Completed
Push — master ( 26278b...61e1ff )
by
unknown
04:27
created

FileProvider::getMediaTemplate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace MediaMonks\SonataMediaBundle\Provider;
4
5
use MediaMonks\SonataMediaBundle\Entity\Media;
6
use Sonata\AdminBundle\Form\FormMapper;
7
use Symfony\Component\Validator\Constraints as Constraint;
8
9
class FileProvider extends AbstractProvider
10
{
11
    /**
12
     * @param FormMapper $formMapper
13
     */
14
    public function buildProviderCreateForm(FormMapper $formMapper)
15
    {
16
        $this->addFileUploadField($formMapper, 'binaryContent', 'File');
17
    }
18
19
    /**
20
     * @param Media $media
21
     */
22
    public function update(Media $media)
23
    {
24
        if (!is_null($media->getBinaryContent())) {
25
            $filename = $this->handleFileUpload($media);
26
            $media->setProviderReference($filename);
27
        }
28
        if (!is_null($media->getImageContent())) {
29
            $this->handleImageUpload($media);
0 ignored issues
show
Bug introduced by
The method handleImageUpload() does not seem to exist on object<MediaMonks\Sonata...\Provider\FileProvider>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
30
        }
31
    }
32
33
    /**
34
     * @return string
35
     */
36
    public function getIcon()
37
    {
38
        return 'file';
39
    }
40
41
    /**
42
     * @return string
43
     */
44
    public function getName()
45
    {
46
        return 'File';
47
    }
48
49
    public function getTypeName()
50
    {
51
        return 'file';
52
    }
53
54
    /**
55
     * @return string
56
     */
57
    public function getMediaTemplate()
58
    {
59
        return 'MediaMonksSonataMediaBundle:Provider:file_media.html.twig';
60
    }
61
}
62