Completed
Push — master ( 85afe8...ed5835 )
by Benjamin
02:21
created
DataTransformer/EntityToIdTransformer.php 1 patch
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -30,6 +30,10 @@
 block discarded – undo
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)) {
Please login to merge, or discard this patch.
Entity/Media.php 1 patch
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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)
Please login to merge, or discard this patch.
Twig/Extension/MediaPreviewExtension.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -60,6 +60,9 @@
 block discarded – undo
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) {
Please login to merge, or discard this patch.
Controller/MediaController.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -38,10 +38,10 @@  discard block
 block discarded – undo
38 38
                 $media = $this->get('alpixel_media.manager')->upload($file, $this->get('request')->get('folder'), $lifetime);
39 39
                 $path = $mediaPreview->generatePathFromSecretKey($media->getSecretKey());
40 40
                 $returnData[] = [
41
-                  'id'   => $media->getSecretKey(),
42
-                  'path' => $path,
43
-                  'name' => $media->getName(),
44
-              ];
41
+                    'id'   => $media->getSecretKey(),
42
+                    'path' => $path,
43
+                    'name' => $media->getName(),
44
+                ];
45 45
             }
46 46
         }
47 47
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 
98 98
                     $path = 'upload/'.$media->getUri();
99 99
 
100
-                     // find the image and determine its type
100
+                        // find the image and determine its type
101 101
                     $image = $dataManager->find($filter, $path);
102 102
 
103 103
                     // run the filter
Please login to merge, or discard this patch.
Command/MediaCleanupCommand.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
     public function configure()
16 16
     {
17 17
         $this->setName('alpixel:media:cleanup')
18
-             ->setDescription('Cleaning unused media');
18
+                ->setDescription('Cleaning unused media');
19 19
     }
20 20
 
21 21
     public function execute(InputInterface $input, OutputInterface $output)
Please login to merge, or discard this patch.
Command/LiipImagineCleanupCommand.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
     {
17 17
         parent::configure();
18 18
         $this->setName('alpixel:media:liip_cleanup')
19
-             ->setDescription('Cleaning liip cache folders');
19
+                ->setDescription('Cleaning liip cache folders');
20 20
     }
21 21
 
22 22
     public function execute(InputInterface $input, OutputInterface $output)
Please login to merge, or discard this patch.
Services/MediaManager.php 2 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -38,31 +38,31 @@  discard block
 block discarded – undo
38 38
         $this->allowedMimetypes = $allowedMimetypes;
39 39
     }
40 40
 
41
-  /**
42
-   * $current_uri String actual uri of the file
43
-   * $dest_folder String future uri of the file starting from web/upload folder
44
-   * $lifetime DateTime lifetime of the file. If time goes over this limit, the file will be deleted.
45
-   **/
46
-  public function upload(File $file, $dest_folder = '', \DateTime $lifetime = null)
47
-  {
41
+    /**
42
+     * $current_uri String actual uri of the file
43
+     * $dest_folder String future uri of the file starting from web/upload folder
44
+     * $lifetime DateTime lifetime of the file. If time goes over this limit, the file will be deleted.
45
+     **/
46
+    public function upload(File $file, $dest_folder = '', \DateTime $lifetime = null)
47
+    {
48 48
     //preparing dir name
49 49
     $dest_folder = date('Ymd').'/'.date('G').'/'.$dest_folder;
50 50
 
51 51
     //checking mimetypes
52 52
     $mimeTypePassed = false;
53 53
     foreach ($this->allowedMimetypes as $mimeType) {
54
-      if (preg_match('@'.$mimeType.'@', $file->getMimeType())) {
55
-          $mimeTypePassed = true;
56
-      }
54
+        if (preg_match('@'.$mimeType.'@', $file->getMimeType())) {
55
+            $mimeTypePassed = true;
56
+        }
57 57
     }
58 58
 
59 59
     if (!$mimeTypePassed) {
60
-      throw new InvalidMimeTypeException('Only following filetypes are allowed : '.implode(', ', $this->allowedMimetypes));
60
+        throw new InvalidMimeTypeException('Only following filetypes are allowed : '.implode(', ', $this->allowedMimetypes));
61 61
     }
62 62
 
63 63
     $fs = new Filesystem();
64 64
     if (!$fs->exists($this->uploadDir.$dest_folder)) {
65
-      $fs->mkdir($this->uploadDir.$dest_folder);
65
+        $fs->mkdir($this->uploadDir.$dest_folder);
66 66
     }
67 67
 
68 68
     $em = $this->entityManager;
@@ -85,27 +85,27 @@  discard block
 block discarded – undo
85 85
     // Checking for a media with the same name
86 86
     $mediaExists = $this->entityManager->getRepository('AlpixelMediaBundle:Media')->findOneByUri($dest_folder.$filename);
87 87
     if (count($mediaExists) === 0) {
88
-      $mediaExists = $fs->exists($this->uploadDir.$dest_folder.$filename);
88
+        $mediaExists = $fs->exists($this->uploadDir.$dest_folder.$filename);
89 89
     }
90 90
 
91 91
     // If there's one, we try to generate a new name
92 92
     $extension = $file->getExtension();
93 93
     if (empty($extension)) {
94
-      $extension = $file->guessExtension();
94
+        $extension = $file->guessExtension();
95 95
     }
96 96
 
97 97
     if (count($mediaExists) > 0) {
98
-      $filename = basename($filename, '.'.$extension);
99
-
100
-      $i = 1;
101
-      do {
102
-          $media->setName($filename.'-'.$i++.'.'.$extension);
103
-          $media->setUri($dest_folder.$media->getName());
104
-          $mediaExists = $this->entityManager->getRepository('AlpixelMediaBundle:Media')->findOneByUri($media->getUri());
105
-      } while (count($mediaExists) > 0);
98
+        $filename = basename($filename, '.'.$extension);
99
+
100
+        $i = 1;
101
+        do {
102
+            $media->setName($filename.'-'.$i++.'.'.$extension);
103
+            $media->setUri($dest_folder.$media->getName());
104
+            $mediaExists = $this->entityManager->getRepository('AlpixelMediaBundle:Media')->findOneByUri($media->getUri());
105
+        } while (count($mediaExists) > 0);
106 106
     } else {
107
-      $media->setName($filename.'.'.$extension);
108
-      $media->setUri($dest_folder.$media->getName());
107
+        $media->setName($filename.'.'.$extension);
108
+        $media->setUri($dest_folder.$media->getName());
109 109
     }
110 110
 
111 111
     $file->move($this->uploadDir.$dest_folder, $media->getName());
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
     $em->flush();
120 120
 
121 121
     return $media;
122
-  }
122
+    }
123 123
 
124 124
     public function cleanup()
125 125
     {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     public function __construct(EntityManager $entityManager, $uploadDir, $allowedMimetypes)
32 32
     {
33 33
         $this->entityManager = $entityManager;
34
-        if(substr($uploadDir, -1) !== '/') {
34
+        if (substr($uploadDir, -1) !== '/') {
35 35
             $uploadDir = $uploadDir.'/';
36 36
         }
37 37
         $this->uploadDir = $uploadDir;
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 
72 72
     // Sanitizing the filename
73 73
     $slugify = new Slugify();
74
-    if($file instanceof UploadedFile) {
74
+    if ($file instanceof UploadedFile) {
75 75
         $filename = $slugify->slugify($file->getClientOriginalName());
76 76
     } else {
77 77
         $filename = $slugify->slugify($file->getFilename());
Please login to merge, or discard this patch.
DataFixtures/ORM/MediaProvider.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -46,6 +46,9 @@
 block discarded – undo
46 46
    		return $url;
47 47
    }
48 48
 
49
+   /**
50
+    * @param string $url
51
+    */
49 52
    protected function downloadMedia($url) 
50 53
    {
51 54
    	$filepath = sys_get_temp_dir().'/tmp.jpg';
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,14 +15,14 @@  discard block
 block discarded – undo
15 15
 		$this->mediaManager = $mediaManager;
16 16
 	}
17 17
 
18
-   public function randomMedia ($width = null, $height = null, $type = "color")
18
+   public function randomMedia($width = null, $height = null, $type = "color")
19 19
    {
20 20
 		$file = $this->downloadMedia($this->generateUrl($width, $height, $type));
21 21
 		$media = $this->mediaManager->upload($file);
22 22
 		return $media;
23 23
    }
24 24
 
25
-   protected function generateUrl ($width = null, $height = null, $type = "color")
25
+   protected function generateUrl($width = null, $height = null, $type = "color")
26 26
    {
27 27
    		$url = "http://lorempixel.com/";
28 28
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
    			$url .= 'g/';
31 31
    		}
32 32
 
33
-   		if($width === null && $height !== null) {
33
+   		if ($width === null && $height !== null) {
34 34
    			$width = round($height * 4 / 3);
35 35
    		} elseif ($width !== null && $height === null) {
36 36
    			$height = round($width * 3 / 4);
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
    {
51 51
    	$filepath = sys_get_temp_dir().'/tmp.jpg';
52 52
 	$ch = curl_init($url);
53
-	$fp = fopen($filepath,'wb');
53
+	$fp = fopen($filepath, 'wb');
54 54
 	curl_setopt($ch, CURLOPT_FILE, $fp);
55 55
 	curl_setopt($ch, CURLOPT_HEADER, 0);
56 56
 	curl_exec($ch);
Please login to merge, or discard this patch.
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -8,54 +8,54 @@
 block discarded – undo
8 8
 
9 9
 class MediaProvider extends BaseProvider
10 10
 {
11
-	protected $mediaManager;
12
-
13
-	public function __construct(MediaManager $mediaManager)
14
-	{
15
-		$this->mediaManager = $mediaManager;
16
-	}
17
-
18
-   public function randomMedia ($width = null, $height = null, $type = "color")
19
-   {
20
-		$file = $this->downloadMedia($this->generateUrl($width, $height, $type));
21
-		$media = $this->mediaManager->upload($file);
22
-		return $media;
23
-   }
24
-
25
-   protected function generateUrl ($width = null, $height = null, $type = "color")
26
-   {
27
-   		$url = "http://loremflickr.com/";
28
-
29
-   		if ($type !== 'color') {
30
-   			$url .= 'g/';
31
-   		}
32
-
33
-   		if($width === null && $height !== null) {
34
-   			$width = round($height * 4 / 3);
35
-   		} elseif ($width !== null && $height === null) {
36
-   			$height = round($width * 3 / 4);
37
-   		} else {
38
-   			$width = rand(800, 1600);
39
-   			$height = round($width * 3 / 4);
40
-   		}
41
-
42
-   		$url .= $width.'/'.$height;
43
-
44
-   		$category = ['abstract', 'city', 'nature', 'moutains'];
45
-   		$url .= '/'.$category[array_rand($category, 1)].'/';
46
-   		return $url;
47
-   }
48
-
49
-   protected function downloadMedia($url)
50
-   {
51
-   	$filepath = sys_get_temp_dir().'/tmp.jpg';
52
-	$ch = curl_init($url);
53
-	$fp = fopen($filepath,'wb');
54
-	curl_setopt($ch, CURLOPT_FILE, $fp);
55
-	curl_setopt($ch, CURLOPT_HEADER, 0);
56
-	curl_exec($ch);
57
-	curl_close($ch);
58
-	fclose($fp);
59
-	return new File($filepath, 'random');
60
-   }
11
+    protected $mediaManager;
12
+
13
+    public function __construct(MediaManager $mediaManager)
14
+    {
15
+        $this->mediaManager = $mediaManager;
16
+    }
17
+
18
+    public function randomMedia ($width = null, $height = null, $type = "color")
19
+    {
20
+        $file = $this->downloadMedia($this->generateUrl($width, $height, $type));
21
+        $media = $this->mediaManager->upload($file);
22
+        return $media;
23
+    }
24
+
25
+    protected function generateUrl ($width = null, $height = null, $type = "color")
26
+    {
27
+            $url = "http://loremflickr.com/";
28
+
29
+            if ($type !== 'color') {
30
+                $url .= 'g/';
31
+            }
32
+
33
+            if($width === null && $height !== null) {
34
+                $width = round($height * 4 / 3);
35
+            } elseif ($width !== null && $height === null) {
36
+                $height = round($width * 3 / 4);
37
+            } else {
38
+                $width = rand(800, 1600);
39
+                $height = round($width * 3 / 4);
40
+            }
41
+
42
+            $url .= $width.'/'.$height;
43
+
44
+            $category = ['abstract', 'city', 'nature', 'moutains'];
45
+            $url .= '/'.$category[array_rand($category, 1)].'/';
46
+            return $url;
47
+    }
48
+
49
+    protected function downloadMedia($url)
50
+    {
51
+        $filepath = sys_get_temp_dir().'/tmp.jpg';
52
+    $ch = curl_init($url);
53
+    $fp = fopen($filepath,'wb');
54
+    curl_setopt($ch, CURLOPT_FILE, $fp);
55
+    curl_setopt($ch, CURLOPT_HEADER, 0);
56
+    curl_exec($ch);
57
+    curl_close($ch);
58
+    fclose($fp);
59
+    return new File($filepath, 'random');
60
+    }
61 61
 }
Please login to merge, or discard this patch.