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


PHP Twig_Environment::getNodeVisitors方法代码示例

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


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

示例1: setEnvironment

 public function setEnvironment(Twig_Environment $env)
 {
     $this->env = $env;
     $this->handlers = array();
     $this->visitors = array();
     // tag handlers
     foreach ($this->env->getTokenParsers() as $handler) {
         $handler->setParser($this);
         $this->handlers[$handler->getTag()] = $handler;
     }
     // node visitors
     $this->visitors = $env->getNodeVisitors();
 }
开发者ID:juraj-blahunka,项目名称:Framework-Packages,代码行数:13,代码来源:Parser.php

示例2: testRemoveExtension

 public function testRemoveExtension()
 {
     $twig = new Twig_Environment(new Twig_Loader_String());
     $twig->addExtension(new Twig_Tests_EnvironmentTest_Extension());
     $twig->removeExtension('test');
     $this->assertFalse(array_key_exists('test', $twig->getTags()));
     $this->assertFalse(array_key_exists('foo_filter', $twig->getFilters()));
     $this->assertFalse(array_key_exists('foo_function', $twig->getFunctions()));
     $this->assertFalse(array_key_exists('foo_test', $twig->getTests()));
     $this->assertFalse(array_key_exists('foo_unary', $twig->getUnaryOperators()));
     $this->assertFalse(array_key_exists('foo_binary', $twig->getBinaryOperators()));
     $this->assertFalse(array_key_exists('foo_global', $twig->getGlobals()));
     $this->assertCount(2, $twig->getNodeVisitors());
 }
开发者ID:simonjodet,项目名称:twig,代码行数:14,代码来源:EnvironmentTest.php

示例3: __construct

 /**
  * FileExtractor constructor.
  * @param \Twig_Environment $twig
  * @param LoggerInterface $logger
  * @param array $visitors
  */
 public function __construct(\Twig_Environment $twig, LoggerInterface $logger, array $visitors)
 {
     $this->twig = $twig;
     $this->visitors = $visitors;
     $this->setLogger($logger);
     $lexer = new Lexer();
     if (class_exists('PhpParser\\ParserFactory')) {
         $factory = new ParserFactory();
         $this->phpParser = $factory->create(ParserFactory::PREFER_PHP7, $lexer);
     } else {
         $this->phpParser = new Parser($lexer);
     }
     foreach ($this->twig->getNodeVisitors() as $visitor) {
         if ($visitor instanceof RemovingNodeVisitor) {
             $this->removingTwigVisitor = $visitor;
         }
         if ($visitor instanceof DefaultApplyingNodeVisitor) {
             $this->defaultApplyingTwigVisitor = $visitor;
         }
     }
 }
开发者ID:clytemnestra,项目名称:JMSTranslationBundle,代码行数:27,代码来源:FileExtractor.php

示例4: testAddExtension

 public function testAddExtension()
 {
     $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
     $twig->addExtension(new Twig_Tests_EnvironmentTest_Extension());
     $this->assertArrayHasKey('test', $twig->getTags());
     $this->assertArrayHasKey('foo_filter', $twig->getFilters());
     $this->assertArrayHasKey('foo_function', $twig->getFunctions());
     $this->assertArrayHasKey('foo_test', $twig->getTests());
     $this->assertArrayHasKey('foo_unary', $twig->getUnaryOperators());
     $this->assertArrayHasKey('foo_binary', $twig->getBinaryOperators());
     $this->assertArrayHasKey('foo_global', $twig->getGlobals());
     $visitors = $twig->getNodeVisitors();
     $this->assertEquals('Twig_Tests_EnvironmentTest_NodeVisitor', get_class($visitors[2]));
 }
开发者ID:JohnnyEstilles,项目名称:Twig,代码行数:14,代码来源:EnvironmentTest.php

示例5: extract

 private function extract($file, TwigFileExtractor $extractor = null)
 {
     if (!is_file($file = __DIR__ . '/Fixture/' . $file)) {
         throw new RuntimeException(sprintf('The file "%s" does not exist.', $file));
     }
     $env = new \Twig_Environment();
     $env->addExtension(new SymfonyTranslationExtension($translator = new IdentityTranslator(new MessageSelector())));
     $env->addExtension(new TranslationExtension($translator, true));
     $env->addExtension(new RoutingExtension(new UrlGenerator(new RouteCollection(), new RequestContext())));
     $env->addExtension(new FormExtension(new TwigRenderer(new TwigRendererEngine())));
     foreach ($env->getNodeVisitors() as $visitor) {
         if ($visitor instanceof DefaultApplyingNodeVisitor) {
             $visitor->setEnabled(false);
         }
         if ($visitor instanceof RemovingNodeVisitor) {
             $visitor->setEnabled(false);
         }
     }
     if (null === $extractor) {
         $extractor = new TwigFileExtractor($env);
     }
     $ast = $env->parse($env->tokenize(file_get_contents($file), $file));
     $catalogue = new MessageCatalogue();
     $extractor->visitTwigFile(new \SplFileInfo($file), $catalogue, $ast);
     return $catalogue;
 }
开发者ID:pixel-cookers,项目名称:JMSTranslationBundle,代码行数:26,代码来源:TwigFileExtractorTest.php

示例6: testRemoveExtension

 /**
  * @group legacy
  */
 public function testRemoveExtension()
 {
     $twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
     $twig->addExtension(new Twig_Tests_EnvironmentTest_Extension_WithDeprecatedName());
     $twig->removeExtension('environment_test');
     $this->assertFalse(array_key_exists('test', $twig->getTags()));
     $this->assertFalse(array_key_exists('foo_filter', $twig->getFilters()));
     $this->assertFalse(array_key_exists('foo_function', $twig->getFunctions()));
     $this->assertFalse(array_key_exists('foo_test', $twig->getTests()));
     $this->assertFalse(array_key_exists('foo_unary', $twig->getUnaryOperators()));
     $this->assertFalse(array_key_exists('foo_binary', $twig->getBinaryOperators()));
     $this->assertFalse(array_key_exists('foo_global', $twig->getGlobals()));
     $this->assertCount(2, $twig->getNodeVisitors());
 }
开发者ID:bigbitecreative,项目名称:wordpress-git-content,代码行数:17,代码来源:EnvironmentTest.php


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