vendor/sylius/theme-bundle/src/Twig/Locator/LegacyApplicationTemplateLocator.php line 33

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Sylius package.
  4.  *
  5.  * (c) Paweł Jędrzejewski
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. declare(strict_types=1);
  11. namespace Sylius\Bundle\ThemeBundle\Twig\Locator;
  12. use Sylius\Bundle\ThemeBundle\Model\ThemeInterface;
  13. use Symfony\Component\Filesystem\Filesystem;
  14. /**
  15.  * Handles paths like "template.html.twig" or "Directory/template.html.twig".
  16.  *
  17.  * @deprecated Deprecated since Sylius/ThemeBundle 2.0 and will be removed in 3.0.
  18.  */
  19. final class LegacyApplicationTemplateLocator implements TemplateLocatorInterface
  20. {
  21.     private Filesystem $filesystem;
  22.     public function __construct(Filesystem $filesystem)
  23.     {
  24.         @trigger_error(sprintf(
  25.             '"%s" is deprecated since Sylius/ThemeBundle 2.0 and will be removed in 3.0.',
  26.             self::class,
  27.         ), \E_USER_DEPRECATED);
  28.         $this->filesystem $filesystem;
  29.     }
  30.     public function locate(string $templateThemeInterface $theme): string
  31.     {
  32.         $path sprintf('%s/views/%s'$theme->getPath(), $template);
  33.         if (!$this->filesystem->exists($path)) {
  34.             throw new TemplateNotFoundException($template, [$theme]);
  35.         }
  36.         return $path;
  37.     }
  38.     public function supports(string $template): bool
  39.     {
  40.         return strpos($template'@') !== 0;
  41.     }
  42. }