1 | <?php |
||
11 | class PdfHandler extends FileHandler |
||
12 | { |
||
13 | const TYPE = 'pdf'; |
||
14 | |||
15 | /** @var string */ |
||
16 | protected $webPath; |
||
17 | |||
18 | /** @var PreviewTransformerInterface */ |
||
19 | protected $pdfTransformer; |
||
20 | |||
21 | /** |
||
22 | * Inject the root dir so we know the full path where we need to store the file. |
||
23 | * |
||
24 | * @param string $kernelRootDir |
||
25 | */ |
||
26 | public function setMediaPath($kernelRootDir) |
||
32 | |||
33 | /** |
||
34 | * @param string $webPath |
||
35 | */ |
||
36 | public function setWebPath($webPath) |
||
37 | { |
||
38 | $this->webPath = $webPath; |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * @param PreviewTransformerInterface $pdfTransformer |
||
43 | */ |
||
44 | public function setPdfTransformer(PreviewTransformerInterface $pdfTransformer) |
||
45 | { |
||
46 | $this->pdfTransformer = $pdfTransformer; |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * @return string |
||
51 | */ |
||
52 | public function getType() |
||
53 | { |
||
54 | return PdfHandler::TYPE; |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * @param mixed $object |
||
59 | * |
||
60 | * @return bool |
||
61 | */ |
||
62 | public function canHandle($object) |
||
63 | { |
||
64 | if (parent::canHandle($object) && |
||
65 | ($object instanceof Media && $object->getContentType() == 'application/pdf') |
||
66 | ) { |
||
67 | return true; |
||
68 | } |
||
69 | |||
70 | return false; |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * @param Media $media |
||
75 | */ |
||
76 | public function saveMedia(Media $media) |
||
87 | |||
88 | /** |
||
89 | * @param Media $media The media entity |
||
90 | * @param string $basepath The base path |
||
91 | * |
||
92 | * @return string |
||
|
|||
93 | */ |
||
94 | public function getImageUrl(Media $media, $basepath) |
||
103 | } |
||
104 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.