minor #16941 [FrameworkBundle] Compute the kernel root hash only one time (dunglas)
This PR was merged into the 2.7 branch.
Discussion
----------
[FrameworkBundle] Compute the kernel root hash only one time
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | n/a
| License | MIT
| Doc PR | n/a
Commits
-------
23431e9
[FrameworkBundle] Compute the kernel root hash only one time
This commit is contained in:
commit
c738085cb3
@ -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.
|
||||
*
|
||||
|
Reference in New Issue
Block a user