public function Extension::getAlias in Service Container 7
Same name and namespace in other branches
- 7.2 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Extension/Extension.php \Symfony\Component\DependencyInjection\Extension\Extension::getAlias()
Returns the recommended alias to use in XML.
This alias is also the mandatory prefix to use when using YAML.
This convention is to remove the "Extension" postfix from the class name and then lowercase and underscore the result. So:
AcmeHelloExtension
becomes
acme_hello
This can be overridden in a sub-class to specify the alias manually.
Return value
string The alias
Throws
BadMethodCallException When the extension name does not follow conventions
Overrides ExtensionInterface::getAlias
1 call to Extension::getAlias()
- Extension::getNamespace in modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ DependencyInjection/ Extension/ Extension.php - Returns the namespace to be used for this extension (XML namespace).
File
- modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ DependencyInjection/ Extension/ Extension.php, line 69
Class
- Extension
- Provides useful features shared by many extensions.
Namespace
Symfony\Component\DependencyInjection\ExtensionCode
public function getAlias() {
$className = get_class($this);
if (substr($className, -9) != 'Extension') {
throw new BadMethodCallException('This extension does not follow the naming convention; you must overwrite the getAlias() method.');
}
$classBaseName = substr(strrchr($className, '\\'), 1, -9);
return Container::underscore($classBaseName);
}