Created
June 9, 2016 09:46
-
-
Save StanAngeloff/b1c271c27352a51bf82151911676606e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
final class CreateRegistryServicesPass extends AbstractCompilerPass | |
{ | |
# … | |
/** | |
* Create a service decorator which will memoize values returned by the registry making it deterministic. | |
* | |
* @param ContainerBuilder $container | |
* @param string $registryId | |
* @param string $memoizeGroup | |
* | |
* @return void | |
*/ | |
private function processMemoizer(ContainerBuilder $container, $registryId, $memoizeGroup) | |
{ | |
$decorator = new DefinitionDecorator("{$this->getAlias()}.registry.memoizer"); | |
$decorator->setDecoratedService( | |
$registryId, | |
/* $renamedId = */ "{$registryId}_inner" | |
); | |
$decorator->setPublic(false); | |
$decorator->addArgument(new Reference("{$registryId}_inner")); | |
$decorator->addArgument($memoizeGroup); | |
$container->setDefinition( | |
/* $id = */ "{$registryId}_memoizer", | |
$decorator | |
); | |
} | |
# … | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
registry.memoizer: | |
class: RegistryMemoizer | |
abstract: true | |
arguments: | |
- @registry.memoizer_backend | |
registry.doctrine_dbal_memoizer_backend: | |
class: DoctrineDbalMemoizeBackend | |
registry.memoizer_backend: | |
alias: registry.doctrine_dbal_memoizer_backend |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment