You are here

public function Extension::getAlias in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/dependency-injection/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 vendor/symfony/dependency-injection/Extension/Extension.php
Returns the namespace to be used for this extension (XML namespace).

File

vendor/symfony/dependency-injection/Extension/Extension.php, line 69

Class

Extension
Provides useful features shared by many extensions.

Namespace

Symfony\Component\DependencyInjection\Extension

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