Completed
Pull Request — master (#3)
by
unknown
05:10
created
Event/UploadEvent.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Created by PhpStorm.
4
- * User: Rafidion Michael
5
- * Date: 30/11/2014
6
- * Time: 18:21
7
- */
3
+     * Created by PhpStorm.
4
+     * User: Rafidion Michael
5
+     * Date: 30/11/2014
6
+     * Time: 18:21
7
+     */
8 8
 
9 9
 namespace Mykees\MediaBundle\Event;
10 10
 
Please login to merge, or discard this patch.
Form/Type/MediaShowType.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Created by PhpStorm.
4
- * User: Rafidion Michael
5
- * Date: 18/11/2014
6
- * Time: 01:22
7
- */
3
+     * Created by PhpStorm.
4
+     * User: Rafidion Michael
5
+     * Date: 18/11/2014
6
+     * Time: 01:22
7
+     */
8 8
 
9 9
 namespace Mykees\MediaBundle\Form\Type;
10 10
 
Please login to merge, or discard this 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.
Helper/ResizeHelper.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Created by PhpStorm.
4
- * User: tetsu0o
5
- * Date: 29/12/14
6
- * Time: 02:03
7
- */
3
+     * Created by PhpStorm.
4
+     * User: tetsu0o
5
+     * Date: 29/12/14
6
+     * Time: 02:03
7
+     */
8 8
 
9 9
 namespace Mykees\MediaBundle\Helper;
10 10
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,9 +26,9 @@  discard block
 block discarded – undo
26 26
 
27 27
     public function resize($image)
28 28
     {
29
-        $absolute_path = $this->webroot . $image;
29
+        $absolute_path = $this->webroot.$image;
30 30
         $absolute_info = pathinfo($absolute_path);
31
-        $allowedExtension = ['jpg','JPG','jpeg',"JPEG",'png','PNG','gif','GIF'];
31
+        $allowedExtension = ['jpg', 'JPG', 'jpeg', "JPEG", 'png', 'PNG', 'gif', 'GIF'];
32 32
         $extension = pathinfo($image);
33 33
         $extension = $extension['extension'];
34 34
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
                     $imagine = new \Imagine\Gd\Imagine();
47 47
                     $mode = $this->options['mode'];
48 48
 
49
-                    $imagine->open($absolute_info['dirname'] . '/' . $absolute_info['filename'] . '.'.$extension)
49
+                    $imagine->open($absolute_info['dirname'].'/'.$absolute_info['filename'].'.'.$extension)
50 50
                         ->thumbnail(
51 51
                             new \Imagine\Image\Box($width, $height),
52 52
                             !empty($mode) &&
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/ImageResizeExtension.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Created by PhpStorm.
4
- * User: tetsu0o
5
- * Date: 30/12/14
6
- * Time: 02:47
7
- */
3
+     * Created by PhpStorm.
4
+     * User: tetsu0o
5
+     * Date: 30/12/14
6
+     * Time: 02:47
7
+     */
8 8
 
9 9
 namespace Mykees\MediaBundle\Twig\Extension;
10 10
 
Please login to merge, or discard this 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 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Created by PhpStorm.
4
- * User: Rafidion Michael
5
- * Date: 02/12/2014
6
- * Time: 01:56
7
- */
3
+     * Created by PhpStorm.
4
+     * User: Rafidion Michael
5
+     * Date: 02/12/2014
6
+     * Time: 01:56
7
+     */
8 8
 
9 9
 namespace Mykees\MediaBundle\Interfaces;
10 10
 
Please login to merge, or discard this 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 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Created by PhpStorm.
4
- * User: Rafidion Michael
5
- * Date: 30/11/2014
6
- * Time: 18:22
7
- */
3
+     * Created by PhpStorm.
4
+     * User: Rafidion Michael
5
+     * Date: 30/11/2014
6
+     * Time: 18:22
7
+     */
8 8
 
9 9
 namespace Mykees\MediaBundle\EventListener;
10 10
 
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
 
39 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);
@@ -85,10 +85,10 @@  discard block
 block discarded – undo
85 85
                 }
86 86
 
87 87
                 return true;
88
-            } else {
88
+            }else {
89 89
                 return new Response();
90 90
             }
91
-        } else {
91
+        }else {
92 92
             return new Response();
93 93
         }
94 94
     }
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
     private function isValidExtension($extension, $event)
103 103
     {
104 104
         $extensions = $event->getContainer()->getParameter('mykees.media.extension');
105
-        $valid_extensions = !empty($extensions) ? $extensions : ['jpg','jpeg','JPG','JPEG'];
105
+        $valid_extensions = !empty($extensions) ? $extensions : ['jpg', 'jpeg', 'JPG', 'JPEG'];
106 106
 
107 107
         return in_array($extension, $valid_extensions);
108 108
     }
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
             $count++;
143 143
 
144 144
             return $this->mediaExist($filename, $webroot, $count);
145
-        } else {
146
-            $filename =  $file;
145
+        }else {
146
+            $filename = $file;
147 147
 
148 148
             return $filename;
149 149
         }
Please login to merge, or discard this patch.