| Conditions | 4 |
| Paths | 6 |
| Total Lines | 24 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | public function build(ContainerBuilder $container) |
||
| 21 | { |
||
| 22 | parent::build($container); |
||
| 23 | |||
| 24 | $generatorPass = new DependencyInjection\CompilerPass\GenerateAdminServicesCompilerPass(); |
||
| 25 | |||
| 26 | // if the Sonata bundle is configured before this one, the compilerpass must be injected right before, |
||
| 27 | // otherwise the generated services will not be recognized by Sonata. |
||
| 28 | $idx = null; |
||
| 29 | $beforeOptimizationPasses = $container->getCompilerPassConfig()->getBeforeOptimizationPasses(); |
||
| 30 | |||
| 31 | foreach ($beforeOptimizationPasses as $i => $pass) { |
||
| 32 | if ($pass instanceof AddDependencyCallsCompilerPass) { |
||
| 33 | $idx = $i; |
||
| 34 | break; |
||
| 35 | } |
||
| 36 | } |
||
| 37 | |||
| 38 | if (null !== $idx) { |
||
| 39 | array_splice($beforeOptimizationPasses, $idx, 0, array($generatorPass)); |
||
| 40 | } else { |
||
| 41 | $beforeOptimizationPasses[]= $generatorPass; |
||
| 42 | } |
||
| 43 | $container->getCompilerPassConfig()->setBeforeOptimizationPasses($beforeOptimizationPasses); |
||
| 44 | } |
||
| 46 |