|
1 <?php |
|
2 |
|
3 /* |
|
4 * This file is part of the Symfony package. |
|
5 * |
|
6 * (c) Fabien Potencier <fabien@symfony.com> |
|
7 * |
|
8 * For the full copyright and license information, please view the LICENSE |
|
9 * file that was distributed with this source code. |
|
10 */ |
|
11 |
|
12 namespace Symfony\Bundle\FrameworkBundle\Templating; |
|
13 |
|
14 use Symfony\Component\Templating\TemplateReference as BaseTemplateReference; |
|
15 |
|
16 /** |
|
17 * Internal representation of a template. |
|
18 * |
|
19 * @author Victor Berchet <victor@suumit.com> |
|
20 */ |
|
21 class TemplateReference extends BaseTemplateReference |
|
22 { |
|
23 public function __construct($bundle = null, $controller = null, $name = null, $format = null, $engine = null) |
|
24 { |
|
25 $this->parameters = array( |
|
26 'bundle' => $bundle, |
|
27 'controller' => $controller, |
|
28 'name' => $name, |
|
29 'format' => $format, |
|
30 'engine' => $engine, |
|
31 ); |
|
32 } |
|
33 |
|
34 /** |
|
35 * Returns the path to the template |
|
36 * - as a path when the template is not part of a bundle |
|
37 * - as a resource when the template is part of a bundle |
|
38 * |
|
39 * @return string A path to the template or a resource |
|
40 */ |
|
41 public function getPath() |
|
42 { |
|
43 $controller = str_replace('\\', '/', $this->get('controller')); |
|
44 |
|
45 $path = (empty($controller) ? '' : $controller.'/').$this->get('name').'.'.$this->get('format').'.'.$this->get('engine'); |
|
46 |
|
47 return empty($this->parameters['bundle']) ? 'views/'.$path : '@'.$this->get('bundle').'/Resources/views/'.$path; |
|
48 } |
|
49 |
|
50 /** |
|
51 * {@inheritdoc} |
|
52 */ |
|
53 public function getLogicalName() |
|
54 { |
|
55 return sprintf('%s:%s:%s.%s.%s', $this->parameters['bundle'], $this->parameters['controller'], $this->parameters['name'], $this->parameters['format'], $this->parameters['engine']); |
|
56 } |
|
57 } |