@@ -30,6 +30,10 @@ |
||
| 30 | 30 | |
| 31 | 31 | private $unitOfWork; |
| 32 | 32 | |
| 33 | + /** |
|
| 34 | + * @param string $class |
|
| 35 | + * @param string $property |
|
| 36 | + */ |
|
| 33 | 37 | public function __construct(EntityManager $em, $class, $property, $queryBuilder, $multiple) |
| 34 | 38 | { |
| 35 | 39 | if (!(null === $queryBuilder || $queryBuilder instanceof QueryBuilder || $queryBuilder instanceof \Closure)) { |
@@ -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) |
@@ -126,8 +126,8 @@ discard block |
||
| 126 | 126 | /** |
| 127 | 127 | * Sets the value of uri. |
| 128 | 128 | * |
| 129 | - * @param string $name $uri the uri |
|
| 130 | 129 | * |
| 130 | + * @param string $uri |
|
| 131 | 131 | * @return self |
| 132 | 132 | */ |
| 133 | 133 | public function setUri($uri) |
@@ -150,8 +150,8 @@ discard block |
||
| 150 | 150 | /** |
| 151 | 151 | * Sets the value of secretKey. |
| 152 | 152 | * |
| 153 | - * @param string $name $secretKey the secret key |
|
| 154 | 153 | * |
| 154 | + * @param string $secretKey |
|
| 155 | 155 | * @return self |
| 156 | 156 | */ |
| 157 | 157 | public function setSecretKey($secretKey) |
@@ -174,8 +174,8 @@ discard block |
||
| 174 | 174 | /** |
| 175 | 175 | * Sets the value of mime. |
| 176 | 176 | * |
| 177 | - * @param string $name $mime the mime |
|
| 178 | 177 | * |
| 178 | + * @param string $mime |
|
| 179 | 179 | * @return self |
| 180 | 180 | */ |
| 181 | 181 | public function setMime($mime) |
@@ -198,8 +198,8 @@ discard block |
||
| 198 | 198 | /** |
| 199 | 199 | * Sets the value of lifetime. |
| 200 | 200 | * |
| 201 | - * @param string $label $lifetime the lifetime |
|
| 202 | 201 | * |
| 202 | + * @param null|\DateTime $lifetime |
|
| 203 | 203 | * @return self |
| 204 | 204 | */ |
| 205 | 205 | public function setLifetime($lifetime) |
@@ -60,6 +60,9 @@ |
||
| 60 | 60 | return (array_key_exists($mime, $this->previewIcon)) ? $this->previewIcon[$mime] : $this->previewIcon['unknown']; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | + /** |
|
| 64 | + * @param boolean $isIcon |
|
| 65 | + */ |
|
| 63 | 66 | protected function generatePath($isIcon, $str) |
| 64 | 67 | { |
| 65 | 68 | if($isIcon === true) { |
@@ -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 | |
@@ -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()); |