vendor/symfony/twig-bundle/Loader/NativeFilesystemLoader.php line 32

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Bundle\TwigBundle\Loader;
  11. use Twig\Error\LoaderError;
  12. use Twig\Loader\FilesystemLoader;
  13. /**
  14.  * @author Behnoush Norouzali <behnoush.norouzi@gmail.com>
  15.  *
  16.  * @internal
  17.  */
  18. class NativeFilesystemLoader extends FilesystemLoader
  19. {
  20.     /**
  21.      * {@inheritdoc}
  22.      *
  23.      * @return string|null
  24.      */
  25.     protected function findTemplate($template$throw true)
  26.     {
  27.         try {
  28.             return parent::findTemplate($template$throw);
  29.         } catch (LoaderError $e) {
  30.             if ('' === $template || '@' === $template[0] || !preg_match('/^(?P<bundle>[^:]*?)(?:Bundle)?:(?P<path>[^:]*+):(?P<template>.+\.[^\.]+\.[^\.]+)$/'$template$m)) {
  31.                 throw $e;
  32.             }
  33.             if ('' !== $m['path']) {
  34.                 $m['template'] = $m['path'].'/'.$m['template'];
  35.             }
  36.             if ('' !== $m['bundle']) {
  37.                 $suggestion '@'.$m['bundle'].'/'.$m['template'];
  38.             } else {
  39.                 $suggestion $m['template'];
  40.             }
  41.             if (false === parent::findTemplate($suggestionfalse)) {
  42.                 throw $e;
  43.             }
  44.             throw new LoaderError(sprintf('Template reference "%s" not found, did you mean "%s"?'$template$suggestion), -1null$e);
  45.         }
  46.     }
  47. }