public function Bundle::getContainerExtension in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/symfony/http-kernel/Bundle/Bundle.php \Symfony\Component\HttpKernel\Bundle\Bundle::getContainerExtension()
Returns the bundle's container extension.
Return value
ExtensionInterface|null The container extension
Throws
\LogicException
Overrides BundleInterface::getContainerExtension
File
- vendor/
symfony/ http-kernel/ Bundle/ Bundle.php, line 68
Class
- Bundle
- An implementation of BundleInterface that adds a few conventions for DependencyInjection extensions and Console commands.
Namespace
Symfony\Component\HttpKernel\BundleCode
public function getContainerExtension() {
if (null === $this->extension) {
$class = $this
->getContainerExtensionClass();
if (class_exists($class)) {
$extension = new $class();
if (!$extension instanceof ExtensionInterface) {
throw new \LogicException(sprintf('Extension %s must implement Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface.', $class));
}
// check naming convention
$basename = preg_replace('/Bundle$/', '', $this
->getName());
$expectedAlias = Container::underscore($basename);
if ($expectedAlias != $extension
->getAlias()) {
throw new \LogicException(sprintf('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.', $expectedAlias, $extension
->getAlias()));
}
$this->extension = $extension;
}
else {
$this->extension = false;
}
}
if ($this->extension) {
return $this->extension;
}
}