Attempt to create a reasonable default based on the rules enforced in

src/Symfony/Component/HttpKernel/bootstrap.php
  from commit: 14aa95ba21
This commit is contained in:
Ray 2011-02-17 16:50:22 -06:00 committed by Fabien Potencier
parent f4c0af76e7
commit 8e2d7edb8c

View File

@ -4,6 +4,7 @@ namespace Symfony\Component\HttpKernel\DependencyInjection;
use Symfony\Component\DependencyInjection\Extension\Extension as BaseExtension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Container;
/*
* This file is part of the Symfony framework.
@ -78,4 +79,15 @@ abstract class Extension extends BaseExtension
{
return false;
}
public function getAlias()
{
$className = get_class($this);
if (substr($className, -9) != 'Extension') {
throw new \BadMethodCallException('This extension does not follow the normal naming, so you must overwrite the getAlias method');
}
$classBaseName = substr(strrchr($className, '\\'), 1, -9);
return Container::underscore($classBaseName);
}
}