Completed
Push — master ( 2311d5...4dfad4 )
by Rafidison
08:45
created
Form/Type/MediaShowType.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,10 +21,10 @@
 block discarded – undo
21 21
     public function buildForm(FormBuilderInterface $builder, array $options)
22 22
     {
23 23
         $builder
24
-            ->add('name','text',[
24
+            ->add('name', 'text', [
25 25
                 "label"=>"Nom de l'image"
26 26
             ])
27
-            ->add('file','text',[
27
+            ->add('file', 'text', [
28 28
                 "label"=>"Chemin de l'image"
29 29
             ])
30 30
         ;
Please login to merge, or discard this patch.
Form/Type/MediaType.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
     public function buildForm(FormBuilderInterface $builder, array $options)
16 16
     {
17 17
         $builder
18
-            ->add('fileData','file')
18
+            ->add('fileData', 'file')
19 19
         ;
20 20
     }
21 21
     
Please login to merge, or discard this patch.
Controller/MediasController.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -26,24 +26,24 @@  discard block
 block discarded – undo
26 26
      * @param $editor
27 27
      * @return \Symfony\Component\HttpFoundation\Response
28 28
      */
29
-    public function indexAction( $model, $bundle, $model_id, $editor )
29
+    public function indexAction($model, $bundle, $model_id, $editor)
30 30
     {
31 31
         $params = [
32 32
             'medias'=>$this->get('mk.media.manager')->findMediasByModelAndId($model, $model_id),
33 33
             'entity'=>$this->getManage()->getRepository("$bundle:$model")->find($model_id),
34
-            'mode'=>$editor=='true' ? $editor : null,
35
-            'url'=>$editor == "true" ? ['model'=>$model,'bundle'=>$bundle,'model_id'=>$model_id,'mode'=>'true'] : ['model'=>$model,'bundle'=>$bundle,'model_id'=>$model_id]
34
+            'mode'=>$editor == 'true' ? $editor : null,
35
+            'url'=>$editor == "true" ? ['model'=>$model, 'bundle'=>$bundle, 'model_id'=>$model_id, 'mode'=>'true'] : ['model'=>$model, 'bundle'=>$bundle, 'model_id'=>$model_id]
36 36
         ];
37 37
         $form = $this->createForm(
38 38
             new MediaType(),
39 39
             new Media,
40 40
             [
41
-                'action' => $this->generateUrl('mykees_media_add',$params['url']),
41
+                'action' => $this->generateUrl('mykees_media_add', $params['url']),
42 42
                 'method' => 'POST',
43 43
             ]
44 44
         );
45 45
 
46
-        return $this->render('MykeesMediaBundle:Media:index.html.twig',[
46
+        return $this->render('MykeesMediaBundle:Media:index.html.twig', [
47 47
             'form'=>$form->createView(),
48 48
             'model'=>$model,
49 49
             'bundle'=> $bundle,
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      * @throws \Exception
59 59
      * @return \Symfony\Component\HttpFoundation\Response
60 60
      */
61
-    public function addAction( Request $request )
61
+    public function addAction(Request $request)
62 62
     {
63 63
         $requestArray = [
64 64
             'file'=>$request->files,
@@ -68,24 +68,24 @@  discard block
 block discarded – undo
68 68
         $bundle = $request->get('bundle');
69 69
         $model_id = $request->get('model_id');
70 70
 
71
-        if( $request->isXmlHttpRequest() && $requestArray['file'] )
71
+        if ($request->isXmlHttpRequest() && $requestArray['file'])
72 72
         {
73 73
             //Init Event
74
-            $event = $this->initEvent($requestArray['file'],$model,$model_id);
74
+            $event = $this->initEvent($requestArray['file'], $model, $model_id);
75 75
 
76
-            if($event->getMedia())
76
+            if ($event->getMedia())
77 77
             {
78 78
                 $requestArray['entity'] = $this->getManage()->getRepository("$bundle:$model")->find($model_id);
79 79
 
80 80
 
81
-                return $this->render('MykeesMediaBundle:Media:upload/upload_list.html.twig',[
81
+                return $this->render('MykeesMediaBundle:Media:upload/upload_list.html.twig', [
82 82
                     'params'=>$requestArray,
83 83
                     'media'=>$event->getMedia(),
84 84
                     'model'=>$model,
85 85
                     'bundle'=>$bundle,
86 86
                     'model_id'=>$model_id
87 87
                 ]);
88
-            }else{
88
+            }else {
89 89
                 $response = new Response();
90 90
                 $response->setContent(json_encode(array(
91 91
                     'error'=>"Le format n'est pas valid"
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
         }
98 98
     }
99 99
 
100
-    private function initEvent($file,$model,$model_id)
100
+    private function initEvent($file, $model, $model_id)
101 101
     {
102 102
         $event = new UploadEvent();
103 103
         $event->setFile($file);
@@ -120,10 +120,10 @@  discard block
 block discarded – undo
120 120
      * @param Request $request
121 121
      * @return \Symfony\Component\HttpFoundation\RedirectResponse
122 122
      */
123
-    public function thumbAction( $model, $bundle, $model_id, $id, Request $request )
123
+    public function thumbAction($model, $bundle, $model_id, $id, Request $request)
124 124
     {
125
-        $media  = $this->getManage()->getRepository("MykeesMediaBundle:Media")->find($id);
126
-        $entity  = $this->getManage()->getRepository("$bundle:$model")->find($model_id);
125
+        $media = $this->getManage()->getRepository("MykeesMediaBundle:Media")->find($id);
126
+        $entity = $this->getManage()->getRepository("$bundle:$model")->find($model_id);
127 127
         $entity->setThumb($media);
128 128
         $this->getManage()->persist($entity);
129 129
         $this->getManage()->flush();
@@ -138,16 +138,16 @@  discard block
 block discarded – undo
138 138
      * @param Request $request
139 139
      * @return Response
140 140
      */
141
-    public function showAction( $model=null, $id = null, Request $request )
141
+    public function showAction($model = null, $id = null, Request $request)
142 142
     {
143
-        if( !$id )
143
+        if (!$id)
144 144
         {
145 145
             $params = [
146 146
                 'class'=>$request->get('class'),
147 147
                 'alt'=>$request->get('alt')
148 148
             ];
149
-            $params['media'] = $this->getManage()->getRepository('MykeesMediaBundle:Media')->findOneBy(['name'=>$params['alt'],'model'=>$model]);
150
-        }else{
149
+            $params['media'] = $this->getManage()->getRepository('MykeesMediaBundle:Media')->findOneBy(['name'=>$params['alt'], 'model'=>$model]);
150
+        }else {
151 151
             $params = [
152 152
                 'media'=>$this->getManage()->getRepository('MykeesMediaBundle:Media')->find($id),
153 153
                 'class'=>null
@@ -157,18 +157,18 @@  discard block
 block discarded – undo
157 157
             new MediaShowType(),
158 158
             $params['media'],
159 159
             [
160
-                'action' => $this->generateUrl('mykees_media_show',['model'=>$model,'id'=>$id]),
160
+                'action' => $this->generateUrl('mykees_media_show', ['model'=>$model, 'id'=>$id]),
161 161
                 'method' => 'POST',
162 162
             ]
163 163
         );
164
-        if($request->getMethod() == "POST")
164
+        if ($request->getMethod() == "POST")
165 165
         {
166 166
             $media = $request->request->all();
167
-            return $this->render('MykeesMediaBundle:Media:tinymce.html.twig',['media'=>$media]);
167
+            return $this->render('MykeesMediaBundle:Media:tinymce.html.twig', ['media'=>$media]);
168 168
         }
169 169
 
170
-        return $this->render('MykeesMediaBundle:Media:show/show.html.twig',[
171
-            'media'=>$params['media'],'form'=>$form->createView(),'class'=>$params['class'],"model"=>$model
170
+        return $this->render('MykeesMediaBundle:Media:show/show.html.twig', [
171
+            'media'=>$params['media'], 'form'=>$form->createView(), 'class'=>$params['class'], "model"=>$model
172 172
         ]);
173 173
     }
174 174
 
@@ -180,16 +180,16 @@  discard block
 block discarded – undo
180 180
      * @param $id
181 181
      * @return Response
182 182
      */
183
-    public function deleteAction( $model, $bundle, $id )
183
+    public function deleteAction($model, $bundle, $id)
184 184
     {
185
-        if( $id )
185
+        if ($id)
186 186
         {
187 187
             $media = $this->getManage()->getRepository('MykeesMediaBundle:Media')->find($id);
188 188
             $media_manager = $this->get('mk.media.manager');
189
-            $media_manager->unlink($model,$media);
189
+            $media_manager->unlink($model, $media);
190 190
 
191 191
             $model_referer = $this->getManage()->getRepository("$bundle:$model")->find($media->getMediableId());
192
-            if(method_exists($model_referer,'getThumb') && $model_referer->getThumb() !== null && $model_referer->getThumb()->getId() == $media->getId())
192
+            if (method_exists($model_referer, 'getThumb') && $model_referer->getThumb() !== null && $model_referer->getThumb()->getId() == $media->getId())
193 193
             {
194 194
                 $model_referer->setThumb(null);
195 195
             }
Please login to merge, or discard this patch.
Repository/MediaRepository.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
     {
24 24
         $query = $this->_em->createQueryBuilder()
25 25
             ->select('m')
26
-            ->from($this->_entityName,'m')
26
+            ->from($this->_entityName, 'm')
27 27
             ->where('m.model = :model')
28 28
             ->andWhere('m.modelId = :modelId')
29
-            ->setParameter('model',$model)
30
-            ->setParameter('modelId',$model_id)
29
+            ->setParameter('model', $model)
30
+            ->setParameter('modelId', $model_id)
31 31
             ->getQuery()
32 32
         ;
33 33
         return $query;
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
     {
43 43
         $query = $this->_em->createQueryBuilder()
44 44
             ->select('m')
45
-            ->from($this->_entityName,'m')
45
+            ->from($this->_entityName, 'm')
46 46
             ->where('m.model = :model')
47
-            ->setParameter('model',$model)
47
+            ->setParameter('model', $model)
48 48
             ->getQuery()
49 49
         ;
50 50
         return $query;
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
     {
60 60
         $query = $this->_em->createQueryBuilder()
61 61
             ->select('m')
62
-            ->from($this->_entityName,'m')
62
+            ->from($this->_entityName, 'm')
63 63
             ->where('m.model IN(:model)')
64 64
             ->andWhere('m.modelId IN(:modelId)')
65
-            ->setParameter('model',array_values($model_info['models']))
66
-            ->setParameter('modelId',array_values($model_info['ids']))
65
+            ->setParameter('model', array_values($model_info['models']))
66
+            ->setParameter('modelId', array_values($model_info['ids']))
67 67
             ->getQuery()
68 68
         ;
69 69
         return $query;
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      * @param array $model_info
75 75
      * @return array
76 76
      */
77
-    public function findForArrayModels(array $model_info){
77
+    public function findForArrayModels(array $model_info) {
78 78
         return $this->queryForArray($model_info)
79 79
                     ->getResult();
80 80
     }
Please login to merge, or discard this patch.
Twig/Extension/UploaderExtension.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 
17 17
     public $generator;
18 18
 
19
-    public function __construct(UrlGeneratorInterface $generator )
19
+    public function __construct(UrlGeneratorInterface $generator)
20 20
     {
21 21
         $this->generator = $generator;
22 22
     }
@@ -40,21 +40,21 @@  discard block
 block discarded – undo
40 40
      * @param $entity
41 41
      * @return string
42 42
      */
43
-    public function iframeUploader(Mediable $entity )
43
+    public function iframeUploader(Mediable $entity)
44 44
     {
45 45
         $model    = Reflection::getClassShortName($entity);
46 46
         $model_id = $entity->getId();
47 47
         $bundle   = Reflection::getShortBundleRepository($entity);
48
-        if($model_id)
48
+        if ($model_id)
49 49
         {
50
-            $url = $this->generator->generate('mykees_media',[
50
+            $url = $this->generator->generate('mykees_media', [
51 51
                 'model' => $model,
52 52
                 'bundle'=> $bundle,
53 53
                 'model_id'=> $model_id
54 54
             ]);
55 55
 
56 56
             return '<iframe src="'.$url.'" style="width:100%;border: none;min-height:100%;" class="iframe-uploader"></iframe>';
57
-        }else{
57
+        }else {
58 58
 
59 59
             return '<h3 style="font-weight: bold;text-align: center;color:#777">The <span style="color:#DD6F6F;border-bottom:2px dashed #777;">ID</span> from your entity <span style="color:#DD6F6F;border-bottom:2px dashed #777;">'.$model.'</span> is required to use the uploader</h3>';
60 60
         }
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
      * @param $entity
66 66
      * @return
67 67
      */
68
-    public function wysiwygUploader( \Twig_Environment $env, Mediable $entity )
68
+    public function wysiwygUploader(\Twig_Environment $env, Mediable $entity)
69 69
     {
70 70
         $model    = Reflection::getClassShortName($entity);
71 71
         $model_id = $entity->getId();
72 72
         $bundle   = Reflection::getShortBundleRepository($entity);
73 73
 
74
-        return  $env->render('MykeesMediaBundle:Media:editor/tinymce.html.twig',[
74
+        return  $env->render('MykeesMediaBundle:Media:editor/tinymce.html.twig', [
75 75
             'model'=>$model,
76 76
             'model_id'=>$model_id,
77 77
             'bundle'=> $bundle,
Please login to merge, or discard this patch.
Twig/Extension/ImageResizeExtension.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,12 +27,12 @@  discard block
 block discarded – undo
27 27
         ];
28 28
     }
29 29
 
30
-    public function getImage($image, $width, $height, $options=[])
30
+    public function getImage($image, $width, $height, $options = [])
31 31
     {
32 32
         $attr = false;
33
-        foreach($options as $k=>$opt)
33
+        foreach ($options as $k=>$opt)
34 34
         {
35
-            if( $k > 1 ){
35
+            if ($k > 1) {
36 36
                 $attr .= ' ';
37 37
             }
38 38
             $attr .= $k.'="'.$opt.'"';
@@ -40,13 +40,13 @@  discard block
 block discarded – undo
40 40
 
41 41
         $webroot = $this->rootDir.'/../web/';
42 42
         $info = pathinfo($image);
43
-        $imageResize = $info['dirname'] . '/' . $info['filename'] . "_$width" . "x$height" . '.jpg';
44
-        $fullPathImageResize = $webroot . $imageResize;
43
+        $imageResize = $info['dirname'].'/'.$info['filename']."_$width"."x$height".'.jpg';
44
+        $fullPathImageResize = $webroot.$imageResize;
45 45
 
46
-        if(file_exists($fullPathImageResize))
46
+        if (file_exists($fullPathImageResize))
47 47
         {
48
-            return '<img src="'. $imageResize .'" '. $attr .'>';
49
-        } else {
48
+            return '<img src="'.$imageResize.'" '.$attr.'>';
49
+        }else {
50 50
             return false;
51 51
         }
52 52
 
Please login to merge, or discard this patch.
Tests/Controller/MediasControllerTest.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -32,28 +32,28 @@  discard block
 block discarded – undo
32 32
     public function testListMedias()
33 33
     {
34 34
         $crawler = $this->client->request('GET', '/admin/medias/Post/MvcBlogBundle/1');
35
-        $this->assertEquals(200,$this->client->getResponse()->getStatusCode());
36
-        $this->assertEquals(2,$crawler->filter('.count-tr')->count());
35
+        $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
36
+        $this->assertEquals(2, $crawler->filter('.count-tr')->count());
37 37
 
38 38
 
39 39
         $crawler = $this->client->request('GET', '/admin/medias/Post/MvcBlogBundle/2');
40
-        $this->assertEquals(200,$this->client->getResponse()->getStatusCode());
41
-        $this->assertEquals(1,$crawler->filter('.count-tr')->count());
40
+        $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
41
+        $this->assertEquals(1, $crawler->filter('.count-tr')->count());
42 42
     }
43 43
 
44 44
     public function testFindAllMediasForAModel()
45 45
     {
46
-        $medias  = $this->manager->findMediasByModelAndId('Post',1);
47
-        $this->assertGreaterThan(1,count($medias));
46
+        $medias = $this->manager->findMediasByModelAndId('Post', 1);
47
+        $this->assertGreaterThan(1, count($medias));
48 48
         $this->assertEquals(2, count($medias));
49 49
     }
50 50
 
51 51
     public function testRemoveFile()
52 52
     {
53 53
         $this->client->request('GET', '/admin/medias/delete/Post/MvcBlogBundle/9');
54
-        $this->assertEquals(200,$this->client->getResponse()->getStatusCode());
54
+        $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
55 55
 
56
-        $medias  = $this->manager->findMediasByModelAndId('Post',2);
56
+        $medias = $this->manager->findMediasByModelAndId('Post', 2);
57 57
         $this->assertEquals(0, count($medias));
58 58
     }
59 59
 
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
             ['HTTP_X-Requested-With' => 'XMLHttpRequest']
76 76
         );
77 77
 
78
-        $this->assertEquals(200,$this->client->getResponse()->getStatusCode());
79
-        $medias  = $this->manager->findMediasByModelAndId('Post',13);
78
+        $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
79
+        $medias = $this->manager->findMediasByModelAndId('Post', 13);
80 80
 
81 81
         $this->assertEquals(1, count($medias));
82 82
 
@@ -99,10 +99,10 @@  discard block
 block discarded – undo
99 99
             ['HTTP_X-Requested-With' => 'XMLHttpRequest']
100 100
         );
101 101
 
102
-        $this->assertEquals(500,$this->client->getResponse()->getStatusCode());
102
+        $this->assertEquals(500, $this->client->getResponse()->getStatusCode());
103 103
 
104 104
         $this->manager = $this->container->get('mk.media.manager');
105
-        $medias  = $this->manager->findMediasByModelAndId('Post',17);
105
+        $medias = $this->manager->findMediasByModelAndId('Post', 17);
106 106
         $this->assertEquals(0, count($medias));
107 107
     }
108 108
 
Please login to merge, or discard this patch.
Interfaces/Mediable.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
 namespace Mykees\MediaBundle\Interfaces;
10 10
 
11 11
 
12
-Interface Mediable{
12
+Interface Mediable {
13 13
 
14 14
     public function getId();
15 15
 }
Please login to merge, or discard this patch.
EventListener/UploadSubscriber.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -36,57 +36,57 @@  discard block
 block discarded – undo
36 36
     }
37 37
 
38 38
 
39
-    public function uploadProcess( UploadEvent $event )
39
+    public function uploadProcess(UploadEvent $event)
40 40
     {
41
-        $file  = $event->getFile()->all();
41
+        $file = $event->getFile()->all();
42 42
         $fileUploaded = $file['file'];
43
-        $model   = $event->getMediableModel();
43
+        $model = $event->getMediableModel();
44 44
         $model_id = $event->getMediableId();
45 45
         $resize_option = $event->getContainer()->getParameter('mykees.media.resize');
46 46
         $extension = pathinfo($fileUploaded->getClientOriginalName(), PATHINFO_EXTENSION);
47 47
         $DS = DIRECTORY_SEPARATOR;
48 48
 
49 49
 
50
-        if( $this->isValidExtension($extension,$event) )
50
+        if ($this->isValidExtension($extension, $event))
51 51
         {
52 52
             //create dir
53 53
             $webroot = $event->getRootDir().'/../web';
54 54
             $dir = $webroot.'/img';
55 55
 
56
-            if(!file_exists($dir)){mkdir($dir,0777);}
56
+            if (!file_exists($dir)) {mkdir($dir, 0777); }
57 57
 
58 58
             $dir .= $DS.date('Y');
59
-            if(!file_exists($dir)){mkdir($dir,0777);}
59
+            if (!file_exists($dir)) {mkdir($dir, 0777); }
60 60
 
61 61
             $dir .= $DS.date('m');
62
-            if(!file_exists($dir)){mkdir($dir,0777);}
62
+            if (!file_exists($dir)) {mkdir($dir, 0777); }
63 63
 
64 64
             //clean and define path filename
65
-            $filename = $this->cleanFilename( $fileUploaded->getClientOriginalName(), $extension );
65
+            $filename = $this->cleanFilename($fileUploaded->getClientOriginalName(), $extension);
66 66
             //test duplicate
67
-            $name = $this->mediaExist( $filename,$webroot );
67
+            $name = $this->mediaExist($filename, $webroot);
68 68
 
69 69
             $filePath = date('Y').'/'.date('m').'/'.$name;
70 70
             $save_media = $this->saveMedia($filePath, $name, $model, $model_id);
71 71
 
72
-            if($save_media)
72
+            if ($save_media)
73 73
             {
74 74
                 //upload
75
-                $fileUploaded->move($dir,$name);
75
+                $fileUploaded->move($dir, $name);
76 76
                 $event->setMedia($save_media);
77 77
 
78
-                if(!empty($resize_option[$model]))
78
+                if (!empty($resize_option[$model]))
79 79
                 {
80 80
                     $resize = new ResizeHelper($resize_option[$model], $webroot);
81 81
                     $resize->resize($save_media->getFile());
82 82
                 }
83 83
 
84 84
                 return true;
85
-            }else{
85
+            }else {
86 86
 
87 87
                 return new Response();
88 88
             }
89
-        }else{
89
+        }else {
90 90
 
91 91
             return new Response();
92 92
         }
@@ -98,12 +98,12 @@  discard block
 block discarded – undo
98 98
      * @param $event
99 99
      * @return bool
100 100
      */
101
-    private function isValidExtension($extension,$event)
101
+    private function isValidExtension($extension, $event)
102 102
     {
103 103
         $extensions = $event->getContainer()->getParameter('mykees.media.extension');
104
-        $valid_extensions = !empty($extensions) ? $extensions : ['jpg','jpeg','JPG','JPEG'];
104
+        $valid_extensions = !empty($extensions) ? $extensions : ['jpg', 'jpeg', 'JPG', 'JPEG'];
105 105
 
106
-        return in_array($extension,$valid_extensions);
106
+        return in_array($extension, $valid_extensions);
107 107
     }
108 108
 
109 109
     /**
@@ -112,10 +112,10 @@  discard block
 block discarded – undo
112 112
      * @param $extension
113 113
      * @return string
114 114
      */
115
-    private function cleanFilename( $filename, $extension )
115
+    private function cleanFilename($filename, $extension)
116 116
     {
117
-        $f = explode('.',$filename);
118
-        $cleanFilename = Urlizer::urlize(implode('.',array_slice($f,0,-1)));
117
+        $f = explode('.', $filename);
118
+        $cleanFilename = Urlizer::urlize(implode('.', array_slice($f, 0, -1)));
119 119
 
120 120
         return $cleanFilename.'.'.$extension;
121 121
     }
@@ -127,23 +127,23 @@  discard block
 block discarded – undo
127 127
      * @param int $count
128 128
      * @return string
129 129
      */
130
-    private function mediaExist( $filename, $webroot, $count=0 )
130
+    private function mediaExist($filename, $webroot, $count = 0)
131 131
     {
132 132
         $file = $filename;
133 133
         $filePath = false;
134
-        if($count > 0){
135
-            $f = explode('.',$filename);
134
+        if ($count > 0) {
135
+            $f = explode('.', $filename);
136 136
             $file = $f[0].'_'.$count.'.'.end($f);
137 137
             $filePath = $webroot.'/img/'.date('Y').'/'.date('m').'/'.$file;
138 138
         }
139 139
         $filePath = !$filePath ? $webroot.'/img/'.date('Y').'/'.date('m').'/'.$file : $filePath;
140
-        if(file_exists($filePath))
140
+        if (file_exists($filePath))
141 141
         {
142 142
             $count++;
143 143
 
144
-            return $this->mediaExist( $filename, $webroot, $count );
145
-        }else{
146
-            $filename =  $file;
144
+            return $this->mediaExist($filename, $webroot, $count);
145
+        }else {
146
+            $filename = $file;
147 147
 
148 148
             return $filename;
149 149
         }
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
     private function saveMedia($filePath, $filename, $model, $model_id)
161 161
     {
162 162
         $media = new Media();
163
-        $fn = explode('.',$filename);
163
+        $fn = explode('.', $filename);
164 164
         $media->setName($fn[0]);
165 165
         $media->setMediableModel($model);
166 166
         $media->setMediableId($model_id);
Please login to merge, or discard this patch.