當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Twig_ExtensionInterface::getGlobals方法代碼示例

本文整理匯總了PHP中Twig_ExtensionInterface::getGlobals方法的典型用法代碼示例。如果您正苦於以下問題:PHP Twig_ExtensionInterface::getGlobals方法的具體用法?PHP Twig_ExtensionInterface::getGlobals怎麽用?PHP Twig_ExtensionInterface::getGlobals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Twig_ExtensionInterface的用法示例。


在下文中一共展示了Twig_ExtensionInterface::getGlobals方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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;
     }
     // globals
     $this->globals = array_merge($this->globals, $extension->getGlobals());
     // 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:ideafresh,項目名稱:Slim-Boilerplate,代碼行數:57,代碼來源:Environment.php


注:本文中的Twig_ExtensionInterface::getGlobals方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。