function 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.
Throws
BadMethodCallException When the extension name does not follow conventions
Overrides ExtensionInterface::getAlias
2 calls to Extension::getAlias()
- AbstractExtension::getConfiguration in vendor/
symfony/ dependency-injection/ Extension/ AbstractExtension.php - Returns extension configuration.
- Extension::getNamespace in vendor/
symfony/ dependency-injection/ Extension/ Extension.php
1 method overrides Extension::getAlias()
- BundleExtension::getAlias in vendor/
symfony/ http-kernel/ Bundle/ BundleExtension.php - Returns the recommended alias to use in XML.
File
-
vendor/
symfony/ dependency-injection/ Extension/ Extension.php, line 65
Class
- Extension
- Provides useful features shared by many extensions.
Namespace
Symfony\Component\DependencyInjection\ExtensionCode
public function getAlias() : string {
$className = static::class;
if (!str_ends_with($className, '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);
}