diff --git a/eZ/Bundle/EzPublishCoreBundle/DependencyInjection/Compiler/ConsoleCacheWarmupPass.php b/eZ/Bundle/EzPublishCoreBundle/DependencyInjection/Compiler/ConsoleCacheWarmupPass.php new file mode 100644 index 00000000000..174f6462261 --- /dev/null +++ b/eZ/Bundle/EzPublishCoreBundle/DependencyInjection/Compiler/ConsoleCacheWarmupPass.php @@ -0,0 +1,50 @@ +hasDefinition('kernel.class_cache.cache_warmer')) { + return; + } + + $warmers = array(); + foreach ($container->findTaggedServiceIds('kernel.cache_warmer') as $id => $attributes) { + if ($id === 'kernel.class_cache.cache_warmer') { + continue; + } + + $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; + $warmers[$priority][] = new Reference($id); + } + + if (empty($warmers)) { + return; + } + + // sort by priority and flatten + krsort($warmers); + $warmers = \call_user_func_array('array_merge', $warmers); + + $container->getDefinition('cache_warmer')->replaceArgument(0, $warmers); + } +} diff --git a/eZ/Bundle/EzPublishCoreBundle/EzPublishCoreBundle.php b/eZ/Bundle/EzPublishCoreBundle/EzPublishCoreBundle.php index c8497fa8f8f..6a03ed8ce58 100644 --- a/eZ/Bundle/EzPublishCoreBundle/EzPublishCoreBundle.php +++ b/eZ/Bundle/EzPublishCoreBundle/EzPublishCoreBundle.php @@ -12,6 +12,7 @@ use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\BinaryContentDownloadPass; use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\ComplexSettingsPass; use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\ConfigResolverParameterPass; +use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\ConsoleCacheWarmupPass; use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\FieldTypeParameterProviderRegistryPass; use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\FragmentPass; use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\NotificationRendererPass; @@ -84,6 +85,7 @@ public function build(ContainerBuilder $container) $container->addCompilerPass(new ViewProvidersPass()); $container->addCompilerPass(new PlaceholderProviderPass()); $container->addCompilerPass(new NotificationRendererPass()); + $container->addCompilerPass(new ConsoleCacheWarmupPass()); // Storage passes $container->addCompilerPass(new ExternalStorageRegistryPass());