| Conditions | 7 |
| Paths | 9 |
| Total Lines | 28 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 22 | public function process(ContainerBuilder $container) |
||
| 23 | { |
||
| 24 | // This pass is CLI only as CLI class cache warmup conflicts with web access, see EZP-29034 |
||
| 25 | if (PHP_SAPI !== 'cli' || |
||
| 26 | !$container->hasDefinition('kernel.class_cache.cache_warmer')) { |
||
| 27 | return; |
||
| 28 | } |
||
| 29 | |||
| 30 | $warmers = array(); |
||
| 31 | foreach ($container->findTaggedServiceIds('kernel.cache_warmer') as $id => $attributes) { |
||
| 32 | if ($id === 'kernel.class_cache.cache_warmer') { |
||
| 33 | continue; |
||
| 34 | } |
||
| 35 | |||
| 36 | $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; |
||
| 37 | $warmers[$priority][] = new Reference($id); |
||
| 38 | } |
||
| 39 | |||
| 40 | if (empty($warmers)) { |
||
| 41 | return; |
||
| 42 | } |
||
| 43 | |||
| 44 | // sort by priority and flatten |
||
| 45 | krsort($warmers); |
||
| 46 | $warmers = \call_user_func_array('array_merge', $warmers); |
||
| 47 | |||
| 48 | $container->getDefinition('cache_warmer')->replaceArgument(0, $warmers); |
||
| 49 | } |
||
| 50 | } |
||
| 51 |