vendor/simpledot/cms-bundle/AWCmsBundle/Templating/FilesystemLoader.php line 7

Open in your IDE?
  1. <?php
  2. namespace AWCmsBundle\Templating;
  3. /**
  4.  * {@inheritdoc}
  5.  */
  6. class FilesystemLoader extends \Symfony\Bundle\TwigBundle\Loader\FilesystemLoader
  7. {
  8.     /**
  9.      * {@inheritdoc}
  10.      */
  11.     protected function findTemplate($template$throw true)
  12.     {
  13.         $customTemplate $this->getFormatedTemplate($template);
  14.         $twigTemplate parent::findTemplate($customTemplatefalse);
  15.         if (false !== $twigTemplate) {
  16.             return $twigTemplate;
  17.         }
  18.         return parent::findTemplate($template$throw);
  19.     }
  20.     /**
  21.      * Get the formated template.
  22.      *
  23.      * @param string $template The original template
  24.      *
  25.      * @return string The template with a normal path
  26.      */
  27.     protected function getFormatedTemplate($template)
  28.     {
  29.         $customTemplate = (string) $template;
  30.         if ('::' === substr($customTemplate02)) {
  31.             $customTemplate substr($customTemplate2);
  32.         }
  33.         $customTemplate str_replace(':'DIRECTORY_SEPARATOR$customTemplate);
  34.         if (=== strpos($template'@')) {
  35.             $customTemplate substr($customTemplate1);
  36.             $templateExplode explode(DIRECTORY_SEPARATOR$customTemplate);
  37.             // Add Bundle in path if not
  38.             if ('bundle' !== strtolower(substr($templateExplode[0], -6))) {
  39.                 $separatorPosition strpos($customTemplateDIRECTORY_SEPARATOR);
  40.                 $customTemplate substr($customTemplate0$separatorPosition).'Bundle'.substr($customTemplate$separatorPosition);
  41.             }
  42.         }
  43.         return $customTemplate;
  44.     }
  45. }