@@ -31,8 +31,9 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | public function previewIconFilter(\Twig_Environment $twig, $secretKey = '') |
| 33 | 33 | { |
| 34 | - if($secretKey == '') |
|
| 35 | - return ''; |
|
| 34 | + if($secretKey == '') { |
|
| 35 | + return ''; |
|
| 36 | + } |
|
| 36 | 37 | |
| 37 | 38 | $mimeType = $this->getMimeType($secretKey); |
| 38 | 39 | $icon = ''; |
@@ -41,8 +42,7 @@ discard block |
||
| 41 | 42 | if(preg_match('/^image/', $mimeType) === 0) { |
| 42 | 43 | $icon = $this->getIcon($mimeType); |
| 43 | 44 | $link = $this->generatePath(true, $icon); |
| 44 | - } |
|
| 45 | - else { |
|
| 45 | + } else { |
|
| 46 | 46 | $link = $this->generatePath(false, $secretKey); |
| 47 | 47 | } |
| 48 | 48 | |
@@ -71,8 +71,9 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | public function generatePathFromSecretKey($secretKey) |
| 73 | 73 | { |
| 74 | - if($secretKey == '') |
|
| 75 | - return ''; |
|
| 74 | + if($secretKey == '') { |
|
| 75 | + return ''; |
|
| 76 | + } |
|
| 76 | 77 | |
| 77 | 78 | $mimeType = $this->getMimeType($secretKey); |
| 78 | 79 | |
@@ -79,10 +79,11 @@ |
||
| 79 | 79 | |
| 80 | 80 | protected function transformSingleEntity($data) |
| 81 | 81 | { |
| 82 | - if($data instanceof Media) |
|
| 83 | - return $data->getSecretKey(); |
|
| 84 | - else |
|
| 85 | - return $this->em->getRepository($this->class)->findOneBySecretKey($data); |
|
| 82 | + if($data instanceof Media) { |
|
| 83 | + return $data->getSecretKey(); |
|
| 84 | + } else { |
|
| 85 | + return $this->em->getRepository($this->class)->findOneBySecretKey($data); |
|
| 86 | + } |
|
| 86 | 87 | } |
| 87 | 88 | |
| 88 | 89 | public function reverseTransform($data) |
@@ -48,11 +48,13 @@ |
||
| 48 | 48 | { |
| 49 | 49 | $results = $event->getForm()->getData(); |
| 50 | 50 | |
| 51 | - if($results === null) |
|
| 52 | - return; |
|
| 51 | + if($results === null) { |
|
| 52 | + return; |
|
| 53 | + } |
|
| 53 | 54 | |
| 54 | - if(!is_array($results)) |
|
| 55 | - $results = array($results); |
|
| 55 | + if(!is_array($results)) { |
|
| 56 | + $results = array($results); |
|
| 57 | + } |
|
| 56 | 58 | |
| 57 | 59 | foreach($results as $media) { |
| 58 | 60 | $mediaEvent = new MediaEvent($media); |
@@ -31,8 +31,9 @@ |
||
| 31 | 31 | |
| 32 | 32 | $mediaPreview = $this->container->get('twig.extension.media_preview_extension'); |
| 33 | 33 | foreach ($this->get('request')->files as $files) { |
| 34 | - if(!is_array($files)) |
|
| 35 | - $files = array($files); |
|
| 34 | + if(!is_array($files)) { |
|
| 35 | + $files = array($files); |
|
| 36 | + } |
|
| 36 | 37 | foreach($files as $file) { |
| 37 | 38 | $media = $this->get('media')->upload($file, $this->get('request')->get('folder'), $lifetime); |
| 38 | 39 | $path = $mediaPreview->generatePathFromSecretKey($media->getSecretKey()); |