Completed
Push — master ( 2ede7a...256325 )
by Benjamin
04:30
created

MediaExtension::getAllowedMimeTypes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Alpixel\Bundle\MediaBundle\Twig\Extension;
4
5
use Alpixel\Bundle\MediaBundle\Entity\Media;
6
use Alpixel\Bundle\MediaBundle\Services\MediaManager;
7
8
class MediaExtension extends \Twig_Extension
9
{
10
    protected $mediaManager;
11
12
    public function __construct(MediaManager $mm)
13
    {
14
        $this->mediaManager = $mm;
15
    }
16
17
    public function getName()
18
    {
19
        return 'alpixel_media';
20
    }
21
22
    public function getFunctions()
23
    {
24
        return [
25
            new \Twig_SimpleFunction('alpixel_media_allowed_mimetypes', [$this, 'getAllowedMimeTypes']),
26
        ];
27
    }
28
29
    public function getFilters()
30
    {
31
        return [
32
            new \Twig_SimpleFilter('media_url', [$this, 'generateMediaUrl']),
33
        ];
34
    }
35
36
    public function generateMediaUrl(Media $media, $options = [])
37
    {
38
        return $this->mediaManager->generateUrl($media, $options);
39
    }
40
41
    public function getAllowedMimeTypes()
42
    {
43
        return $this->mediaManager->getAllowedMimeTypes();
44
    }
45
}
46