@@ -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)) { |
@@ -5,15 +5,10 @@ |
||
5 | 5 | use Alpixel\Bundle\MediaBundle\Entity\Media; |
6 | 6 | use Doctrine\Common\Collections\Collection; |
7 | 7 | use Doctrine\ORM\EntityManager; |
8 | -use Doctrine\ORM\NoResultException; |
|
9 | 8 | use Doctrine\ORM\QueryBuilder; |
10 | 9 | use Symfony\Component\Form\DataTransformerInterface; |
11 | -use Symfony\Component\Form\Exception\FormException; |
|
12 | 10 | use Symfony\Component\Form\Exception\TransformationFailedException; |
13 | 11 | use Symfony\Component\Form\Exception\UnexpectedTypeException; |
14 | -use Symfony\Component\Form\FormError; |
|
15 | -use Symfony\Component\Form\FormInterface; |
|
16 | -use Symfony\Component\PropertyAccess\PropertyAccessor; |
|
17 | 12 | |
18 | 13 | /** |
19 | 14 | * Data transformation class |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | public function transform($data) |
55 | 55 | { |
56 | - if($data instanceof Collection) { |
|
56 | + if ($data instanceof Collection) { |
|
57 | 57 | return $this->reverseTransform($data); |
58 | 58 | } |
59 | 59 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | protected function transformSingleEntity($data) |
81 | 81 | { |
82 | - if($data instanceof Media) |
|
82 | + if ($data instanceof Media) |
|
83 | 83 | return $data->getSecretKey(); |
84 | 84 | else |
85 | 85 | return $this->em->getRepository($this->class)->findOneBySecretKey($data); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | return null; |
92 | 92 | } |
93 | 93 | |
94 | - if(!($data instanceof Collection)) { |
|
94 | + if (!($data instanceof Collection)) { |
|
95 | 95 | return $this->transform($data); |
96 | 96 | } |
97 | 97 |
@@ -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) |
@@ -4,11 +4,7 @@ discard block |
||
4 | 4 | use Alpixel\Bundle\MediaBundle\DataTransformer\EntityToIdTransformer; |
5 | 5 | use Alpixel\Bundle\MediaBundle\Entity\Media; |
6 | 6 | use Alpixel\Bundle\MediaBundle\EventListener\MediaEvent; |
7 | -use Alpixel\Bundle\MediaBundle\EventListener\MediaListener; |
|
8 | 7 | use Symfony\Bridge\Doctrine\RegistryInterface; |
9 | -use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher; |
|
10 | -use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher; |
|
11 | -use Symfony\Component\EventDispatcher\EventDispatcher; |
|
12 | 8 | use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
13 | 9 | use Symfony\Component\Form\AbstractType; |
14 | 10 | use Symfony\Component\Form\FormBuilderInterface; |
@@ -16,7 +12,6 @@ discard block |
||
16 | 12 | use Symfony\Component\Form\FormEvents; |
17 | 13 | use Symfony\Component\Form\FormInterface; |
18 | 14 | use Symfony\Component\Form\FormView; |
19 | -use Symfony\Component\HttpKernel\Kernel; |
|
20 | 15 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; |
21 | 16 | |
22 | 17 | class MediaType extends AbstractType |
@@ -48,13 +48,13 @@ |
||
48 | 48 | { |
49 | 49 | $results = $event->getForm()->getData(); |
50 | 50 | |
51 | - if($results === null) |
|
51 | + if ($results === null) |
|
52 | 52 | return; |
53 | 53 | |
54 | - if(!is_array($results)) |
|
54 | + if (!is_array($results)) |
|
55 | 55 | $results = array($results); |
56 | 56 | |
57 | - foreach($results as $media) { |
|
57 | + foreach ($results as $media) { |
|
58 | 58 | $mediaEvent = new MediaEvent($media); |
59 | 59 | $this->dispatcher->dispatch(MediaEvent::POST_SUBMIT, $mediaEvent); |
60 | 60 | } |
@@ -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); |
@@ -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) { |
@@ -71,7 +71,7 @@ |
||
71 | 71 | |
72 | 72 | public function generatePathFromSecretKey($secretKey) |
73 | 73 | { |
74 | - if($secretKey == '') |
|
74 | + if($secretKey == '') |
|
75 | 75 | return ''; |
76 | 76 | |
77 | 77 | $mimeType = $this->getMimeType($secretKey); |
@@ -31,14 +31,14 @@ discard block |
||
31 | 31 | |
32 | 32 | public function previewIconFilter(\Twig_Environment $twig, $secretKey = '') |
33 | 33 | { |
34 | - if($secretKey == '') |
|
34 | + if ($secretKey == '') |
|
35 | 35 | return ''; |
36 | 36 | |
37 | 37 | $mimeType = $this->getMimeType($secretKey); |
38 | 38 | $icon = ''; |
39 | 39 | $link = ''; |
40 | 40 | |
41 | - if(preg_match('/^image/', $mimeType) === 0) { |
|
41 | + if (preg_match('/^image/', $mimeType) === 0) { |
|
42 | 42 | $icon = $this->getIcon($mimeType); |
43 | 43 | $link = $this->generatePath(true, $icon); |
44 | 44 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | protected function generatePath($isIcon, $str) |
64 | 64 | { |
65 | - if($isIcon === true) { |
|
65 | + if ($isIcon === true) { |
|
66 | 66 | return $this->requestStack->getSchemeAndHttpHost().$this->requestStack->getBasePath().'/bundles/media/images/'.$str; |
67 | 67 | } |
68 | 68 | |
@@ -71,12 +71,12 @@ discard block |
||
71 | 71 | |
72 | 72 | public function generatePathFromSecretKey($secretKey) |
73 | 73 | { |
74 | - if($secretKey == '') |
|
74 | + if ($secretKey == '') |
|
75 | 75 | return ''; |
76 | 76 | |
77 | 77 | $mimeType = $this->getMimeType($secretKey); |
78 | 78 | |
79 | - if(preg_match('/^image/', $mimeType) === 0) { |
|
79 | + if (preg_match('/^image/', $mimeType) === 0) { |
|
80 | 80 | $icon = $this->getIcon($mimeType); |
81 | 81 | return $this->generatePath(true, $icon); |
82 | 82 | } |
@@ -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 |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | $this->allowedMimetypes = $allowedMimetypes; |
35 | 35 | } |
36 | 36 | |
37 | - /** |
|
38 | - * $current_uri String actual uri of the file |
|
39 | - * $dest_folder String future uri of the file starting from web/upload folder |
|
40 | - * $lifetime DateTime lifetime of the file. If time goes over this limit, the file will be deleted. |
|
41 | - **/ |
|
42 | - public function upload(UploadedFile $file, $dest_folder = '', \DateTime $lifetime = null) |
|
43 | - { |
|
37 | + /** |
|
38 | + * $current_uri String actual uri of the file |
|
39 | + * $dest_folder String future uri of the file starting from web/upload folder |
|
40 | + * $lifetime DateTime lifetime of the file. If time goes over this limit, the file will be deleted. |
|
41 | + **/ |
|
42 | + public function upload(UploadedFile $file, $dest_folder = '', \DateTime $lifetime = null) |
|
43 | + { |
|
44 | 44 | |
45 | 45 | //Cleaning up old files before uploading this one |
46 | 46 | $this->cleanup(); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | |
64 | 64 | $fs = new Filesystem(); |
65 | 65 | if (!$fs->exists($this->uploadDir.$dest_folder)) { |
66 | - $fs->mkdir($this->uploadDir.$dest_folder); |
|
66 | + $fs->mkdir($this->uploadDir.$dest_folder); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | $em = $this->doctrine->getManager(); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | $em->flush(); |
118 | 118 | |
119 | 119 | return $media; |
120 | - } |
|
120 | + } |
|
121 | 121 | |
122 | 122 | public function cleanup() |
123 | 123 | { |
@@ -20,11 +20,11 @@ discard block |
||
20 | 20 | protected $allowedMimetypes; |
21 | 21 | |
22 | 22 | const SIZE_OF_KIBIOCTET = 1024; |
23 | - const OCTET_IN_KO = 1; |
|
24 | - const OCTET_IN_MO = 2; |
|
25 | - const OCTET_IN_GO = 3; |
|
26 | - const OCTET_IN_TO = 4; |
|
27 | - const OCTET_IN_PO = 5; |
|
23 | + const OCTET_IN_KO = 1; |
|
24 | + const OCTET_IN_MO = 2; |
|
25 | + const OCTET_IN_GO = 3; |
|
26 | + const OCTET_IN_TO = 4; |
|
27 | + const OCTET_IN_PO = 5; |
|
28 | 28 | |
29 | 29 | public function __construct(Registry $doctrine, Kernel $kernel, $uploadDir, $allowedMimetypes) |
30 | 30 | { |
@@ -50,14 +50,14 @@ discard block |
||
50 | 50 | |
51 | 51 | //checking mimetypes |
52 | 52 | $mimeTypePassed = false; |
53 | - foreach($this->allowedMimetypes as $mimeType) { |
|
54 | - if(preg_match('@'.$mimeType.'@', $file->getMimeType())) |
|
53 | + foreach ($this->allowedMimetypes as $mimeType) { |
|
54 | + if (preg_match('@'.$mimeType.'@', $file->getMimeType())) |
|
55 | 55 | { |
56 | 56 | $mimeTypePassed = true; |
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
60 | - if(!$mimeTypePassed) { |
|
60 | + if (!$mimeTypePassed) { |
|
61 | 61 | throw new InvalidMimeTypeException; |
62 | 62 | } |
63 | 63 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | // Checking for a media with the same name |
83 | 83 | $mediaExists = $this->doctrine->getRepository('MediaBundle:Media')->findOneByUri($dest_folder.$filename); |
84 | - if(count($mediaExists) === 0) { |
|
84 | + if (count($mediaExists) === 0) { |
|
85 | 85 | $mediaExists = $fs->exists($this->uploadDir.$dest_folder.$filename); |
86 | 86 | } |
87 | 87 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | |
186 | 186 | public function setAllowedMimeTypes(array $type) |
187 | 187 | { |
188 | - if($type !== null) { |
|
188 | + if ($type !== null) { |
|
189 | 189 | $this->allowedMimetypes = $type; |
190 | 190 | } |
191 | 191 | |
@@ -199,8 +199,8 @@ discard block |
||
199 | 199 | |
200 | 200 | public function convertOctetIn($size, $convert) |
201 | 201 | { |
202 | - if($convert > 0) { |
|
203 | - $size = ($size / self::SIZE_OF_KIBIOCTET) * 1; |
|
202 | + if ($convert > 0) { |
|
203 | + $size = ($size / self::SIZE_OF_KIBIOCTET) * 1; |
|
204 | 204 | return $this->convertOctetIn($size, $convert - 1); |
205 | 205 | } |
206 | 206 |
@@ -16,9 +16,9 @@ |
||
16 | 16 | |
17 | 17 | public function onPostSubmit(MediaEvent $event) |
18 | 18 | { |
19 | - $media = $event->getMedia(); |
|
19 | + $media = $event->getMedia(); |
|
20 | 20 | |
21 | - if($media !== null) { |
|
21 | + if ($media !== null) { |
|
22 | 22 | $media->setLifetime(null); |
23 | 23 | $this->registry->getManager()->persist($media); |
24 | 24 | } |
@@ -32,15 +32,15 @@ discard block |
||
32 | 32 | $mediaPreview = $this->container->get('twig.extension.media_preview_extension'); |
33 | 33 | foreach ($this->get('request')->files as $files) { |
34 | 34 | if(!is_array($files)) |
35 | - $files = array($files); |
|
35 | + $files = array($files); |
|
36 | 36 | foreach($files as $file) { |
37 | - $media = $this->get('media')->upload($file, $this->get('request')->get('folder'), $lifetime); |
|
38 | - $path = $mediaPreview->generatePathFromSecretKey($media->getSecretKey()); |
|
39 | - $returnData[] = array( |
|
40 | - 'id' => $media->getSecretKey(), |
|
41 | - 'path' => $path, |
|
42 | - 'name' => $media->getName(), |
|
43 | - ); |
|
37 | + $media = $this->get('media')->upload($file, $this->get('request')->get('folder'), $lifetime); |
|
38 | + $path = $mediaPreview->generatePathFromSecretKey($media->getSecretKey()); |
|
39 | + $returnData[] = array( |
|
40 | + 'id' => $media->getSecretKey(), |
|
41 | + 'path' => $path, |
|
42 | + 'name' => $media->getName(), |
|
43 | + ); |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
@@ -81,29 +81,29 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function showMediaAction(Media $media, $filter = null) |
83 | 83 | { |
84 | - $response = new Response(); |
|
84 | + $response = new Response(); |
|
85 | 85 | |
86 | - $lastModified = new \DateTime('now'); |
|
86 | + $lastModified = new \DateTime('now'); |
|
87 | 87 | |
88 | 88 | |
89 | - //Checking if it is an image or not |
|
90 | - $src = $this->get('media')->getAbsolutePath($media); |
|
91 | - $isImage = @getimagesize($src); |
|
89 | + //Checking if it is an image or not |
|
90 | + $src = $this->get('media')->getAbsolutePath($media); |
|
91 | + $isImage = @getimagesize($src); |
|
92 | 92 | |
93 | - if($isImage) { |
|
93 | + if($isImage) { |
|
94 | 94 | $response->headers->set('Content-disposition', 'inline;filename='.$media->getName()); |
95 | 95 | if (!empty($filter) && $isImage) { |
96 | 96 | |
97 | - $src = $this->get('media')->getAbsolutePath($media, $filter); |
|
98 | - $dataManager = $this->get('liip_imagine.data.manager'); // the data manager service |
|
99 | - $filterManager = $this->get('liip_imagine.filter.manager');// the filter manager service |
|
97 | + $src = $this->get('media')->getAbsolutePath($media, $filter); |
|
98 | + $dataManager = $this->get('liip_imagine.data.manager'); // the data manager service |
|
99 | + $filterManager = $this->get('liip_imagine.filter.manager');// the filter manager service |
|
100 | 100 | |
101 | - $uploadDir = $this->get('media')->getUploadDir($filter); |
|
101 | + $uploadDir = $this->get('media')->getUploadDir($filter); |
|
102 | 102 | |
103 | - if (!is_file($src)) { |
|
103 | + if (!is_file($src)) { |
|
104 | 104 | $fs = new Filesystem(); |
105 | 105 | if (!$fs->exists($uploadDir.$media->getFolder())) { |
106 | - $fs->mkdir($uploadDir.$media->getFolder()); |
|
106 | + $fs->mkdir($uploadDir.$media->getFolder()); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | $path = 'upload/'.$media->getUri(); |
@@ -111,33 +111,33 @@ discard block |
||
111 | 111 | $responseData = $filterManager->applyFilter($image, $filter); // run the filter |
112 | 112 | $data = $responseData->getContent(); // get the image from the response |
113 | 113 | file_put_contents($uploadDir.$media->getUri(), $data); |
114 | - } else { |
|
114 | + } else { |
|
115 | 115 | $data = file_get_contents($src); |
116 | 116 | $lastModified->setTimestamp(filemtime($src)); |
117 | - } |
|
117 | + } |
|
118 | 118 | |
119 | 119 | } else { |
120 | - $src = $this->get('media')->getAbsolutePath($media); |
|
121 | - $lastModified->setTimestamp(filemtime($src)); |
|
122 | - $data = file_get_contents($src); |
|
120 | + $src = $this->get('media')->getAbsolutePath($media); |
|
121 | + $lastModified->setTimestamp(filemtime($src)); |
|
122 | + $data = file_get_contents($src); |
|
123 | 123 | } |
124 | - } else { |
|
124 | + } else { |
|
125 | 125 | $lastModified->setTimestamp(filemtime($src)); |
126 | 126 | $data = file_get_contents($src); |
127 | 127 | $response->headers->set('Content-disposition', 'attachment;filename='.basename($media->getUri())); |
128 | - } |
|
128 | + } |
|
129 | 129 | |
130 | - $response->setLastModified($lastModified); |
|
131 | - $response->setPublic(); |
|
132 | - $response->headers->set('Content-Type', $media->getMime()); |
|
130 | + $response->setLastModified($lastModified); |
|
131 | + $response->setPublic(); |
|
132 | + $response->headers->set('Content-Type', $media->getMime()); |
|
133 | 133 | |
134 | - if ($response->isNotModified($this->get('request'))) { |
|
135 | - return $response; |
|
136 | - } |
|
134 | + if ($response->isNotModified($this->get('request'))) { |
|
135 | + return $response; |
|
136 | + } |
|
137 | 137 | |
138 | - $response->setContent($data); |
|
138 | + $response->setContent($data); |
|
139 | 139 | |
140 | - return $response; |
|
140 | + return $response; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | */ |
20 | 20 | public function uploadAction() |
21 | 21 | { |
22 | - $returnData = array(); |
|
22 | + $returnData = array(); |
|
23 | 23 | |
24 | 24 | if ($this->get('request')->get('lifetime') !== null) { |
25 | 25 | $lifetime = new \DateTime($this->get('request')->get('lifetime')); |
@@ -31,9 +31,9 @@ discard block |
||
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)) |
|
34 | + if (!is_array($files)) |
|
35 | 35 | $files = array($files); |
36 | - foreach($files as $file) { |
|
36 | + foreach ($files as $file) { |
|
37 | 37 | $media = $this->get('media')->upload($file, $this->get('request')->get('folder'), $lifetime); |
38 | 38 | $path = $mediaPreview->generatePathFromSecretKey($media->getSecretKey()); |
39 | 39 | $returnData[] = array( |
@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | $src = $this->get('media')->getAbsolutePath($media); |
91 | 91 | $isImage = @getimagesize($src); |
92 | 92 | |
93 | - if($isImage) { |
|
93 | + if ($isImage) { |
|
94 | 94 | $response->headers->set('Content-disposition', 'inline;filename='.$media->getName()); |
95 | 95 | if (!empty($filter) && $isImage) { |
96 | 96 | |
97 | 97 | $src = $this->get('media')->getAbsolutePath($media, $filter); |
98 | - $dataManager = $this->get('liip_imagine.data.manager'); // the data manager service |
|
99 | - $filterManager = $this->get('liip_imagine.filter.manager');// the filter manager service |
|
98 | + $dataManager = $this->get('liip_imagine.data.manager'); // the data manager service |
|
99 | + $filterManager = $this->get('liip_imagine.filter.manager'); // the filter manager service |
|
100 | 100 | |
101 | 101 | $uploadDir = $this->get('media')->getUploadDir($filter); |
102 | 102 | |
@@ -107,9 +107,9 @@ discard block |
||
107 | 107 | } |
108 | 108 | |
109 | 109 | $path = 'upload/'.$media->getUri(); |
110 | - $image = $dataManager->find($filter, $path); // find the image and determine its type |
|
111 | - $responseData = $filterManager->applyFilter($image, $filter); // run the filter |
|
112 | - $data = $responseData->getContent(); // get the image from the response |
|
110 | + $image = $dataManager->find($filter, $path); // find the image and determine its type |
|
111 | + $responseData = $filterManager->applyFilter($image, $filter); // run the filter |
|
112 | + $data = $responseData->getContent(); // get the image from the response |
|
113 | 113 | file_put_contents($uploadDir.$media->getUri(), $data); |
114 | 114 | } else { |
115 | 115 | $data = file_get_contents($src); |
@@ -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()); |