| Conditions | 6 |
| Paths | 8 |
| Total Lines | 31 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 18 | public function getContainerExtension() |
||
| 19 | { |
||
| 20 | if (null === $this->extension) { |
||
| 21 | $extension = $this->createContainerExtension(); |
||
| 22 | |||
| 23 | if (null !== $extension) { |
||
| 24 | if (!$extension instanceof ExtensionInterface) { |
||
| 25 | throw new \LogicException(sprintf('Extension %s must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface.', get_class($extension))); |
||
| 26 | } |
||
| 27 | |||
| 28 | // check naming convention |
||
| 29 | $basename = preg_replace('/Bundle$/', '', $this->getName()); |
||
| 30 | $expectedAlias = Container::underscore($basename); |
||
| 31 | |||
| 32 | if ($expectedAlias != $extension->getAlias()) { |
||
| 33 | throw new \LogicException(sprintf( |
||
| 34 | 'Users will expect the alias of the default extension of a bundle to be the underscored version of the bundle name ("%s"). You can override "Bundle::getContainerExtension()" if you want to use "%s" or another alias.', |
||
| 35 | $expectedAlias, $extension->getAlias() |
||
| 36 | )); |
||
| 37 | } |
||
| 38 | |||
| 39 | $this->extension = $extension; |
||
| 40 | } else { |
||
| 41 | $this->extension = false; |
||
| 42 | } |
||
| 43 | } |
||
| 44 | |||
| 45 | if ($this->extension) { |
||
| 46 | return $this->extension; |
||
| 47 | } |
||
| 48 | } |
||
| 49 | |||
| 51 |