Passed
Push — main ( 93508d...088a49 )
by Sammy
01:32
created
Controllers/ORMController.class.php 1 patch
Braces   +60 added lines, -43 removed lines patch added patch discarded remove patch
@@ -34,9 +34,12 @@  discard block
 block discarded – undo
34 34
       {
35 35
         $res = $this->$chainling();
36 36
 
37
-        if($this->logger()->has_halting_messages()) // logger handled a critical error during the chailing execution
37
+        if($this->logger()->has_halting_messages()) {
38
+          // logger handled a critical error during the chailing execution
38 39
         {
39
-          break; // dont go on with other
40
+          break;
41
+        }
42
+        // dont go on with other
40 43
         }
41 44
 
42 45
         if($chainling === $method)
@@ -47,19 +50,23 @@  discard block
 block discarded – undo
47 50
       }
48 51
     }
49 52
 
50
-    if(method_exists($this, 'conclude')) // conclude always executed, even with has_halting_messages
53
+    if(method_exists($this, 'conclude')) {
54
+      // conclude always executed, even with has_halting_messages
51 55
     	$this->conclude();
56
+    }
52 57
 
53
-    if(method_exists($this, 'display'))
54
-    	$template = $this->display($custom_template);
58
+    if(method_exists($this, 'display')) {
59
+        	$template = $this->display($custom_template);
60
+    }
55 61
   }
56 62
 
57 63
   public function prepare()
58 64
   {
59 65
     parent::prepare();
60 66
 
61
-    if(!class_exists($this->model_class_name = $this->class_name()))
62
-      throw new \Exception("!class_exists($this->model_class_name)");
67
+    if(!class_exists($this->model_class_name = $this->class_name())) {
68
+          throw new \Exception("!class_exists($this->model_class_name)");
69
+    }
63 70
 
64 71
     $this->model_type = $this->model_class_name::model_type();
65 72
 
@@ -74,17 +81,18 @@  discard block
 block discarded – undo
74 81
       $pk_values = $this->model_class_name::table()->primary_keys_match($this->router()->submitted());
75 82
 
76 83
       $this->load_model = $this->model_class_name::exists($pk_values);
77
-    }
78
-    elseif($this->router()->requests())
84
+    } elseif($this->router()->requests())
79 85
     {
80 86
       $pk_values = $this->model_class_name::table()->primary_keys_match($this->router()->params());
81 87
 
82
-      if(!is_null($this->load_model = $this->model_class_name::exists($pk_values)))
83
-        $this->form_model = clone $this->load_model;
88
+      if(!is_null($this->load_model = $this->model_class_name::exists($pk_values))) {
89
+              $this->form_model = clone $this->load_model;
90
+      }
84 91
     }
85 92
 
86
-    if(!is_null($this->load_model) && $this->load_model->traceable())
87
-      $this->viewport('load_model_history', $this->load_model->traces() ?? []);
93
+    if(!is_null($this->load_model) && $this->load_model->traceable()) {
94
+          $this->viewport('load_model_history', $this->load_model->traces() ?? []);
95
+    }
88 96
   }
89 97
 
90 98
   public function has_load_model()
@@ -112,8 +120,9 @@  discard block
 block discarded – undo
112 120
       $this->logger()->nice('CRUDITES_INSTANCE_ALTERED', ['MODEL_'.get_class($model)::model_type().'_INSTANCE']);
113 121
       return $model;
114 122
     }
115
-    foreach($this->errors() as $field => $error_msg)
116
-      $this->logger()->warning($error_msg, [$field]);
123
+    foreach($this->errors() as $field => $error_msg) {
124
+          $this->logger()->warning($error_msg, [$field]);
125
+    }
117 126
 
118 127
     return null;
119 128
   }
@@ -127,8 +136,12 @@  discard block
 block discarded – undo
127 136
   {
128 137
     $class_name = is_null($model) ? $this->model_class_name : get_class($model);
129 138
 
130
-    if(!isset($filters['date_start']))  $filters['date_start'] = $this->box('StateAgent')->filters('date_start');
131
-    if(!isset($filters['date_stop']))   $filters['date_stop'] = $this->box('StateAgent')->filters('date_stop');
139
+    if(!isset($filters['date_start'])) {
140
+      $filters['date_start'] = $this->box('StateAgent')->filters('date_start');
141
+    }
142
+    if(!isset($filters['date_stop'])) {
143
+      $filters['date_stop'] = $this->box('StateAgent')->filters('date_stop');
144
+    }
132 145
 
133 146
     // dd($filters);
134 147
     $listing = $class_name::filter($filters);
@@ -144,15 +157,16 @@  discard block
 block discarded – undo
144 157
       foreach($class_name::table()->columns() as $column)
145 158
       {
146 159
 
147
-        if(!$column->is_auto_incremented() && !$column->is_hidden())
148
-          $listing_fields[$column->name()]=L(sprintf('MODEL_%s_FIELD_%s', $class_name::model_type(), $column->name()));
160
+        if(!$column->is_auto_incremented() && !$column->is_hidden()) {
161
+                  $listing_fields[$column->name()]=L(sprintf('MODEL_%s_FIELD_%s', $class_name::model_type(), $column->name()));
162
+        }
149 163
       }
150
-    }
151
-    else
164
+    } else
152 165
     {
153 166
       $current = current($listing);
154
-      if(is_object($current))
155
-        $current = get_object_vars($current);
167
+      if(is_object($current)) {
168
+              $current = get_object_vars($current);
169
+      }
156 170
 
157 171
       foreach(array_keys($current) as $field)
158 172
       {
@@ -184,9 +198,9 @@  discard block
 block discarded – undo
184 198
   {
185 199
     $model = $this->persist_model($this->form_model);
186 200
 
187
-    if(empty($this->errors()))
188
-      $this->route_back($model);
189
-    else
201
+    if(empty($this->errors())) {
202
+          $this->route_back($model);
203
+    } else
190 204
     {
191 205
       $this->edit();
192 206
       return 'edit';
@@ -226,8 +240,7 @@  discard block
 block discarded – undo
226 240
     {
227 241
       $this->logger()->warning('CRUDITES_ERR_INSTANCE_NOT_FOUND', ['MODEL_'.$this->model_type.'_INSTANCE']);
228 242
       $this->router()->hop($this->model_type);
229
-    }
230
-    elseif($this->load_model->immortal())
243
+    } elseif($this->load_model->immortal())
231 244
     {
232 245
 
233 246
       $this->logger()->warning('CRUDITES_ERR_INSTANCE_IS_IMMORTAL', ['MODEL_'.$this->model_type.'_INSTANCE']);
@@ -237,15 +250,15 @@  discard block
 block discarded – undo
237 250
 
238 251
   public function destroy()
239 252
   {
240
-    if(!$this->router()->submits())
241
-      throw new \Exception('KADRO_ROUTER_MUST_SUBMIT');
253
+    if(!$this->router()->submits()) {
254
+          throw new \Exception('KADRO_ROUTER_MUST_SUBMIT');
255
+    }
242 256
 
243 257
     if($this->load_model->destroy($this->operator()->operator_id()) === false)
244 258
     {
245 259
       $this->logger()->info('CRUDITES_ERR_INSTANCE_IS_UNDELETABLE', [''.$this->load_model]);
246 260
       $this->route_back($this->load_model);
247
-    }
248
-    else
261
+    } else
249 262
     {
250 263
       $this->logger()->nice('CRUDITES_INSTANCE_DESTROYED', ['MODEL_'.$this->model_type.'_INSTANCE']);
251 264
       $this->route_back($this->model_type);
@@ -263,11 +276,13 @@  discard block
 block discarded – undo
263 276
 
264 277
     $this->viewport('form_model_type', $this->model_type);
265 278
 
266
-    if(isset($this->load_model))
267
-      $this->viewport('load_model', $this->load_model);
279
+    if(isset($this->load_model)) {
280
+          $this->viewport('load_model', $this->load_model);
281
+    }
268 282
 
269
-    if(isset($this->form_model))
270
-      $this->viewport('form_model', $this->form_model);
283
+    if(isset($this->form_model)) {
284
+          $this->viewport('form_model', $this->form_model);
285
+    }
271 286
   }
272 287
 
273 288
   public function collection_to_csv($collection, $filename)
@@ -325,9 +340,9 @@  discard block
 block discarded – undo
325 340
     $route_params = [];
326 341
 
327 342
     $route_name = get_class($model)::model_type().'_';
328
-    if($model->is_new())
329
-      $route_name.= 'new';
330
-    else
343
+    if($model->is_new()) {
344
+          $route_name.= 'new';
345
+    } else
331 346
     {
332 347
       $route_name.= 'default';
333 348
       $route_params = ['id' => $model->get_id()];
@@ -338,11 +353,13 @@  discard block
 block discarded – undo
338 353
 
339 354
   public function route_factory($route=null, $route_params=[]) : string
340 355
   {
341
-    if(is_null($route) && $this->router()->submits())
342
-      $route = $this->form_model;
356
+    if(is_null($route) && $this->router()->submits()) {
357
+          $route = $this->form_model;
358
+    }
343 359
 
344
-    if(!is_null($route) && is_subclass_of($route, '\HexMakina\Crudites\Interfaces\ModelInterface'))
345
-      $route = $this->route_model($route);
360
+    if(!is_null($route) && is_subclass_of($route, '\HexMakina\Crudites\Interfaces\ModelInterface')) {
361
+          $route = $this->route_model($route);
362
+    }
346 363
 
347 364
     return parent::route_factory($route, $route_params);
348 365
   }
Please login to merge, or discard this patch.
StorageManager/__DEL__FileManager.class.php 1 patch
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -12,8 +12,9 @@  discard block
 block discarded – undo
12 12
   
13 13
   function __construct($file_manageable_model, $filetype)
14 14
   {
15
-    if(!is_subclass_of($file_manageable_model, '\HexMakina\Crudites\TightModel'))
16
-      throw new \Exception("__construct($file_manageable_model) // only Model items are manageable");
15
+    if(!is_subclass_of($file_manageable_model, '\HexMakina\Crudites\TightModel')) {
16
+          throw new \Exception("__construct($file_manageable_model) // only Model items are manageable");
17
+    }
17 18
 
18 19
     $this->pmi = $file_manageable_model;
19 20
     $this->picture_type = $filetype;
@@ -58,11 +59,13 @@  discard block
 block discarded – undo
58 59
     return $this->pmi->get_id().'/';  
59 60
 
60 61
     $pmi_model_type = get_class($this->pmi)::model_type();
61
-    if(!isset($this->pmi) || is_null($this->get_type()))
62
-      throw new \Exception(__FUNCTION__." // undefined manageable item or picture type");
62
+    if(!isset($this->pmi) || is_null($this->get_type())) {
63
+          throw new \Exception(__FUNCTION__." // undefined manageable item or picture type");
64
+    }
63 65
 
64
-    if(!isset($settings[$pmi_model_type][$this->get_type()]['import_directory']))
65
-      throw new \Exception(__FUNCTION__." // undefined configuration for '".($pmi_model_type)."'>'".$this->get_type()."'>'import_directory'");
66
+    if(!isset($settings[$pmi_model_type][$this->get_type()]['import_directory'])) {
67
+          throw new \Exception(__FUNCTION__." // undefined configuration for '".($pmi_model_type)."'>'".$this->get_type()."'>'import_directory'");
68
+    }
66 69
     
67 70
     // global $settings;
68 71
     // return $settings[$pmi_model_type][$this->get_type()]['import_directory'].$this->pmi->get_id().'/';
Please login to merge, or discard this patch.