public 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.

Return value

string The alias

Overrides ExtensionInterface::getAlias

1 call to Extension::getAlias()
Extension::getNamespace in drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/Extension.php
Returns the namespace to be used for this extension (XML namespace).

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/Extension.php, line 88

Class

Extension
Provides useful features shared by many extensions.

Namespace

Symfony\Component\HttpKernel\DependencyInjection

Code

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);
}