1 | <?php |
||
27 | class PuliExtension extends Twig_Extension |
||
28 | { |
||
29 | /** |
||
30 | * Priority for node visitors that want to work with relative path before |
||
31 | * they are turned into absolute paths. |
||
32 | */ |
||
33 | const PRE_RESOLVE_PATHS = 4; |
||
34 | |||
35 | /** |
||
36 | * Priority for node visitors that turn relative paths into absolute paths. |
||
37 | */ |
||
38 | const RESOLVE_PATHS = 5; |
||
39 | |||
40 | /** |
||
41 | * Priority for node visitors that want to work with absolute paths. |
||
42 | */ |
||
43 | const POST_RESOLVE_PATHS = 6; |
||
44 | |||
45 | /** |
||
46 | * @var ResourceRepository |
||
47 | */ |
||
48 | private $repo; |
||
49 | |||
50 | /** |
||
51 | * @var UrlGenerator |
||
52 | */ |
||
53 | private $urlGenerator; |
||
54 | |||
55 | /** |
||
56 | * @var bool |
||
57 | */ |
||
58 | private $supportFallbackLoader; |
||
59 | |||
60 | 23 | public function __construct(ResourceRepository $repo, UrlGenerator $urlGenerator = null, $supportFallbackLoader = false) |
|
61 | { |
||
62 | 23 | $this->repo = $repo; |
|
63 | 23 | $this->urlGenerator = $urlGenerator; |
|
64 | 23 | $this->supportFallbackLoader = $supportFallbackLoader; |
|
65 | 23 | } |
|
66 | |||
67 | /** |
||
68 | * Returns the name of the extension. |
||
69 | * |
||
70 | * @return string The extension name |
||
71 | */ |
||
72 | 23 | public function getName() |
|
76 | |||
77 | /** |
||
78 | * {@inheritdoc} |
||
79 | */ |
||
80 | 23 | public function getNodeVisitors() |
|
81 | { |
||
82 | return array( |
||
83 | 23 | new PuliDirTagger(), |
|
84 | 23 | new TemplatePathResolver($this->repo, $this->urlGenerator, $this->supportFallbackLoader), |
|
85 | ); |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * {@inheritdoc} |
||
90 | */ |
||
91 | 23 | public function getTokenParsers() |
|
95 | |||
96 | /** |
||
97 | * {@inheritdoc} |
||
98 | */ |
||
99 | 23 | public function getFunctions() |
|
107 | } |
||
108 |