[HttpKernel] added check of default extension alias convention
This commit is contained in:
parent
7dfe286897
commit
97f66e93ac
@ -66,7 +66,24 @@ abstract class Bundle extends ContainerAware implements BundleInterface
|
|||||||
{
|
{
|
||||||
if (null === $this->extension) {
|
if (null === $this->extension) {
|
||||||
$class = $this->getNamespace().'\\DependencyInjection\\'.str_replace('Bundle', 'Extension', $this->getName());
|
$class = $this->getNamespace().'\\DependencyInjection\\'.str_replace('Bundle', 'Extension', $this->getName());
|
||||||
$this->extension = class_exists($class) ? new $class() : false;
|
if (class_exists($class)) {
|
||||||
|
$extension = new $class();
|
||||||
|
|
||||||
|
// check naming convention
|
||||||
|
$expectedAlias = Container::underscore(str_replace('Bundle', '', $this->getName()));
|
||||||
|
if ($expectedAlias != $extension->getAlias()) {
|
||||||
|
throw new \LogicException(sprintf(
|
||||||
|
'The extension alias for the default extension of a '.
|
||||||
|
'bundle must be the underscored version of the '.
|
||||||
|
'bundle name ("%s" vs "%s")',
|
||||||
|
$expectedAlias, $extension->getAlias()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->extension = $extension;
|
||||||
|
} else {
|
||||||
|
$this->extension = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->extension) {
|
if ($this->extension) {
|
||||||
|
Reference in New Issue
Block a user