getRenderizer() публичный Метод

Gets the renderizer.
public getRenderizer ( ) : Yosymfony\Spress\Core\ContentManager\Renderizer\RenderizerInterface
Результат Yosymfony\Spress\Core\ContentManager\Renderizer\RenderizerInterface
Пример #1
0
 public function testEnvironmentEvent()
 {
     $dsm = $this->getMockBuilder('\\Yosymfony\\Spress\\Core\\DataSource\\DataSourceManager')->getMock();
     $cm = $this->getMockBuilder('\\Yosymfony\\Spress\\Core\\ContentManager\\Converter\\ConverterManager')->getMock();
     $gm = $this->getMockBuilder('\\Yosymfony\\Spress\\Core\\ContentManager\\Generator\\GeneratorManager')->getMock();
     $renderizer = $this->getMockBuilder('\\Yosymfony\\Spress\\Core\\ContentManager\\Renderizer\\RenderizerInterface')->getMock();
     $io = $this->getMockBuilder('\\Yosymfony\\Spress\\Core\\IO\\IOInterface')->getMock();
     $dw = $this->getMockBuilder('\\Yosymfony\\Spress\\Core\\DataWriter\\DataWriterInterface')->getMock();
     $configValues = ['name' => 'Yo! Symfony'];
     $event = new EnvironmentEvent($dsm, $dw, $cm, $gm, $renderizer, $io, $configValues);
     $this->assertInstanceOf('\\Yosymfony\\Spress\\Core\\DataSource\\DataSourceManager', $event->getDataSourceManager());
     $this->assertInstanceOf('\\Yosymfony\\Spress\\Core\\DataWriter\\DataWriterInterface', $event->getDataWriter());
     $this->assertInstanceOf('\\Yosymfony\\Spress\\Core\\ContentManager\\Converter\\ConverterManager', $event->getConverterManager());
     $this->assertInstanceOf('\\Yosymfony\\Spress\\Core\\ContentManager\\Generator\\GeneratorManager', $event->getGeneratorManager());
     $this->assertInstanceOf('\\Yosymfony\\Spress\\Core\\ContentManager\\Renderizer\\RenderizerInterface', $event->getRenderizer());
     $this->assertInstanceOf('\\Yosymfony\\Spress\\Core\\IO\\IOInterface', $event->getIO());
     $values = $event->getConfigValues();
     $this->assertTrue(is_array($values));
     $this->assertArrayHasKey('name', $values);
     $this->assertEquals('Yo! Symfony', $values['name']);
     $values['title'] = 'My blog page';
     $event->setConfigValues($values);
     $this->assertArrayHasKey('name', $configValues);
     $this->assertEquals('My blog page', $configValues['title']);
 }
 /**
  * Register the `codeblock` tag on startup
  *
  * @param EnvironmentEvent $event The start event
  */
 public function onStart(EnvironmentEvent $event)
 {
     $renderizer = $event->getRenderizer();
     if (method_exists($renderizer, 'addTwigTag')) {
         $renderizer->addTwigTag(new CodeBlockParser());
     }
 }
 public function onStart(EnvironmentEvent $event)
 {
     $renderizer = $event->getRenderizer();
     $renderizer->addTwigFilter('slugify', function ($text) {
         $string = new StringWrapper($text);
         return $string->slug();
     });
 }
 /**
  * Load requested Twig extensions on startup
  *
  * @param EnvironmentEvent $event The start event
  */
 public function onStart(EnvironmentEvent $event)
 {
     $configValues = $event->getConfigValues();
     $configValues['twig_extensions'] = (new Configuration($configValues))->getExtensions();
     $event->setConfigValues($configValues);
     $factory = new ExtensionFactory();
     $renderizer = $event->getRenderizer();
     foreach ($configValues['twig_extensions'] as $extension) {
         try {
             $factory->getExtension($extension)->load($renderizer);
         } catch (\UnexpectedValueException $e) {
             $event->getIO()->warning($e->getMessage());
         }
     }
 }
 public function onStart(EnvironmentEvent $event)
 {
     $renderizer = $event->getRenderizer();
     $renderizer->addTwigFilter('excerpt', function ($text) {
         return $this->getExcerpt($text);
     });
     $renderizer->addTwigFilter('content', function ($text) {
         return $this->getContentWithoutExcerptLabel($text);
     });
     $renderizer->addTwigFilter('excerpt_label', function ($text) {
         return $this->getExcerptLabel($text);
     });
     $renderizer->addTwigTest('with_excerpt', function ($text) {
         return $this->hasExcerpt($text);
     });
 }
 public function onStart(EnvironmentEvent $event)
 {
     $renderizer = $event->getRenderizer();
     $renderizer->addTwigFunction('remote_json', function ($url) {
         if (!file_exists('.cache')) {
             mkdir('.cache');
         }
         $cache_file = '.cache/' . sha1($url);
         if (file_exists($cache_file) && filemtime($cache_file) > time() - 60 * 5) {
             $json = file_get_contents($cache_file);
         } else {
             $curl = curl_init();
             curl_setopt_array($curl, [CURLOPT_RETURNTRANSFER => true, CURLOPT_USERAGENT => 'spress/' . Yosymfony\Spress\Core\Spress::VERSION, CURLOPT_URL => $url]);
             $json = curl_exec($curl);
             file_put_contents($cache_file, $json, LOCK_EX);
         }
         return json_decode($json);
     });
 }