1 | <?php |
||
24 | class DownloadExtension extends \Twig_Extension |
||
25 | { |
||
26 | /** |
||
27 | * The URL generator. |
||
28 | * |
||
29 | * @var UrlGeneratorInterface |
||
30 | */ |
||
31 | private $urlGenerator; |
||
32 | |||
33 | /** |
||
34 | * The file handlers. |
||
35 | * |
||
36 | * @var array |
||
37 | */ |
||
38 | private $handlers; |
||
39 | |||
40 | /** |
||
41 | * Constructor. |
||
42 | * |
||
43 | * @param UrlGeneratorInterface $anUrlGenerator The URL generator |
||
44 | * @param array $handlers The file handlers |
||
45 | */ |
||
46 | public function __construct(UrlGeneratorInterface $anUrlGenerator, array $handlers) |
||
47 | { |
||
48 | $this->urlGenerator = $anUrlGenerator; |
||
49 | $this->handlers = $handlers; |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * {@inheritdoc} |
||
54 | */ |
||
55 | public function getFunctions() |
||
61 | |||
62 | /** |
||
63 | * Generates the url that returns the file of given file type and file. |
||
64 | * |
||
65 | * @param string $fileClass The file type type |
||
66 | * @param string $q The file query |
||
67 | * |
||
68 | * @return string |
||
69 | */ |
||
70 | public function download($fileClass, $q) |
||
85 | |||
86 | /** |
||
87 | * {@inheritdoc} |
||
88 | */ |
||
89 | public function getName() |
||
93 | } |
||
94 |