diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 844bfa6f26..9c1da19924 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -38,6 +38,11 @@ class FrameworkExtension extends Extension private $translationConfigEnabled = false; private $sessionConfigEnabled = false; + /** + * @var string|null + */ + private $kernelRootHash; + /** * Responds to the app.config configuration parameter. * @@ -779,7 +784,7 @@ class FrameworkExtension extends Extension if (isset($config['cache'])) { $container->setParameter( 'validator.mapping.cache.prefix', - 'validator_'.hash('sha256', $container->getParameter('kernel.root_dir')) + 'validator_'.$this->getKernelRootHash($container) ); $validatorBuilder->addMethodCall('setMetadataCache', array(new Reference($config['cache']))); @@ -961,7 +966,7 @@ class FrameworkExtension extends Extension if (isset($config['cache']) && $config['cache']) { $container->setParameter( 'serializer.mapping.cache.prefix', - 'serializer_'.hash('sha256', $container->getParameter('kernel.root_dir')) + 'serializer_'.$this->getKernelRootHash($container) ); $container->getDefinition('serializer.mapping.class_metadata_factory')->replaceArgument( @@ -970,6 +975,22 @@ class FrameworkExtension extends Extension } } + /** + * Gets a hash of the kernel root directory. + * + * @param ContainerBuilder $container + * + * @return string + */ + private function getKernelRootHash(ContainerBuilder $container) + { + if (!$this->kernelRootHash) { + $this->kernelRootHash = hash('sha256', $container->getParameter('kernel.root_dir')); + } + + return $this->kernelRootHash; + } + /** * Returns the base path for the XSD files. *