Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Form] Added ResetInterface to CachingFactoryDecorator #30597

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
Mar 20, 2019
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 @@ -53,6 +53,7 @@
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Form\ChoiceList\Factory\CachingFactoryDecorator;
use Symfony\Component\Form\FormTypeExtensionInterface;
use Symfony\Component\Form\FormTypeGuesserInterface;
use Symfony\Component\Form\FormTypeInterface;
Expand Down Expand Up @@ -410,6 +411,11 @@ private function registerFormConfiguration(array $config, ContainerBuilder $cont
if (!class_exists(Translator::class)) {
$container->removeDefinition('form.type_extension.upload.validator');
}
if (!method_exists(CachingFactoryDecorator::class, 'reset')) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I guess this can be reverted when merged in master.

$container->getDefinition('form.choice_list_factory.cached')
->clearTag('kernel.reset')
;
}
}

private function registerEsiConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@

<service id="form.choice_list_factory.cached" class="Symfony\Component\Form\ChoiceList\Factory\CachingFactoryDecorator">
<argument type="service" id="form.choice_list_factory.property_access"/>
<tag name="kernel.reset" method="reset" />
</service>

<service id="form.choice_list_factory" alias="form.choice_list_factory.cached" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
use Symfony\Component\Form\ChoiceList\View\ChoiceListView;
use Symfony\Contracts\Service\ResetInterface;

/**
* Caches the choice lists created by the decorated factory.
*
* @author Bernhard Schussek <[email protected]>
*/
class CachingFactoryDecorator implements ChoiceListFactoryInterface
class CachingFactoryDecorator implements ChoiceListFactoryInterface, ResetInterface
{
private $decoratedFactory;

Expand Down Expand Up @@ -134,4 +135,10 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,

return $this->views[$hash];
}

public function reset()
{
$this->lists = [];
$this->views = [];
}
}