Prechádzať zdrojové kódy

[FrameworkBundle] added cache warmer priority

Kris Wallsmith 14 rokov pred
rodič
commit
ea536b0d9e

+ 6 - 1
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddCacheWarmerPass.php

@@ -33,9 +33,14 @@ class AddCacheWarmerPass implements CompilerPassInterface
 
         $warmers = array();
         foreach ($container->findTaggedServiceIds('kernel.cache_warmer') as $id => $attributes) {
-            $warmers[] = new Reference($id);
+            $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
+            $warmers[$priority][] = new Reference($id);
         }
 
+        // sort by priority and flatten
+        krsort($warmers);
+        $warmers = call_user_func_array('array_merge', $warmers);
+
         $container->getDefinition('cache_warmer')->setArgument(0, $warmers);
 
         if ('full' === $container->getParameter('kernel.cache_warmup')) {