Passed
Push — main ( 9b9a2d...ee3278 )
by Sammy
02:31 queued 36s
created
Controllers/ORMController.class.php 1 patch
Braces   +58 added lines, -41 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,24 @@  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
-    	$this->display($custom_template); // ret value ignored..
58
+    if(method_exists($this, 'display')) {
59
+        	$this->display($custom_template);
60
+    }
61
+    // ret value ignored..
55 62
   }
56 63
 
57 64
   public function prepare()
58 65
   {
59 66
     parent::prepare();
60 67
 
61
-    if(!class_exists($this->model_class_name = $this->class_name()))
62
-      throw new \Exception("!class_exists($this->model_class_name)");
68
+    if(!class_exists($this->model_class_name = $this->class_name())) {
69
+          throw new \Exception("!class_exists($this->model_class_name)");
70
+    }
63 71
 
64 72
     $this->model_type = $this->model_class_name::model_type();
65 73
 
@@ -74,13 +82,13 @@  discard block
 block discarded – undo
74 82
       $pk_values = $this->model_class_name::table()->primary_keys_match($this->router()->submitted());
75 83
 
76 84
       $this->load_model = $this->model_class_name::exists($pk_values);
77
-    }
78
-    elseif($this->router()->requests())
85
+    } elseif($this->router()->requests())
79 86
     {
80 87
       $pk_values = $this->model_class_name::table()->primary_keys_match($this->router()->params());
81 88
 
82
-      if(!is_null($this->load_model = $this->model_class_name::exists($pk_values)))
83
-        $this->form_model = clone $this->load_model;
89
+      if(!is_null($this->load_model = $this->model_class_name::exists($pk_values))) {
90
+              $this->form_model = clone $this->load_model;
91
+      }
84 92
     }
85 93
 
86 94
     if(!is_null($this->load_model) && is_subclass_of($this->load_model, '\HexMakina\Crudites\Interfaces\TraceableInterface') && $this->load_model->traceable())
@@ -117,8 +125,9 @@  discard block
 block discarded – undo
117 125
       $this->logger()->nice(L('CRUDITES_INSTANCE_ALTERED', [L('MODEL_'.get_class($model)::model_type().'_INSTANCE')]));
118 126
       return $model;
119 127
     }
120
-    foreach($this->errors() as $field => $error_msg)
121
-      $this->logger()->warning(L($error_msg, [$field]));
128
+    foreach($this->errors() as $field => $error_msg) {
129
+          $this->logger()->warning(L($error_msg, [$field]));
130
+    }
122 131
 
123 132
     return null;
124 133
   }
@@ -132,8 +141,12 @@  discard block
 block discarded – undo
132 141
   {
133 142
     $class_name = is_null($model) ? $this->model_class_name : get_class($model);
134 143
 
135
-    if(!isset($filters['date_start']))  $filters['date_start'] = $this->box('StateAgent')->filters('date_start');
136
-    if(!isset($filters['date_stop']))   $filters['date_stop'] = $this->box('StateAgent')->filters('date_stop');
144
+    if(!isset($filters['date_start'])) {
145
+      $filters['date_start'] = $this->box('StateAgent')->filters('date_start');
146
+    }
147
+    if(!isset($filters['date_stop'])) {
148
+      $filters['date_stop'] = $this->box('StateAgent')->filters('date_stop');
149
+    }
137 150
 
138 151
     // dd($filters);
139 152
     $listing = $class_name::filter($filters);
@@ -149,15 +162,16 @@  discard block
 block discarded – undo
149 162
       foreach($class_name::table()->columns() as $column)
150 163
       {
151 164
 
152
-        if(!$column->is_auto_incremented() && !$column->is_hidden())
153
-          $listing_fields[$column->name()]=L(sprintf('MODEL_%s_FIELD_%s', $class_name::model_type(), $column->name()));
165
+        if(!$column->is_auto_incremented() && !$column->is_hidden()) {
166
+                  $listing_fields[$column->name()]=L(sprintf('MODEL_%s_FIELD_%s', $class_name::model_type(), $column->name()));
167
+        }
154 168
       }
155
-    }
156
-    else
169
+    } else
157 170
     {
158 171
       $current = current($listing);
159
-      if(is_object($current))
160
-        $current = get_object_vars($current);
172
+      if(is_object($current)) {
173
+              $current = get_object_vars($current);
174
+      }
161 175
 
162 176
       foreach(array_keys($current) as $field)
163 177
       {
@@ -189,9 +203,9 @@  discard block
 block discarded – undo
189 203
   {
190 204
     $model = $this->persist_model($this->form_model);
191 205
 
192
-    if(empty($this->errors()))
193
-      $this->route_back($model);
194
-    else
206
+    if(empty($this->errors())) {
207
+          $this->route_back($model);
208
+    } else
195 209
     {
196 210
       $this->edit();
197 211
       return 'edit';
@@ -231,8 +245,7 @@  discard block
 block discarded – undo
231 245
     {
232 246
       $this->logger()->warning(L('CRUDITES_ERR_INSTANCE_NOT_FOUND', [L('MODEL_'.$this->model_type.'_INSTANCE')]));
233 247
       $this->router()->hop($this->model_type);
234
-    }
235
-    elseif($this->load_model->immortal())
248
+    } elseif($this->load_model->immortal())
236 249
     {
237 250
 
238 251
       $this->logger()->warning(L('CRUDITES_ERR_INSTANCE_IS_IMMORTAL', [L('MODEL_'.$this->model_type.'_INSTANCE')]));
@@ -242,15 +255,15 @@  discard block
 block discarded – undo
242 255
 
243 256
   public function destroy()
244 257
   {
245
-    if(!$this->router()->submits())
246
-      throw new \Exception('KADRO_ROUTER_MUST_SUBMIT');
258
+    if(!$this->router()->submits()) {
259
+          throw new \Exception('KADRO_ROUTER_MUST_SUBMIT');
260
+    }
247 261
 
248 262
     if($this->load_model->destroy($this->operator()->operator_id(), $this->tracer()) === false)
249 263
     {
250 264
       $this->logger()->info(L('CRUDITES_ERR_INSTANCE_IS_UNDELETABLE', [''.$this->load_model]));
251 265
       $this->route_back($this->load_model);
252
-    }
253
-    else
266
+    } else
254 267
     {
255 268
       $this->logger()->nice(L('CRUDITES_INSTANCE_DESTROYED', [L('MODEL_'.$this->model_type.'_INSTANCE')]));
256 269
       $this->route_back($this->model_type);
@@ -268,11 +281,13 @@  discard block
 block discarded – undo
268 281
 
269 282
     $this->viewport('form_model_type', $this->model_type);
270 283
 
271
-    if(isset($this->load_model))
272
-      $this->viewport('load_model', $this->load_model);
284
+    if(isset($this->load_model)) {
285
+          $this->viewport('load_model', $this->load_model);
286
+    }
273 287
 
274
-    if(isset($this->form_model))
275
-      $this->viewport('form_model', $this->form_model);
288
+    if(isset($this->form_model)) {
289
+          $this->viewport('form_model', $this->form_model);
290
+    }
276 291
   }
277 292
 
278 293
   public function collection_to_csv($collection, $filename)
@@ -330,9 +345,9 @@  discard block
 block discarded – undo
330 345
     $route_params = [];
331 346
 
332 347
     $route_name = get_class($model)::model_type().'_';
333
-    if($model->is_new())
334
-      $route_name.= 'new';
335
-    else
348
+    if($model->is_new()) {
349
+          $route_name.= 'new';
350
+    } else
336 351
     {
337 352
       $route_name.= 'default';
338 353
       $route_params = ['id' => $model->get_id()];
@@ -343,11 +358,13 @@  discard block
 block discarded – undo
343 358
 
344 359
   public function route_factory($route=null, $route_params=[]) : string
345 360
   {
346
-    if(is_null($route) && $this->router()->submits())
347
-      $route = $this->form_model;
361
+    if(is_null($route) && $this->router()->submits()) {
362
+          $route = $this->form_model;
363
+    }
348 364
 
349
-    if(!is_null($route) && is_subclass_of($route, '\HexMakina\Crudites\Interfaces\ModelInterface'))
350
-      $route = $this->route_model($route);
365
+    if(!is_null($route) && is_subclass_of($route, '\HexMakina\Crudites\Interfaces\ModelInterface')) {
366
+          $route = $this->route_model($route);
367
+    }
351 368
 
352 369
     return parent::route_factory($route, $route_params);
353 370
   }
Please login to merge, or discard this patch.
Auth/ACL.class.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -37,8 +37,9 @@  discard block
 block discarded – undo
37 37
     $res = self::any(['operator_id'=>$op->operator_id()]);
38 38
 
39 39
     $permission_ids = [];
40
-    foreach($res as $r)
41
-      $permission_ids[]=$r->get('permission_id');
40
+    foreach($res as $r) {
41
+          $permission_ids[]=$r->get('permission_id');
42
+    }
42 43
 
43 44
     $ret = Permission::filter(['ids'=>$permission_ids]);
44 45
     return $ret;
@@ -47,8 +48,9 @@  discard block
 block discarded – undo
47 48
   {
48 49
     $operator_with_perms = get_class($op)::exists($op->operator_id());
49 50
     // $operator_with_perms = get_class($op)::retrieve($operator_with_perms);
50
-    if(is_null($operator_with_perms))
51
-      return [];
51
+    if(is_null($operator_with_perms)) {
52
+          return [];
53
+    }
52 54
 
53 55
     return explode(',',$operator_with_perms->get('permission_names'));
54 56
   }
Please login to merge, or discard this patch.