Passed
Push — master ( d347c7...920953 )
by Ferry
10:32
created
src/CRUDBoosterServiceProvider.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -25,13 +25,13 @@  discard block
 block discarded – undo
25 25
         // Register views
26 26
         $this->loadViewsFrom(__DIR__.'/views', 'crudbooster');
27 27
         $this->loadViewsFrom(__DIR__.'/types', 'types');
28
-        $this->loadTranslationsFrom(__DIR__."/localization","cb");
28
+        $this->loadTranslationsFrom(__DIR__."/localization", "cb");
29 29
 
30 30
         // Publish the files
31
-        $this->publishes([__DIR__.'/configs/crudbooster.php' => config_path('crudbooster.php')],'cb_config');
32
-        $this->publishes([__DIR__.'/database' => base_path('database')],'cb_migration');
33
-        $this->publishes([__DIR__.'/templates/CBHook.stub'=> app_path('Http/CBHook.php')],'cb_hook');
34
-        $this->publishes([__DIR__ . '/assets' =>public_path('cb_asset')],'cb_asset');
31
+        $this->publishes([__DIR__.'/configs/crudbooster.php' => config_path('crudbooster.php')], 'cb_config');
32
+        $this->publishes([__DIR__.'/database' => base_path('database')], 'cb_migration');
33
+        $this->publishes([__DIR__.'/templates/CBHook.stub'=> app_path('Http/CBHook.php')], 'cb_hook');
34
+        $this->publishes([__DIR__.'/assets' =>public_path('cb_asset')], 'cb_asset');
35 35
 
36 36
         // Override Local FileSystem
37 37
         Config::set("filesystems.disks.local.root", cbConfig("LOCAL_FILESYSTEM_PATH", public_path("storage")));
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
         require __DIR__.'/helpers/Helper.php';
54 54
 
55 55
         // Singletons
56
-        $this->app->singleton('crudbooster', function ()
56
+        $this->app->singleton('crudbooster', function()
57 57
         {
58 58
             return true;
59 59
         });
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
         }
77 77
 
78 78
         // Merging configuration
79
-        $this->mergeConfigFrom(__DIR__.'/configs/crudbooster.php','crudbooster');
79
+        $this->mergeConfigFrom(__DIR__.'/configs/crudbooster.php', 'crudbooster');
80 80
 
81 81
         // Register additional library
82 82
         $this->app->register('Intervention\Image\ImageServiceProvider');
@@ -84,17 +84,17 @@  discard block
 block discarded – undo
84 84
 
85 85
     private function registerPlugin()
86 86
     {
87
-        if(file_exists(app_path("CBPlugins"))) {
87
+        if (file_exists(app_path("CBPlugins"))) {
88 88
             $views = scandir(app_path("CBPlugins"));
89
-            foreach($views as $view) {
90
-                if($view != "." && $view != "..") {
89
+            foreach ($views as $view) {
90
+                if ($view != "." && $view != "..") {
91 91
                     $basename = basename($view);
92 92
 
93 93
                     // register migrations
94 94
                     $this->loadMigrationsFrom(app_path("CBPlugins".DIRECTORY_SEPARATOR.$basename.DIRECTORY_SEPARATOR."Migrations"));
95 95
 
96 96
                     // register view
97
-                    $this->loadViewsFrom(app_path("CBPlugins".DIRECTORY_SEPARATOR.$basename.DIRECTORY_SEPARATOR."Views"),$basename);
97
+                    $this->loadViewsFrom(app_path("CBPlugins".DIRECTORY_SEPARATOR.$basename.DIRECTORY_SEPARATOR."Views"), $basename);
98 98
 
99 99
                     // register route
100 100
                     require app_path("CBPlugins".DIRECTORY_SEPARATOR.$basename.DIRECTORY_SEPARATOR."Routes".DIRECTORY_SEPARATOR."Route.php");
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 
108 108
     private function registerTypeRoutes() {
109 109
         $routes = rglob(__DIR__.DIRECTORY_SEPARATOR."types".DIRECTORY_SEPARATOR."Route.php");
110
-        foreach($routes as $route) {
110
+        foreach ($routes as $route) {
111 111
             require $route;
112 112
         }
113 113
     }
Please login to merge, or discard this patch.
src/controllers/DeveloperPluginStoreController.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -31,14 +31,14 @@  discard block
 block discarded – undo
31 31
 
32 32
     public function getIndex() {
33 33
 
34
-        if(request("refresh")) {
35
-            $this->fetchPluginData(false );
36
-            return cb()->redirectBack("Plugin list has been refreshed!","success");
34
+        if (request("refresh")) {
35
+            $this->fetchPluginData(false);
36
+            return cb()->redirectBack("Plugin list has been refreshed!", "success");
37 37
         }
38 38
 
39 39
         $data = [];
40 40
         $data['result'] = $this->fetchPluginData();
41
-        return view($this->view.'.index',$data);
41
+        return view($this->view.'.index', $data);
42 42
     }
43 43
 
44 44
     public function postLoginAccount() {
@@ -53,13 +53,13 @@  discard block
 block discarded – undo
53 53
         ]);
54 54
         $response = $curl->send();
55 55
 
56
-        if($respArray = json_decode($response, true)) {
57
-            if($respArray['status'] && isset($respArray['token'])) {
56
+        if ($respArray = json_decode($response, true)) {
57
+            if ($respArray['status'] && isset($respArray['token'])) {
58 58
                 session(['account_token'=>$respArray['token']]);
59 59
             }
60
-            return response()->make($response,200,["Content-Type"=>"application/json"]);
60
+            return response()->make($response, 200, ["Content-Type"=>"application/json"]);
61 61
         } else {
62
-            return response()->json(['status'=>false,'message'=>'failed']);
62
+            return response()->json(['status'=>false, 'message'=>'failed']);
63 63
         }
64 64
     }
65 65
 
@@ -76,15 +76,15 @@  discard block
 block discarded – undo
76 76
         ]);
77 77
         $response = $curl->send();
78 78
 
79
-        if($respArray = json_decode($response, true)) {
80
-            if($respArray['status']) {
79
+        if ($respArray = json_decode($response, true)) {
80
+            if ($respArray['status']) {
81 81
                 $form = base64_decode($respArray['payment']);
82
-                return response()->json(['status'=>true,'form'=>$form]);
82
+                return response()->json(['status'=>true, 'form'=>$form]);
83 83
             } else {
84 84
                 return response()->json($respArray);
85 85
             }
86 86
         } else {
87
-            return response()->json(['status'=>false,'message'=>'failed','raw'=>$response]);
87
+            return response()->json(['status'=>false, 'message'=>'failed', 'raw'=>$response]);
88 88
         }
89 89
     }
90 90
 
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
     {
93 93
         $pluginData = $this->fetchPluginData();
94 94
 
95
-        if(isset($pluginData[$key])) {
96
-            if(file_exists(app_path("CBPlugins/".$key))) {
95
+        if (isset($pluginData[$key])) {
96
+            if (file_exists(app_path("CBPlugins/".$key))) {
97 97
 
98
-                if(isset($pluginData['source']) && $pluginData['source'] == 'composer') {
99
-                    if(isset($pluginData['package'])) {
98
+                if (isset($pluginData['source']) && $pluginData['source'] == 'composer') {
99
+                    if (isset($pluginData['package'])) {
100 100
                         ComposerHelper::composerRemove($pluginData['package']);
101 101
                     }
102 102
                 }
@@ -104,24 +104,24 @@  discard block
 block discarded – undo
104 104
                 rrmdir(app_path("CBPlugins/".$key));
105 105
 
106 106
                 return response()->json(['status'=>true, 'message'=>'Plugin has been uninstalled!']);
107
-            }else{
108
-                return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin is not found']);
107
+            } else {
108
+                return response()->json(['status'=>false, 'message'=>'Failed to uninstall, plugin is not found']);
109 109
             }
110
-        }else {
111
-            return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin key is not found']);
110
+        } else {
111
+            return response()->json(['status'=>false, 'message'=>'Failed to uninstall, plugin key is not found']);
112 112
         }
113 113
     }
114 114
 
115
-    private function recursiveCopy($src,$dst) {
115
+    private function recursiveCopy($src, $dst) {
116 116
         $dir = opendir($src);
117 117
         @mkdir($dst);
118
-        while(false !== ( $file = readdir($dir)) ) {
119
-            if (( $file != '.' ) && ( $file != '..' )) {
120
-                if ( is_dir($src . '/' . $file) ) {
121
-                    $this->recursiveCopy($src . '/' . $file,$dst . '/' . $file);
118
+        while (false !== ($file = readdir($dir))) {
119
+            if (($file != '.') && ($file != '..')) {
120
+                if (is_dir($src.'/'.$file)) {
121
+                    $this->recursiveCopy($src.'/'.$file, $dst.'/'.$file);
122 122
                 }
123 123
                 else {
124
-                    copy($src . '/' . $file,$dst . '/' . $file);
124
+                    copy($src.'/'.$file, $dst.'/'.$file);
125 125
                 }
126 126
             }
127 127
         }
@@ -130,26 +130,26 @@  discard block
 block discarded – undo
130 130
 
131 131
     public function getInstall($key)
132 132
     {
133
-        ini_set("memory_limit","192M");
133
+        ini_set("memory_limit", "192M");
134 134
         set_time_limit(500);
135 135
 
136 136
         $pluginData = $this->fetchPluginData();
137 137
 
138 138
         try {
139
-            if(isset($pluginData[$key])) {
139
+            if (isset($pluginData[$key])) {
140 140
                 $plugin = $pluginData[$key];
141 141
 
142
-                if(isset($plugin['source']) && $plugin['source'] == "composer") {
142
+                if (isset($plugin['source']) && $plugin['source'] == "composer") {
143 143
 
144
-                    if(isset($plugin['package']) && isset($plugin['service_provider'])) {
144
+                    if (isset($plugin['package']) && isset($plugin['service_provider'])) {
145 145
                         // Make a composer
146 146
                         $output = ComposerHelper::composerRequire($plugin['package'], $plugin['service_provider']);
147 147
 
148 148
                         Artisan::call("migrate");
149 149
 
150
-                        return response()->json(['status'=>true,'message'=>$output]);
150
+                        return response()->json(['status'=>true, 'message'=>$output]);
151 151
                     } else {
152
-                        return response()->json(['status'=>true,'message'=>'Installation is failed, there is no package and or service provider']);
152
+                        return response()->json(['status'=>true, 'message'=>'Installation is failed, there is no package and or service provider']);
153 153
                     }
154 154
 
155 155
                 } else {
@@ -168,16 +168,16 @@  discard block
 block discarded – undo
168 168
                         fclose($temp);
169 169
 
170 170
                         // Rename
171
-                        if(file_exists(app_path("CBPlugins/".$key))) rrmdir(app_path("CBPlugins/".$key));
171
+                        if (file_exists(app_path("CBPlugins/".$key))) rrmdir(app_path("CBPlugins/".$key));
172 172
                         rename(app_path("CBPlugins/".$dirName), app_path("CBPlugins/".$key));
173 173
 
174 174
                         // Read Plugin JSON
175 175
                         $pluginJson = json_decode(file_get_contents(app_path("CBPlugins/".$key."/plugin.json")), true);
176 176
 
177 177
                         // Check if has asset
178
-                        if($pluginJson && $pluginJson['asset']) {
178
+                        if ($pluginJson && $pluginJson['asset']) {
179 179
                             // Check destination folder is ready
180
-                            if(file_exists(public_path("cb_asset/".$key))) {
180
+                            if (file_exists(public_path("cb_asset/".$key))) {
181 181
                                 rrmdir(public_path("cb_asset/".$key));
182 182
                             }
183 183
 
@@ -191,31 +191,31 @@  discard block
 block discarded – undo
191 191
                         //Migrate
192 192
                         Artisan::call("migrate");
193 193
 
194
-                        return response()->json(['status'=>true,'message'=>'Install / update plugin has been succesfull!']);
194
+                        return response()->json(['status'=>true, 'message'=>'Install / update plugin has been succesfull!']);
195 195
 
196 196
                     } else {
197
-                        return response()->json(['status'=>false,'message'=>"Failed to install/update, can't open the plugin archive"]);
197
+                        return response()->json(['status'=>false, 'message'=>"Failed to install/update, can't open the plugin archive"]);
198 198
                     }
199 199
                 }
200 200
 
201
-            }else{
202
-                return response()->json(['status'=>false,'message'=>'Failed to install/update, plugin key is not found']);
201
+            } else {
202
+                return response()->json(['status'=>false, 'message'=>'Failed to install/update, plugin key is not found']);
203 203
             }
204 204
         } catch (\Exception $e) {
205
-            return response()->json(['status'=>false,'message'=>'Something went wrong!']);
205
+            return response()->json(['status'=>false, 'message'=>'Something went wrong!']);
206 206
         }
207 207
     }
208 208
 
209 209
     private function fetchPluginData($cache = true)
210 210
     {
211
-        if($cache === true && $data = Cache::get("plugin_store_data")) {
211
+        if ($cache === true && $data = Cache::get("plugin_store_data")) {
212 212
             return $data;
213 213
         }
214 214
 
215 215
         $result = [];
216 216
 
217 217
         try {
218
-            $no_cache = ($cache)?0:1;
218
+            $no_cache = ($cache) ? 0 : 1;
219 219
             $opts = [
220 220
                 "http" => [
221 221
                     "method" => "GET",
@@ -224,17 +224,17 @@  discard block
 block discarded – undo
224 224
                                 "No-Cache: ".$no_cache
225 225
                 ]
226 226
             ];
227
-            Log::debug("Headers: ".print_r($opts,true));
227
+            Log::debug("Headers: ".print_r($opts, true));
228 228
             $context = stream_context_create($opts);
229 229
             $data = file_get_contents(base64_decode("aHR0cDovL2NydWRib29zdGVyLmNvbS9hcGkvcGx1Z2luP2FjY2Vzc190b2tlbj1iVmMvWm5wWU5TWnJNVlpZT0hFNVUydHFjU1U9"), false, $context);
230 230
             Log::debug("Plugin API : ".$data);
231
-            if($data) {
231
+            if ($data) {
232 232
                 $data = json_decode($data, true);
233
-                if($data['status']==true) {
233
+                if ($data['status'] == true) {
234 234
 
235
-                    foreach($data['data'] as $item) {
235
+                    foreach ($data['data'] as $item) {
236 236
                         $key = $item['key'];
237
-                        $result[ $key ] = $item;
237
+                        $result[$key] = $item;
238 238
                     }
239 239
 
240 240
                     $result = collect($result)->sortBy("name")->all();
Please login to merge, or discard this patch.