Completed
Pull Request — master (#3)
by
unknown
20:32
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.
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 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/MediasListener.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,9 +31,9 @@
 block discarded – undo
31 31
     {
32 32
         $model = $args->getEntity();
33 33
 
34
-        if($model instanceof Mediable)
34
+        if ($model instanceof Mediable)
35 35
         {
36
-            $manager = new MediaManager($this->managerRegistry,$this->rootDir,$this->resize_parameters);
36
+            $manager = new MediaManager($this->managerRegistry, $this->rootDir, $this->resize_parameters);
37 37
             $manager->removeAllMediasForModel($model);
38 38
         }
39 39
     }
Please login to merge, or discard this patch.
Traits/MediableTrait.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,16 +14,16 @@
 block discarded – undo
14 14
 
15 15
     protected $medias;
16 16
 
17
-    public function getMediableModel(){
17
+    public function getMediableModel() {
18 18
         return Reflection::getClassShortName($this);
19 19
     }
20 20
 
21
-    public function getMediableId(){
21
+    public function getMediableId() {
22 22
         return $this->getId();
23 23
     }
24 24
 
25
-    public function getMedias(){
26
-        $this->medias = $this->medias ? : new ArrayCollection();
25
+    public function getMedias() {
26
+        $this->medias = $this->medias ?: new ArrayCollection();
27 27
         return $this->medias;
28 28
     }
29 29
 }
Please login to merge, or discard this patch.
Util/Urlizer.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -40,13 +40,13 @@  discard block
 block discarded – undo
40 40
         $stringLength = strlen($string);
41 41
         for ($i = 0; $i < $stringLength; $i++) {
42 42
             if (ord($string[$i]) < 0x80) continue; # 0bbbbbbb
43
-            elseif ((ord($string[$i]) & 0xE0) == 0xC0) $n=1; # 110bbbbb
44
-            elseif ((ord($string[$i]) & 0xF0) == 0xE0) $n=2; # 1110bbbb
45
-            elseif ((ord($string[$i]) & 0xF8) == 0xF0) $n=3; # 11110bbb
46
-            elseif ((ord($string[$i]) & 0xFC) == 0xF8) $n=4; # 111110bb
47
-            elseif ((ord($string[$i]) & 0xFE) == 0xFC) $n=5; # 1111110b
43
+            elseif ((ord($string[$i]) & 0xE0) == 0xC0) $n = 1; # 110bbbbb
44
+            elseif ((ord($string[$i]) & 0xF0) == 0xE0) $n = 2; # 1110bbbb
45
+            elseif ((ord($string[$i]) & 0xF8) == 0xF0) $n = 3; # 11110bbb
46
+            elseif ((ord($string[$i]) & 0xFC) == 0xF8) $n = 4; # 111110bb
47
+            elseif ((ord($string[$i]) & 0xFE) == 0xFC) $n = 5; # 1111110b
48 48
             else return false; # Does not match any model
49
-            for ($j=0; $j<$n; $j++) { # n bytes matching 10bbbbbb follow ?
49
+            for ($j = 0; $j < $n; $j++) { # n bytes matching 10bbbbbb follow ?
50 50
                 if ((++$i == strlen($string)) || ((ord($string[$i]) & 0xC0) != 0x80))
51 51
                 return false;
52 52
             }
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
             chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
124 124
             chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
125 125
             chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
126
-            chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
126
+            chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij',
127 127
             chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
128 128
             chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
129 129
             chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
             chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
140 140
             chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
141 141
             chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
142
-            chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
142
+            chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe',
143 143
             chr(197).chr(148) => 'R', chr(197).chr(149) => 'r',
144 144
             chr(197).chr(150) => 'R', chr(197).chr(151) => 'r',
145 145
             chr(197).chr(152) => 'R', chr(197).chr(153) => 'r',
@@ -169,11 +169,11 @@  discard block
 block discarded – undo
169 169
             'Ä' => 'Ae', 'ä' => 'ae', 'Ü' => 'Ue', 'ü' => 'ue',
170 170
             'Ö' => 'Oe', 'ö' => 'oe', 'ß' => 'ss',
171 171
             // Norwegian characters
172
-            'Å'=>'Aa','Æ'=>'Ae','Ø'=>'O','æ'=>'a','ø'=>'o','å'=>'aa'
172
+            'Å'=>'Aa', 'Æ'=>'Ae', 'Ø'=>'O', 'æ'=>'a', 'ø'=>'o', 'å'=>'aa'
173 173
             );
174 174
 
175 175
             $string = strtr($string, $chars);
176
-        } else {
176
+        }else {
177 177
             // Assume ISO-8859-1 if not UTF-8
178 178
             $chars['in'] = chr(128).chr(131).chr(138).chr(142).chr(154).chr(158)
179 179
             .chr(159).chr(162).chr(165).chr(181).chr(192).chr(193).chr(194)
@@ -237,10 +237,10 @@  discard block
 block discarded – undo
237 237
     */
238 238
     public static function validUtf8($str)
239 239
     {
240
-        $mState = 0;     // cached expected number of octets after the current octet
240
+        $mState = 0; // cached expected number of octets after the current octet
241 241
                          // until the beginning of the next UTF8 character sequence
242
-        $mUcs4  = 0;     // cached Unicode character
243
-        $mBytes = 1;     // cached expected number of octets in the current sequence
242
+        $mUcs4  = 0; // cached Unicode character
243
+        $mBytes = 1; // cached expected number of octets in the current sequence
244 244
 
245 245
         $len = strlen($str);
246 246
         for ($i = 0; $i < $len; $i++) {
@@ -288,13 +288,13 @@  discard block
 block discarded – undo
288 288
                     $mUcs4 = ($mUcs4 & 1) << 30;
289 289
                     $mState = 5;
290 290
                     $mBytes = 6;
291
-                } else {
291
+                }else {
292 292
                     /* Current octet is neither in the US-ASCII range nor a legal first
293 293
                      * octet of a multi-octet sequence.
294 294
                      */
295 295
                     return false;
296 296
                 }
297
-            } else {
297
+            }else {
298 298
                 // When mState is non-zero, we expect a continuation of the multi-octet
299 299
                 // sequence
300 300
                 if (0x80 == (0xC0 & ($in))) {
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
                         $mUcs4  = 0;
329 329
                         $mBytes = 1;
330 330
                     }
331
-                } else {
331
+                }else {
332 332
                     /**
333 333
                     *((0xC0 & (*in) != 0x80) && (mState != 0))
334 334
                     * Incomplete multi-octet sequence.
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
     {
352 352
         if (function_exists('mb_strtolower')) {
353 353
             $text = mb_strtolower($text);
354
-        } else {
354
+        }else {
355 355
             $text = strtolower($text);
356 356
         }
357 357
 
Please login to merge, or discard this patch.