当前位置: 首页>>代码示例>>PHP>>正文


PHP Twig_ExtensionInterface::getTokenParsers方法代码示例

本文整理汇总了PHP中Twig_ExtensionInterface::getTokenParsers方法的典型用法代码示例。如果您正苦于以下问题:PHP Twig_ExtensionInterface::getTokenParsers方法的具体用法?PHP Twig_ExtensionInterface::getTokenParsers怎么用?PHP Twig_ExtensionInterface::getTokenParsers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Twig_ExtensionInterface的用法示例。


在下文中一共展示了Twig_ExtensionInterface::getTokenParsers方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: initExtension

 protected function initExtension(Twig_ExtensionInterface $extension)
 {
     // filters
     foreach ($extension->getFilters() as $name => $filter) {
         if ($filter instanceof Twig_SimpleFilter) {
             $name = $filter->getName();
         } else {
             @trigger_error(sprintf('Using an instance of "%s" for filter "%s" is deprecated since version 1.21. Use Twig_SimpleFilter instead.', get_class($filter), $name), E_USER_DEPRECATED);
         }
         $this->filters[$name] = $filter;
     }
     // functions
     foreach ($extension->getFunctions() as $name => $function) {
         if ($function instanceof Twig_SimpleFunction) {
             $name = $function->getName();
         } else {
             @trigger_error(sprintf('Using an instance of "%s" for function "%s" is deprecated since version 1.21. Use Twig_SimpleFunction instead.', get_class($function), $name), E_USER_DEPRECATED);
         }
         $this->functions[$name] = $function;
     }
     // tests
     foreach ($extension->getTests() as $name => $test) {
         if ($test instanceof Twig_SimpleTest) {
             $name = $test->getName();
         } else {
             @trigger_error(sprintf('Using an instance of "%s" for test "%s" is deprecated since version 1.21. Use Twig_SimpleTest instead.', get_class($test), $name), E_USER_DEPRECATED);
         }
         $this->tests[$name] = $test;
     }
     // token parsers
     foreach ($extension->getTokenParsers() as $parser) {
         if ($parser instanceof Twig_TokenParserInterface) {
             $this->parsers->addTokenParser($parser);
         } elseif ($parser instanceof Twig_TokenParserBrokerInterface) {
             @trigger_error('Registering a Twig_TokenParserBrokerInterface instance is deprecated since version 1.21.', E_USER_DEPRECATED);
             $this->parsers->addTokenParserBroker($parser);
         } else {
             throw new LogicException('getTokenParsers() must return an array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances');
         }
     }
     // node visitors
     foreach ($extension->getNodeVisitors() as $visitor) {
         $this->visitors[] = $visitor;
     }
     // operators
     if ($operators = $extension->getOperators()) {
         if (2 !== count($operators)) {
             throw new InvalidArgumentException(sprintf('"%s::getOperators()" does not return a valid operators array.', get_class($extension)));
         }
         $this->unaryOperators = array_merge($this->unaryOperators, $operators[0]);
         $this->binaryOperators = array_merge($this->binaryOperators, $operators[1]);
     }
 }
开发者ID:rogerioleal1,项目名称:ci_base,代码行数:53,代码来源:Environment.php

示例2: initExtension

 protected function initExtension(Twig_ExtensionInterface $extension)
 {
     // filters
     foreach ($extension->getFilters() as $name => $filter) {
         if ($name instanceof Twig_SimpleFilter) {
             $filter = $name;
             $name = $filter->getName();
         } elseif ($filter instanceof Twig_SimpleFilter) {
             $name = $filter->getName();
         }
         $this->filters[$name] = $filter;
     }
     // functions
     foreach ($extension->getFunctions() as $name => $function) {
         if ($name instanceof Twig_SimpleFunction) {
             $function = $name;
             $name = $function->getName();
         } elseif ($function instanceof Twig_SimpleFunction) {
             $name = $function->getName();
         }
         $this->functions[$name] = $function;
     }
     // tests
     foreach ($extension->getTests() as $name => $test) {
         if ($name instanceof Twig_SimpleTest) {
             $test = $name;
             $name = $test->getName();
         } elseif ($test instanceof Twig_SimpleTest) {
             $name = $test->getName();
         }
         $this->tests[$name] = $test;
     }
     // token parsers
     foreach ($extension->getTokenParsers() as $parser) {
         if ($parser instanceof Twig_TokenParserInterface) {
             $this->parsers->addTokenParser($parser);
         } elseif ($parser instanceof Twig_TokenParserBrokerInterface) {
             $this->parsers->addTokenParserBroker($parser);
         } else {
             throw new LogicException('getTokenParsers() must return an array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances');
         }
     }
     // node visitors
     foreach ($extension->getNodeVisitors() as $visitor) {
         $this->visitors[] = $visitor;
     }
     // operators
     if ($operators = $extension->getOperators()) {
         if (2 !== count($operators)) {
             throw new InvalidArgumentException(sprintf('"%s::getOperators()" does not return a valid operators array.', get_class($extension)));
         }
         $this->unaryOperators = array_merge($this->unaryOperators, $operators[0]);
         $this->binaryOperators = array_merge($this->binaryOperators, $operators[1]);
     }
 }
开发者ID:tschifftner,项目名称:Magento-MEP,代码行数:55,代码来源:Environment.php

示例3: initExtension

 private function initExtension(Twig_ExtensionInterface $extension)
 {
     // filters
     foreach ($extension->getFilters() as $filter) {
         $this->filters[$filter->getName()] = $filter;
     }
     // functions
     foreach ($extension->getFunctions() as $function) {
         $this->functions[$function->getName()] = $function;
     }
     // tests
     foreach ($extension->getTests() as $test) {
         $this->tests[$test->getName()] = $test;
     }
     // token parsers
     foreach ($extension->getTokenParsers() as $parser) {
         if (!$parser instanceof Twig_TokenParserInterface) {
             throw new LogicException('getTokenParsers() must return an array of Twig_TokenParserInterface');
         }
         $this->parsers[] = $parser;
     }
     // node visitors
     foreach ($extension->getNodeVisitors() as $visitor) {
         $this->visitors[] = $visitor;
     }
     // operators
     if ($operators = $extension->getOperators()) {
         if (2 !== count($operators)) {
             throw new InvalidArgumentException(sprintf('"%s::getOperators()" does not return a valid operators array.', get_class($extension)));
         }
         $this->unaryOperators = array_merge($this->unaryOperators, $operators[0]);
         $this->binaryOperators = array_merge($this->binaryOperators, $operators[1]);
     }
 }
开发者ID:PieterSwitten,项目名称:webandmobile,代码行数:34,代码来源:Environment.php


注:本文中的Twig_ExtensionInterface::getTokenParsers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。