/
UploaderExtension.php
58 lines (47 loc) · 1.32 KB
/
UploaderExtension.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
namespace Oneup\UploaderBundle\Twig\Extension;
use Oneup\UploaderBundle\Templating\Helper\UploaderHelper;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
class UploaderExtension extends AbstractExtension
{
protected $helper;
public function __construct(UploaderHelper $helper)
{
$this->helper = $helper;
}
public function getName()
{
return 'oneup_uploader';
}
public function getFunctions()
{
return [
new TwigFunction('oneup_uploader_endpoint', [$this, 'endpoint']),
new TwigFunction('oneup_uploader_progress', [$this, 'progress']),
new TwigFunction('oneup_uploader_cancel', [$this, 'cancel']),
new TwigFunction('oneup_uploader_upload_key', [$this, 'uploadKey']),
new TwigFunction('oneup_uploader_maxsize', [$this, 'maxSize']),
];
}
public function endpoint($key)
{
return $this->helper->endpoint($key);
}
public function progress($key)
{
return $this->helper->progress($key);
}
public function cancel($key)
{
return $this->helper->cancel($key);
}
public function uploadKey()
{
return $this->helper->uploadKey();
}
public function maxSize($key)
{
return $this->helper->maxSize($key);
}
}