You are here

public function Twig_Environment::addExtension in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/twig/twig/lib/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/twig/lib/Twig/Environment.php
Registers an array of extensions.
Twig_Environment::__construct in vendor/twig/twig/lib/Twig/Environment.php
Constructor.

File

vendor/twig/twig/lib/Twig/Environment.php, line 781

Class

Twig_Environment
Stores the Twig configuration.

Code

public function addExtension(Twig_ExtensionInterface $extension) {
  $name = $extension
    ->getName();
  if ($this->extensionInitialized) {
    throw new LogicException(sprintf('Unable to register extension "%s" as extensions have already been initialized.', $name));
  }
  if (isset($this->extensions[$name])) {
    @trigger_error(sprintf('The possibility to register the same extension twice ("%s") is deprecated and will be removed in Twig 2.0. Use proper PHP inheritance instead.', $name), E_USER_DEPRECATED);
  }
  $this->lastModifiedExtension = 0;
  $this->extensions[$name] = $extension;
}