PHP Twig_Template::getSource Examples

PHP Twig_Template::getSource - 2 examples found. These are the top rated real world PHP examples of Twig_Template::getSource extracted from open source projects. You can rate examples to help us improve the quality of examples.
 private function getTemplateSource(\Twig_Template $template)
 {
     // Twig templates are not always stored in files, and so there is no
     // API to get the filename from a template name in a generic way.
     // The logic used here works only for templates stored in app/Resources/views
     // and referenced via the "filename.html.twig" notation, not via the "::filename.html.twig"
     // one or stored in bundles. This is enough for the needs of the demo app.
     $filePath = $this->kernelRootDir . '/Resources/views/' . $template->getTemplateName();
     $sourceCode = $template->getSource();
     // Temporary workaround for https://github.com/twigphp/Twig/issues/2011
     if (null === $sourceCode) {
         $sourceCode = @file_get_contents($filePath);
     }
     return ['file_path' => $filePath, 'starting_line' => 1, 'source_code' => $sourceCode];
 }
 private function getTemplateSource(\Twig_Template $template)
 {
     return array('file_path' => $this->kernelRootDir . '/Resources/views/' . $template->getTemplateName(), 'starting_line' => 1, 'source_code' => $template->getSource());
 }