vendor/symfony/framework-bundle/Templating/TemplateReference.php line 14

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\FrameworkBundle\Templating;
  11. @trigger_error('The '.TemplateReference::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', \E_USER_DEPRECATED);
  12. use Symfony\Component\Templating\TemplateReference as BaseTemplateReference;
  13. /**
  14.  * Internal representation of a template.
  15.  *
  16.  * @author Victor Berchet <victor@suumit.com>
  17.  *
  18.  * @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
  19.  */
  20. class TemplateReference extends BaseTemplateReference
  21. {
  22.     public function __construct(string $bundle nullstring $controller nullstring $name nullstring $format nullstring $engine null)
  23.     {
  24.         $this->parameters = [
  25.             'bundle' => $bundle,
  26.             'controller' => $controller,
  27.             'name' => $name,
  28.             'format' => $format,
  29.             'engine' => $engine,
  30.         ];
  31.     }
  32.     /**
  33.      * Returns the path to the template
  34.      *  - as a path when the template is not part of a bundle
  35.      *  - as a resource when the template is part of a bundle.
  36.      *
  37.      * @return string A path to the template or a resource
  38.      */
  39.     public function getPath()
  40.     {
  41.         $controller str_replace('\\''/'$this->get('controller'));
  42.         $path = (empty($controller) ? '' $controller.'/').$this->get('name').'.'.$this->get('format').'.'.$this->get('engine');
  43.         return empty($this->parameters['bundle']) ? 'views/'.$path '@'.$this->get('bundle').'/Resources/views/'.$path;
  44.     }
  45.     /**
  46.      * {@inheritdoc}
  47.      */
  48.     public function getLogicalName()
  49.     {
  50.         return sprintf('%s:%s:%s.%s.%s'$this->parameters['bundle'], $this->parameters['controller'], $this->parameters['name'], $this->parameters['format'], $this->parameters['engine']);
  51.     }
  52. }