Completed
Pull Request — master (#17)
by
unknown
01:51
created
DependencyInjection/AlpixelMediaExtension.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
     public function prepend(ContainerBuilder $container)
34 34
     {
35 35
         $parser = new Parser();
36
-        $config = $parser->parse(file_get_contents(__DIR__ . '/../Resources/config/config.yml'));
36
+        $config = $parser->parse(file_get_contents(__DIR__.'/../Resources/config/config.yml'));
37 37
 
38 38
         foreach ($config as $key => $configuration) {
39 39
             $container->prependExtensionConfig($key, $configuration);
Please login to merge, or discard this patch.
DataFixtures/ORM/MediaProvider.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -28,10 +28,10 @@  discard block
 block discarded – undo
28 28
     {
29 29
         do {
30 30
             $dimensions = $this->fetchDimensions($width, $height);
31
-            $file = $this->fetchFromCache($dimensions['w'] . '-' . $dimensions['h']);
31
+            $file = $this->fetchFromCache($dimensions['w'].'-'.$dimensions['h']);
32 32
             if ($file === null) {
33 33
                 $file = $this->downloadMedia($this->generateUrl($dimensions, $type), 'jpg');
34
-                $this->storeInCache($dimensions['w'] . '-' . $dimensions['h'], $file);
34
+                $this->storeInCache($dimensions['w'].'-'.$dimensions['h'], $file);
35 35
             }
36 36
         } while (!preg_match('@^image/@', $file->getMimeType()));
37 37
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
     public function randomFile($fileType)
44 44
     {
45
-        $file = $this->fetchFromCache("file-" . $fileType);
45
+        $file = $this->fetchFromCache("file-".$fileType);
46 46
         if ($file === null) {
47 47
             switch ($fileType) {
48 48
                 case "pdf":
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
                     break;
52 52
             }
53 53
         }
54
-        $this->storeInCache("file-" . $fileType, $file);
54
+        $this->storeInCache("file-".$fileType, $file);
55 55
         $media = $this->mediaManager->upload($file);
56 56
 
57 57
         return $media;
@@ -81,17 +81,17 @@  discard block
 block discarded – undo
81 81
             $url .= 'g/';
82 82
         }
83 83
 
84
-        $url .= $dimensions['w'] . '/' . $dimensions['h'];
84
+        $url .= $dimensions['w'].'/'.$dimensions['h'];
85 85
 
86 86
         $category = ['abstract', 'city', 'nature', 'moutains'];
87
-        $url .= '/' . $category[array_rand($category, 1)] . '/';
87
+        $url .= '/'.$category[array_rand($category, 1)].'/';
88 88
 
89 89
         return $url;
90 90
     }
91 91
 
92 92
     protected function downloadMedia($url, $ext)
93 93
     {
94
-        $filepath = sys_get_temp_dir() . '/' . uniqid() . '.' . $ext;
94
+        $filepath = sys_get_temp_dir().'/'.uniqid().'.'.$ext;
95 95
         $ch = curl_init($url);
96 96
         $fp = fopen($filepath, 'wb');
97 97
         curl_setopt($ch, CURLOPT_FILE, $fp);
@@ -106,16 +106,16 @@  discard block
 block discarded – undo
106 106
     protected function fetchFromCache($key)
107 107
     {
108 108
         $fs = new Filesystem();
109
-        $cacheDir = $_SERVER['HOME'] . '/.symfony/media';
109
+        $cacheDir = $_SERVER['HOME'].'/.symfony/media';
110 110
         if (!$fs->exists($cacheDir)) {
111 111
             $fs->mkdir($cacheDir, 0777);
112 112
         } else {
113
-            $cacheDir .= '/' . $key;
113
+            $cacheDir .= '/'.$key;
114 114
             if (!$fs->exists($cacheDir)) {
115 115
                 $fs->mkdir($cacheDir, 0777);
116 116
             } else {
117 117
                 $finder = new Finder();
118
-                $files = $finder->in($cacheDir . '/')->files();
118
+                $files = $finder->in($cacheDir.'/')->files();
119 119
                 if (strrpos($key, "file-") !== false || $files->count() === 3) {
120 120
                     try {
121 121
                         $iterator = $finder->getIterator();
@@ -124,10 +124,10 @@  discard block
 block discarded – undo
124 124
                             $iterator->next();
125 125
                         }
126 126
                         $file = new File($iterator->current());
127
-                        $fs->copy($file->getRealPath(), sys_get_temp_dir() . '/' . $file->getFilename());
127
+                        $fs->copy($file->getRealPath(), sys_get_temp_dir().'/'.$file->getFilename());
128 128
 
129
-                        return new File(sys_get_temp_dir() . '/' . $file->getFilename());
130
-                    } catch(FileNotFoundException $e) {}
129
+                        return new File(sys_get_temp_dir().'/'.$file->getFilename());
130
+                    } catch (FileNotFoundException $e) {}
131 131
                 }
132 132
             }
133 133
         }
@@ -136,10 +136,10 @@  discard block
 block discarded – undo
136 136
     protected function storeInCache($key, File $file)
137 137
     {
138 138
         $fs = new Filesystem();
139
-        $cacheDir = $_SERVER['HOME'] . '/.symfony/media/' . $key;
139
+        $cacheDir = $_SERVER['HOME'].'/.symfony/media/'.$key;
140 140
         if (!$fs->exists($cacheDir)) {
141 141
             $fs->mkdir($cacheDir, 0777);
142 142
         }
143
-        $fs->copy($file->getRealPath(), $cacheDir . '/' . $file->getFilename());
143
+        $fs->copy($file->getRealPath(), $cacheDir.'/'.$file->getFilename());
144 144
     }
145 145
 }
Please login to merge, or discard this patch.