Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Form][TwigBundle] reset Twig form theme resources between requests #45909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Form\AbstractRendererEngine;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\Mailer\Mailer;
use Symfony\Component\Translation\Translator;
use Symfony\Contracts\Service\ResetInterface;
use Twig\Extension\ExtensionInterface;
use Twig\Extension\RuntimeExtensionInterface;
use Twig\Loader\LoaderInterface;
Expand All @@ -40,6 +42,12 @@ public function load(array $configs, ContainerBuilder $container)

if (class_exists(\Symfony\Component\Form\Form::class)) {
$loader->load('form.xml');

if (is_subclass_of(AbstractRendererEngine::class, ResetInterface::class)) {
$container->getDefinition('twig.form.engine')->addTag('kernel.reset', [
'method' => 'reset',
]);
}
}

if (interface_exists(\Symfony\Component\Templating\EngineInterface::class)) {
Expand Down
12 changes: 11 additions & 1 deletion 12 src/Symfony/Component/Form/AbstractRendererEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@

namespace Symfony\Component\Form;

use Symfony\Contracts\Service\ResetInterface;

/**
* Default implementation of {@link FormRendererEngineInterface}.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
abstract class AbstractRendererEngine implements FormRendererEngineInterface
abstract class AbstractRendererEngine implements FormRendererEngineInterface, ResetInterface
{
/**
* The variable in {@link FormView} used as cache key.
Expand Down Expand Up @@ -197,4 +199,12 @@ private function loadResourceForBlockNameHierarchy(string $cacheKey, FormView $v

return false;
}

public function reset(): void
{
$this->themes = [];
$this->useDefaultThemes = [];
$this->resources = [];
$this->resourceHierarchyLevels = [];
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.