Esempio n. 1
0
 /**
  * Registers an extension.
  *
  * @param Twig_ExtensionInterface $extension A Twig_ExtensionInterface instance
  */
 public function addExtension(Twig_ExtensionInterface $extension)
 {
     $this->extensions[$extension->getName()] = $extension;
     $this->parsers = null;
     $this->visitors = null;
     $this->filters = null;
     $this->tests = null;
     $this->functions = null;
     $this->globals = null;
 }
Esempio n. 2
0
 /**
  * Registers an extension.
  *
  * @param Twig_ExtensionInterface $extension A Twig_ExtensionInterface instance
  */
 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;
 }
Esempio n. 3
0
 public function addExtension(Twig_ExtensionInterface $extension)
 {
     $this->extensions[$extension->getName()] = $extension;
 }
Esempio n. 4
0
 /**
  * Registers an extension.
  *
  * @param Twig_ExtensionInterface $extension A Twig_ExtensionInterface instance
  */
 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 since version 1.23 and will be removed in Twig 2.0. Use proper PHP inheritance instead.', $name), E_USER_DEPRECATED);
     }
     $this->lastModifiedExtension = 0;
     $this->extensions[$name] = $extension;
 }
Esempio n. 5
0
 /**
  * Registers an extension.
  *
  * @param Twig_ExtensionInterface $extension A Twig_ExtensionInterface instance
  */
 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])) {
         throw new LogicException(sprintf('Unable to register extension "%s" as it is already registered.', $name));
     }
     $this->lastModifiedExtension = 0;
     $this->extensions[$name] = $extension;
 }
Esempio n. 6
0
 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()));
     }
     $class = get_class($extension);
     if ($class !== $extension->getName()) {
         if (isset($this->extensions[$extension->getName()])) {
             unset($this->extensions[$extension->getName()], $this->extensionsByClass[$class]);
             @trigger_error(sprintf('The possibility to register the same extension twice ("%s") is deprecated since version 1.23 and will be removed in Twig 2.0. Use proper PHP inheritance instead.', $extension->getName()), E_USER_DEPRECATED);
         }
     }
     $this->lastModifiedExtension = 0;
     $this->extensionsByClass[$class] = $extension;
     $this->extensions[$extension->getName()] = $extension;
     $this->updateOptionsHash();
 }
 /**
  * Registers an extension.
  *
  * @param Twig_ExtensionInterface $extension A Twig_ExtensionInterface instance
  */
 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()));
     }
     $r = new ReflectionObject($extension);
     if (($extensionTime = filemtime($r->getFileName())) > $this->lastModifiedExtension) {
         $this->lastModifiedExtension = $extensionTime;
     }
     $this->extensions[$extension->getName()] = $extension;
 }