Completed
Branch master (2825b9)
by satoru
03:27
created
src/Controller/ContentsFileController.php 4 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -84,6 +84,9 @@  discard block
 block discarded – undo
84 84
 
85 85
     }
86 86
     
87
+    /**
88
+     * @param string $ext
89
+     */
87 90
     private function getFileType($ext){
88 91
         $aContentTypes = [
89 92
         'txt'=>'text/plain',
@@ -142,6 +145,9 @@  discard block
 block discarded – undo
142 145
         return $sContentType;
143 146
     }
144 147
     
148
+    /**
149
+     * @param string $filepath
150
+     */
145 151
     private function __resizeSet($filepath, $resize){
146 152
         if (empty($resize['width'])){
147 153
             $resize['width'] = 0;
Please login to merge, or discard this patch.
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -2,8 +2,6 @@
 block discarded – undo
2 2
 namespace ContentsFile\Controller;
3 3
 
4 4
 use ContentsFile\Controller\AppController;
5
-use Cake\Event\Event;
6
-use Cake\Core\Configure;
7 5
 use Cake\ORM\TableRegistry;
8 6
 use Cake\Utility\Inflector;
9 7
 
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
     private $__baseModel;
13 13
     private $__attachmentModel;
14 14
     
15
-    public function loader(){
15
+    public function loader() {
16 16
         $this->autoRender = false;
17 17
 
18 18
         $model = $this->request->query['model'];
@@ -23,13 +23,13 @@  discard block
 block discarded – undo
23 23
 
24 24
         $contentsFileConfig = $entity->contentsFileConfig;
25 25
         
26
-        if (!empty($this->request->query['tmp_file_name'])){
26
+        if (!empty($this->request->query['tmp_file_name'])) {
27 27
             $filename = $this->request->query['tmp_file_name'];
28 28
             $filepath = $contentsFileConfig['fields'][$field_name]['cacheTempDir'] . $filename;
29
-        } elseif (!empty($this->request->query['model_id'])){
29
+        } elseif (!empty($this->request->query['model_id'])) {
30 30
             //表示条件をチェックする
31 31
             $check_method_name = 'contentsFileCheck' . Inflector::camelize($field_name);
32
-            if (method_exists($this->__baseModel, $check_method_name)){
32
+            if (method_exists($this->__baseModel, $check_method_name)) {
33 33
                 //エラーなどの処理はTableに任せる
34 34
                 $this->__baseModel->{$check_method_name}($this->request->query['model_id']);
35 35
             }
@@ -41,22 +41,22 @@  discard block
 block discarded – undo
41 41
                 ->where(['field_name' => $this->request->query['field_name']])
42 42
                 ->first()
43 43
             ;
44
-            if (empty($attachmentData)){
44
+            if (empty($attachmentData)) {
45 45
                 //404
46 46
             }
47 47
             $filename = $attachmentData->file_name;
48 48
             $filepath = $contentsFileConfig['fields'][$field_name]['filePath'] . $attachmentData->model . '/' . $attachmentData->model_id . '/' . $attachmentData->field_name;
49 49
             
50 50
             //通常のセットの時のみresize設定があれば見る
51
-            if (!empty($this->request->query['resize'])){
51
+            if (!empty($this->request->query['resize'])) {
52 52
                 $filepath = $this->__resizeSet($filepath, $this->request->query['resize']);
53 53
             }
54 54
         
55 55
         }
56 56
         
57 57
         $file_ext = null;
58
-        if (preg_match('/\.([^\.]*)$/', $filename, $ext)){
59
-            if ($ext[1]){
58
+        if (preg_match('/\.([^\.]*)$/', $filename, $ext)) {
59
+            if ($ext[1]) {
60 60
                 $file_ext = strtolower($ext[1]);
61 61
             }
62 62
         }
@@ -65,10 +65,10 @@  discard block
 block discarded – undo
65 65
         $file = $filepath;
66 66
 
67 67
         header('Content-Length: ' . filesize($file));
68
-        if(!empty($file_ext)){
68
+        if (!empty($file_ext)) {
69 69
             $fileContentType = $this->getFileType($file_ext);
70 70
             header('Content-Type: ' . $fileContentType);
71
-        }else{
71
+        } else {
72 72
             $fileContentType = $this->getMimeType($file);
73 73
             header('Content-Type: ' . $fileContentType);
74 74
         }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 
85 85
     }
86 86
     
87
-    private function getFileType($ext){
87
+    private function getFileType($ext) {
88 88
         $aContentTypes = [
89 89
         'txt'=>'text/plain',
90 90
         'htm'=>'text/html',
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
     ]; 
106 106
         $sContentType = 'application/octet-stream';
107 107
         
108
-        if (!empty($aContentTypes[$ext])){
108
+        if (!empty($aContentTypes[$ext])) {
109 109
             $sContentType = $aContentTypes[$ext];
110 110
         }
111 111
         return $sContentType;
@@ -134,34 +134,34 @@  discard block
 block discarded – undo
134 134
         
135 135
         if (($pos = strrpos($filename, ".")) !== false) {
136 136
             // 拡張子がある場合
137
-            $ext = strtolower(substr($filename, $pos+1));
137
+            $ext = strtolower(substr($filename, $pos + 1));
138 138
             if (strlen($ext)) {
139
-                return $aContentTypes[$ext]?$aContentTypes[$ext]:$sContentType;
139
+                return $aContentTypes[$ext] ? $aContentTypes[$ext] : $sContentType;
140 140
             }
141 141
         }
142 142
         return $sContentType;
143 143
     }
144 144
     
145
-    private function __resizeSet($filepath, $resize){
146
-        if (empty($resize['width'])){
145
+    private function __resizeSet($filepath, $resize) {
146
+        if (empty($resize['width'])) {
147 147
             $resize['width'] = 0;
148 148
         }
149
-        if (empty($resize['height'])){
149
+        if (empty($resize['height'])) {
150 150
             $resize['height'] = 0;
151 151
         }
152 152
         //両方ゼロの場合はそのまま返す
153
-        if ($resize['width'] == 0 && $resize['height'] == 0){
153
+        if ($resize['width'] == 0 && $resize['height'] == 0) {
154 154
             return $filepath;
155 155
         }
156 156
         $imagepathinfo = $this->__baseModel->getPathinfo($filepath, $resize);
157 157
         
158 158
         //ファイルの存在チェック
159
-        if (file_exists($imagepathinfo['resize_filepath'])){
159
+        if (file_exists($imagepathinfo['resize_filepath'])) {
160 160
             return $imagepathinfo['resize_filepath'];
161 161
         }
162 162
         
163 163
         //ない場合はリサイズを実行
164
-        if (!$this->__baseModel->imageResize($filepath, $resize)){
164
+        if (!$this->__baseModel->imageResize($filepath, $resize)) {
165 165
             //失敗時はそのままのパスを返す(画像以外の可能性あり)
166 166
             return $filepath;
167 167
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@
 block discarded – undo
68 68
         if(!empty($file_ext)){
69 69
             $fileContentType = $this->getFileType($file_ext);
70 70
             header('Content-Type: ' . $fileContentType);
71
-        }else{
71
+        } else{
72 72
             $fileContentType = $this->getMimeType($file);
73 73
             header('Content-Type: ' . $fileContentType);
74 74
         }
Please login to merge, or discard this patch.
src/Model/Behavior/ContentsFileBehavior.php 3 patches
Doc Comments   +19 added lines, -1 removed lines patch added patch discarded remove patch
@@ -92,6 +92,10 @@  discard block
 block discarded – undo
92 92
      * imageResize
93 93
      * 画像のリサイズ処理(外からでもたたけるようにpublicにする
94 94
      */
95
+
96
+    /**
97
+     * @param string $imagePath
98
+     */
95 99
     public function imageResize($imagePath, $baseSize) {
96 100
         if (file_exists($imagePath) === false) {
97 101
             return false;
@@ -213,6 +217,11 @@  discard block
 block discarded – undo
213 217
      * __fileMove
214 218
      * ファイルの移動(元ファイルがいたときのことを考えてbackupファイルを作成する
215 219
      */
220
+
221
+    /**
222
+     * @param string $tmpFile
223
+     * @param string $new_filepath
224
+     */
216 225
     private function __fileMove($tmpFile, $new_filepath){
217 226
         if (file_exists($new_filepath)){
218 227
             $pathinfo = $this->getPathInfo($new_filepath);
@@ -226,6 +235,10 @@  discard block
 block discarded – undo
226 235
      * __resizeDirRemove
227 236
      * リサイズディレクトリの削除
228 237
      */
238
+
239
+    /**
240
+     * @param string $new_filepath
241
+     */
229 242
     private function __resizeDirRemove($new_filepath){
230 243
         $imagepathinfo = $this->getPathInfo($new_filepath);
231 244
         $this->__recursiveRemoveDir($imagepathinfo['resize_dir']);
@@ -238,7 +251,7 @@  discard block
 block discarded – undo
238 251
      *
239 252
      * @param $dir
240 253
      * @return
241
-     * @access protected
254
+     boolean @access protected
242 255
      */
243 256
     private function __recursiveRemoveDir($dir) {
244 257
         if (is_dir($dir)) {
@@ -349,6 +362,11 @@  discard block
 block discarded – undo
349 362
      * __mkdir
350 363
      * ディレクトリの作成(パーミッションの設定のため
351 364
      */
365
+
366
+    /**
367
+     * @param integer $permission
368
+     * @param boolean $recursive
369
+     */
352 370
     private function __mkdir($path, $permission, $recursive){
353 371
         if (is_dir($path)){
354 372
             return true;
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
         //設定値をentityから取得
22 22
         $contentsFileConfig = $entity->contentsFileConfig;
23 23
         $this->__attachmentModel = TableRegistry::get('Attachments');
24
-        foreach ($contentsFileConfig['fields'] as $field => $field_settings){
24
+        foreach ($contentsFileConfig['fields'] as $field => $field_settings) {
25 25
             //contents_file_の方に入ったentityをベースに処理する
26 26
             $file_info = $entity->{'contents_file_' . $field};
27 27
             if (
28 28
                 !empty($file_info) &&
29 29
                 //tmp_file_nameがある=アップロードしたファイルがある
30 30
                 array_key_exists('tmp_file_name', $file_info)
31
-            ){
31
+            ) {
32 32
                 $attachmentSaveData = [
33 33
                     'model' => $this->_table->alias(),
34 34
                     'model_id' => $entity->id,
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
                 $new_filepath = $new_filedir . $file_info['field_name'];
44 44
                 if (
45 45
                     !$this->__mkdir($new_filedir, 0777, true) || 
46
-                    $this->__fileMove($field_settings['cacheTempDir'] . $file_info['tmp_file_name'] , $new_filepath)
46
+                    $this->__fileMove($field_settings['cacheTempDir'] . $file_info['tmp_file_name'], $new_filepath)
47 47
                     
48
-                ){
48
+                ) {
49 49
                     //失敗時はロールバック
50 50
                     $this->__fileRollback($contentsFileConfig, $entity->id);
51 51
                     return false;
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
                 $this->__resizeDirRemove($new_filepath);
56 56
                 
57 57
                 //リサイズ画像作成
58
-                if (!empty($field_settings['resize'])){
59
-                    foreach ($field_settings['resize'] as $resize_settings){
60
-                        if (!$this->imageResize($new_filepath, $resize_settings)){
58
+                if (!empty($field_settings['resize'])) {
59
+                    foreach ($field_settings['resize'] as $resize_settings) {
60
+                        if (!$this->imageResize($new_filepath, $resize_settings)) {
61 61
                             //失敗時はロールバック
62 62
                             $this->__fileRollback($contentsFileConfig, $entity->id);
63 63
                             return false;
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
                     ->where(['model_id' => $entity->id])
72 72
                     ->where(['field_name' => $file_info['field_name']])
73 73
                     ->first(1);
74
-                if (!empty($attachmentDataCheck)){
74
+                if (!empty($attachmentDataCheck)) {
75 75
                     $attachmentEntity->id = $attachmentDataCheck->id;
76 76
                 }
77 77
                 if (!$this->__attachmentModel->save($attachmentEntity)) {
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
         //resizeファイルを格納するディレクトリを作成
187 187
         if (
188 188
             !$this->__mkdir($imagepathinfo['resize_dir'], 0777, true)
189
-        ){
189
+        ) {
190 190
             return false;
191 191
         }
192 192
         
@@ -213,20 +213,20 @@  discard block
 block discarded – undo
213 213
      * __fileMove
214 214
      * ファイルの移動(元ファイルがいたときのことを考えてbackupファイルを作成する
215 215
      */
216
-    private function __fileMove($tmpFile, $new_filepath){
217
-        if (file_exists($new_filepath)){
216
+    private function __fileMove($tmpFile, $new_filepath) {
217
+        if (file_exists($new_filepath)) {
218 218
             $pathinfo = $this->getPathInfo($new_filepath);
219 219
             //旧ファイルをバックアップとしてとっておく
220
-            rename($new_filepath,$pathinfo['backup_filepath']);
220
+            rename($new_filepath, $pathinfo['backup_filepath']);
221 221
         }
222
-        return !rename($tmpFile , $new_filepath);
222
+        return !rename($tmpFile, $new_filepath);
223 223
     }
224 224
     
225 225
     /*
226 226
      * __resizeDirRemove
227 227
      * リサイズディレクトリの削除
228 228
      */
229
-    private function __resizeDirRemove($new_filepath){
229
+    private function __resizeDirRemove($new_filepath) {
230 230
         $imagepathinfo = $this->getPathInfo($new_filepath);
231 231
         $this->__recursiveRemoveDir($imagepathinfo['resize_dir']);
232 232
     }
@@ -260,14 +260,14 @@  discard block
 block discarded – undo
260 260
      * __fileCommit
261 261
      * 保存成功時の処理(backupファイルを削除)
262 262
      */
263
-    private function __fileCommit($contentsFileConfig, $target_id){
263
+    private function __fileCommit($contentsFileConfig, $target_id) {
264 264
         //back削除する
265
-        foreach ($contentsFileConfig['fields'] as $field => $fieldSetting){
265
+        foreach ($contentsFileConfig['fields'] as $field => $fieldSetting) {
266 266
             $new_filedir = $fieldSetting['filePath'] . $this->_table->alias() . '/' . $target_id . '/';
267 267
             $new_filepath = $new_filedir . $field;
268 268
             $new_filepath_pathinfo = $this->getPathInfo($new_filepath);
269 269
             
270
-            if (file_exists($new_filepath_pathinfo['backup_filepath'])){
270
+            if (file_exists($new_filepath_pathinfo['backup_filepath'])) {
271 271
                 //旧ファイルを元に戻す
272 272
                 unlink($new_filepath_pathinfo['backup_filepath']);
273 273
             }
@@ -279,21 +279,21 @@  discard block
 block discarded – undo
279 279
      * __fileRollback
280 280
      * 保存失敗時の処理 アップロードファイルを削除しバックアップファイルを元に戻す
281 281
      */
282
-    private function __fileRollback($contentsFileConfig, $target_id){
282
+    private function __fileRollback($contentsFileConfig, $target_id) {
283 283
         //backを元に戻す
284
-        foreach ($contentsFileConfig['fields'] as $field => $fieldSetting){
284
+        foreach ($contentsFileConfig['fields'] as $field => $fieldSetting) {
285 285
             $new_filedir = $fieldSetting['filePath'] . $this->_table->alias() . '/' . $target_id . '/';
286 286
             $new_filepath = $new_filedir . $field;
287 287
             $new_filepath_pathinfo = $this->getPathInfo($new_filepath);
288 288
             $backup_file = $new_filepath_pathinfo['backup_filepath'];
289
-            if (file_exists($new_filepath)){
289
+            if (file_exists($new_filepath)) {
290 290
                 //新規に登録したファイルを削除
291 291
                 unlink($new_filepath);
292 292
                 //resizeDirも削除(これはアクセス時に復元可能なため
293 293
                 $this->__resizeDirRemove($new_filepath);
294 294
             }
295 295
             
296
-            if (file_exists($new_filepath_pathinfo['backup_filepath'])){
296
+            if (file_exists($new_filepath_pathinfo['backup_filepath'])) {
297 297
                 //旧ファイルを元に戻す
298 298
                 rename($new_filepath_pathinfo['backup_filepath'], $new_filepath);
299 299
             }
@@ -349,8 +349,8 @@  discard block
 block discarded – undo
349 349
      * __mkdir
350 350
      * ディレクトリの作成(パーミッションの設定のため
351 351
      */
352
-    private function __mkdir($path, $permission, $recursive){
353
-        if (is_dir($path)){
352
+    private function __mkdir($path, $permission, $recursive) {
353
+        if (is_dir($path)) {
354 354
             return true;
355 355
         }
356 356
         $oldumask = umask(0);
@@ -363,17 +363,17 @@  discard block
 block discarded – undo
363 363
      * getPathInfo
364 364
      * 通常のpathinfoに加えてContentsFile独自のpathも一緒に設定する
365 365
      */
366
-    public function getPathInfo($imagePath, $resize = []){
366
+    public function getPathInfo($imagePath, $resize = []) {
367 367
         $pathinfo = pathinfo($imagePath);
368 368
         $pathinfo['resize_dir'] = $pathinfo['dirname'] . '/contents_file_resize_' . $pathinfo['filename'];
369 369
         $pathinfo['backup_filepath'] = $pathinfo['dirname'] . '/contents_file_back_' . $pathinfo['filename'];
370 370
         //一旦ベースのパスを通しておく
371 371
         $pathinfo['resize_filepath'] = $imagePath;
372
-        if (!empty($resize)){
373
-            if (!isset($resize['width'])){
372
+        if (!empty($resize)) {
373
+            if (!isset($resize['width'])) {
374 374
                 $resize['width'] = 0;
375 375
             }
376
-            if (!isset($resize['height'])){
376
+            if (!isset($resize['height'])) {
377 377
                 $resize['height'] = 0;
378 378
             }
379 379
             $pathinfo['resize_filepath'] = $pathinfo['resize_dir'] . '/' . $resize['width'] . '_' . $resize['height'];
Please login to merge, or discard this patch.
Braces   +8 added lines, -5 removed lines patch added patch discarded remove patch
@@ -245,9 +245,11 @@  discard block
 block discarded – undo
245 245
             $objects = scandir($dir);
246 246
             foreach ($objects as $object) {
247 247
                 if ($object != "." && $object != "..") {
248
-                    if (filetype($dir . "/" . $object) == "dir")
249
-                        $this->_recursiveRemoveDir($dir . "/" . $object); else
250
-                        @unlink($dir . "/" . $object);
248
+                    if (filetype($dir . "/" . $object) == "dir") {
249
+                                            $this->_recursiveRemoveDir($dir . "/" . $object);
250
+                    } else {
251
+                                                @unlink($dir . "/" . $object);
252
+                        }
251 253
                 }
252 254
             }
253 255
             reset($objects);
@@ -333,8 +335,9 @@  discard block
 block discarded – undo
333 335
                     break;
334 336
                 }
335 337
             }
336
-            if (!isset($tp) || $tp !== null)
337
-                break;
338
+            if (!isset($tp) || $tp !== null) {
339
+                            break;
340
+            }
338 341
         }
339 342
         // 透過GIF
340 343
         if (isset($tp) && is_array($tp)) {
Please login to merge, or discard this patch.
src/Model/Entity/ContentsFileTrait.php 2 patches
Unused Use Statements   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@
 block discarded – undo
2 2
 
3 3
 namespace ContentsFile\Model\Entity;
4 4
 
5
-use Cake\Utility\Security;
6
-use Cake\ORM\TableRegistry;
5
+use Cake\Utility\Security;
6
+use Cake\ORM\TableRegistry;
7 7
 use Cake\I18n\Time;
8 8
 
9 9
 trait ContentsFileTrait
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -19,20 +19,20 @@  discard block
 block discarded – undo
19 19
         //設定値はまとめる
20 20
         $settings = $this->contentsFileConfig;
21 21
         
22
-        $this->__contentsFileSettings = array_merge($default,$settings);
22
+        $this->__contentsFileSettings = array_merge($default, $settings);
23 23
     }
24 24
     
25
-    public function getContentsFile($property, $value){
25
+    public function getContentsFile($property, $value) {
26 26
         $this->__contentsFileSettings();
27 27
         if (
28 28
             //attachmentにデータが登録時のみ
29 29
             !empty($this->id) && 
30 30
             //設定値に設定されているとき
31 31
             preg_match('/^contents_file_(.*)$/', $property, $match) &&
32
-            array_key_exists($match[1] , $this->__contentsFileSettings['fields'])// &&
33
-        ){
32
+            array_key_exists($match[1], $this->__contentsFileSettings['fields'])// &&
33
+        ) {
34 34
             //何もセットされていないとき
35
-            if (empty($this->_properties[$property])){
35
+            if (empty($this->_properties[$property])) {
36 36
                 //attachmentからデータを探しに行く
37 37
                 $this->__attachmentModel = TableRegistry::get('Attachments');
38 38
                 $attachmentData = $this->__attachmentModel->find('all')
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
                     ->where(['field_name' => $match[1]])
42 42
                     ->first()
43 43
                 ;
44
-                if (!empty($attachmentData)){
44
+                if (!empty($attachmentData)) {
45 45
                     $value = [
46 46
                         'model' => $attachmentData->model,
47 47
                         'model_id' => $attachmentData->model_id,
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
         return $value;
60 60
     }
61 61
     
62
-    public function setContentsFile(){
62
+    public function setContentsFile() {
63 63
         $this->__contentsFileSettings();
64
-        foreach ($this->__contentsFileSettings['fields'] as $field => $field_setting){
64
+        foreach ($this->__contentsFileSettings['fields'] as $field => $field_setting) {
65 65
             $file_info = $this->{$field};
66 66
             if (
67 67
                 //ファイルの情報がある
@@ -82,13 +82,13 @@  discard block
 block discarded – undo
82 82
                 ];
83 83
                 
84 84
                 //$file_infoにtmp_nameがいるときはtmpディレクトリへのファイルのコピーを行う
85
-                if (!empty($file_info['tmp_name'])){
85
+                if (!empty($file_info['tmp_name'])) {
86 86
                     $tmp_file_name = Security::hash(rand() . Time::now()->i18nFormat('YYYY/MM/dd HH:ii:ss') . $file_info['name']);
87 87
                     
88
-                    if ($this->__getExt($file_info['name']) !== null ){
88
+                    if ($this->__getExt($file_info['name']) !== null) {
89 89
                         $tmp_file_name .= '.' . $this->__getExt($file_info['name']);
90 90
                     }
91
-                    if (!copy($file_info['tmp_name'], $field_setting['cacheTempDir'] . $tmp_file_name)){
91
+                    if (!copy($file_info['tmp_name'], $field_setting['cacheTempDir'] . $tmp_file_name)) {
92 92
                         //エラー
93 93
                     }
94 94
                     $file_set['tmp_file_name'] = $tmp_file_name;
@@ -103,10 +103,10 @@  discard block
 block discarded – undo
103 103
         return $this;
104 104
     }
105 105
     
106
-    private function __getExt($file){
107
-        $file_explode = explode('.',$file);
106
+    private function __getExt($file) {
107
+        $file_explode = explode('.', $file);
108 108
         //この場合拡張子なし
109
-        if (count($file_explode) == 1){
109
+        if (count($file_explode) == 1) {
110 110
             return null;
111 111
         }
112 112
         return $file_explode[(count($file_explode) - 1)];
Please login to merge, or discard this patch.
config/routes.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 use Cake\Routing\Router;
3 3
 
4
-Router::plugin('ContentsFile', function ($routes) {
4
+Router::plugin('ContentsFile', function($routes) {
5 5
     $routes->fallbacks('InflectedRoute');
6 6
 });
Please login to merge, or discard this patch.
src/Validation/ContentsFileValidation.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
     
14 14
     
15 15
     public static function uploadMaxSizeCheck ($value,$context){
16
-       return $value['error'] != UPLOAD_ERR_INI_SIZE;
16
+        return $value['error'] != UPLOAD_ERR_INI_SIZE;
17 17
     }
18 18
     
19 19
     /**
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,13 +6,13 @@
 block discarded – undo
6 6
 
7 7
 class ContentsFileValidation extends Validation
8 8
 {
9
-    public static function checkMaxSize ($value, $max, $context){
9
+    public static function checkMaxSize($value, $max, $context) {
10 10
         $max_value = ContentsFileValidation::__calcFileSizeUnit($max);
11 11
         return $max_value >= $value['size'];
12 12
     }
13 13
     
14 14
     
15
-    public static function uploadMaxSizeCheck ($value,$context){
15
+    public static function uploadMaxSizeCheck($value, $context) {
16 16
        return $value['error'] != UPLOAD_ERR_INI_SIZE;
17 17
     }
18 18
     
Please login to merge, or discard this patch.
src/View/Helper/ContentsFileHelper.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,10 +14,10 @@  discard block
 block discarded – undo
14 14
 
15 15
     public function link($file_info, $options = [], $title = null) {
16 16
         //一時パス用の設定
17
-        if ($title === null){
17
+        if ($title === null) {
18 18
             $title = $file_info['file_name'];
19 19
         }
20
-        if (isset($options['resize'])){
20
+        if (isset($options['resize'])) {
21 21
             $file_info['resize'] = $options['resize'];
22 22
             unset($options['resize']);
23 23
         }
@@ -34,25 +34,25 @@  discard block
 block discarded – undo
34 34
     }
35 35
     
36 36
     public function image($file_info, $options = []) {
37
-        if (!empty($file_info)){
38
-            if (isset($options['resize'])){
37
+        if (!empty($file_info)) {
38
+            if (isset($options['resize'])) {
39 39
                 $file_info['resize'] = $options['resize'];
40 40
                 unset($options['resize']);
41 41
             }
42
-            return $this->Html->image($this->__urlArray($file_info) ,$options);
42
+            return $this->Html->image($this->__urlArray($file_info), $options);
43 43
         }
44 44
         return '';
45 45
     }
46 46
 
47
-    public function url($file_info, $full = false){
48
-        if (!isset($file_info['resize'])){
47
+    public function url($file_info, $full = false) {
48
+        if (!isset($file_info['resize'])) {
49 49
             $file_info['resize'] = false;
50 50
         }
51
-        return $this->Url->build($this->__urlArray($file_info),$full);
51
+        return $this->Url->build($this->__urlArray($file_info), $full);
52 52
     }
53 53
     
54
-    private function __urlArray($file_info){
55
-        if (!empty($file_info['tmp_file_name'])){
54
+    private function __urlArray($file_info) {
55
+        if (!empty($file_info['tmp_file_name'])) {
56 56
             return [
57 57
                 'controller' => 'contents_file',
58 58
                 'action' => 'loader',
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
                 'tmp_file_name' => $file_info['tmp_file_name'],
63 63
             ];
64 64
         } else {
65
-            if (!isset($file_info['resize'])){
65
+            if (!isset($file_info['resize'])) {
66 66
                 $file_info['resize'] = false;
67 67
             }
68 68
             return [
Please login to merge, or discard this patch.