1 | <?php |
||
21 | class MediaExtension extends \Twig_Extension implements \Twig_Extension_InitRuntimeInterface |
||
22 | { |
||
23 | /** |
||
24 | * @var Pool |
||
25 | */ |
||
26 | protected $mediaService; |
||
27 | |||
28 | /** |
||
29 | * @var array |
||
30 | */ |
||
31 | protected $resources = array(); |
||
32 | |||
33 | /** |
||
34 | * @var ManagerInterface |
||
35 | */ |
||
36 | protected $mediaManager; |
||
37 | |||
38 | /** |
||
39 | * @var \Twig_Environment |
||
40 | */ |
||
41 | protected $environment; |
||
42 | |||
43 | /** |
||
44 | * @param Pool $mediaService |
||
45 | * @param ManagerInterface $mediaManager |
||
46 | */ |
||
47 | public function __construct(Pool $mediaService, ManagerInterface $mediaManager) |
||
52 | |||
53 | /** |
||
54 | * {@inheritdoc} |
||
55 | */ |
||
56 | public function getTokenParsers() |
||
64 | |||
65 | /** |
||
66 | * {@inheritdoc} |
||
67 | */ |
||
68 | public function initRuntime(\Twig_Environment $environment) |
||
72 | |||
73 | /** |
||
74 | * @param MediaInterface $media |
||
75 | * @param string $format |
||
76 | * @param array $options |
||
77 | * |
||
78 | * @return string |
||
79 | */ |
||
80 | public function media($media, $format, $options = array()) |
||
102 | |||
103 | /** |
||
104 | * Returns the thumbnail for the provided media. |
||
105 | * |
||
106 | * @param MediaInterface $media |
||
107 | * @param string $format |
||
108 | * @param array $options |
||
109 | * |
||
110 | * @return string |
||
111 | */ |
||
112 | public function thumbnail($media, $format, $options = array()) |
||
148 | |||
149 | /** |
||
150 | * @param string $template |
||
151 | * @param array $parameters |
||
152 | * |
||
153 | * @return mixed |
||
154 | */ |
||
155 | public function render($template, array $parameters = array()) |
||
163 | |||
164 | /** |
||
165 | * @param MediaInterface $media |
||
166 | * @param string $format |
||
167 | * |
||
168 | * @return string |
||
169 | */ |
||
170 | public function path($media, $format) |
||
185 | |||
186 | /** |
||
187 | * @return Pool |
||
188 | */ |
||
189 | public function getMediaService() |
||
193 | |||
194 | /** |
||
195 | * @param mixed $media |
||
196 | * |
||
197 | * @return MediaInterface|null|bool |
||
198 | */ |
||
199 | private function getMedia($media) |
||
217 | } |
||
218 |