You are here

public function Twig_Environment::addExtension in Translation template extractor 6.3

Same name and namespace in other branches
  1. 7.3 vendor/Twig/Environment.php \Twig_Environment::addExtension()

Registers an extension.

Parameters

Twig_ExtensionInterface $extension A Twig_ExtensionInterface instance:

2 calls to Twig_Environment::addExtension()
Twig_Environment::setExtensions in vendor/Twig/Environment.php
Registers an array of extensions.
Twig_Environment::__construct in vendor/Twig/Environment.php
Constructor.

File

vendor/Twig/Environment.php, line 657

Class

Twig_Environment
Stores the Twig configuration.

Code

public function addExtension(Twig_ExtensionInterface $extension) {
  if ($this->extensionInitialized) {
    throw new LogicException(sprintf('Unable to register extension "%s" as extensions have already been initialized.', $extension
      ->getName()));
  }
  $this->extensions[$extension
    ->getName()] = $extension;
}