Passed
Push — main ( 93508d...088a49 )
by Sammy
01:32
created
Logger/LogLaddy.class.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 namespace HexMakina\kadro\Logger;
13 13
 
14
-use \HexMakina\Crudites\{Crudites,CruditesException,Table};
14
+use \HexMakina\Crudites\{Crudites, CruditesException, Table};
15 15
 use \HexMakina\Crudites\TableInterface;
16 16
 
17 17
 
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
     $context['class'] = get_class($throwable);
69 69
     $context['trace'] = $throwable->getTrace();
70 70
 
71
-    if(is_subclass_of($throwable, 'Error') || get_class($throwable) === 'Error')
71
+    if (is_subclass_of($throwable, 'Error') || get_class($throwable) === 'Error')
72 72
       (new LogLaddy())->alert(self::INTERNAL_ERROR, $context);
73
-    elseif(is_subclass_of($throwable, 'Exception') || get_class($throwable) === 'Exception')
73
+    elseif (is_subclass_of($throwable, 'Exception') || get_class($throwable) === 'Exception')
74 74
       (new LogLaddy())->notice(self::USER_EXCEPTION, $context);
75 75
     else
76 76
     {
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
   public function system_halted($level)
83 83
   {
84 84
 
85
-    switch($level)
85
+    switch ($level)
86 86
     {
87 87
       case LogLevel::ERROR:
88 88
       case LogLevel::CRITICAL:
@@ -101,19 +101,19 @@  discard block
 block discarded – undo
101 101
     $display_error = null;
102 102
 
103 103
     // --- Handles Throwables (exception_handler())
104
-    if($message==self::INTERNAL_ERROR || $message== self::USER_EXCEPTION)
104
+    if ($message == self::INTERNAL_ERROR || $message == self::USER_EXCEPTION)
105 105
     {
106 106
       $this->has_halting_messages = true;
107 107
       $display_error = \HexMakina\Debugger\Debugger::format_throwable_message($context['class'], $context['code'], $context['file'], $context['line'], $context['text']);
108 108
       error_log($display_error);
109
-      $display_error.= \HexMakina\Debugger\Debugger::format_trace($context['trace'], false);
109
+      $display_error .= \HexMakina\Debugger\Debugger::format_trace($context['trace'], false);
110 110
       self::HTTP_500($display_error);
111 111
     }
112
-    elseif($this->system_halted($level)) // analyses error level
112
+    elseif ($this->system_halted($level)) // analyses error level
113 113
     {
114 114
       $display_error = sprintf(PHP_EOL.'%s in file %s:%d'.PHP_EOL.'%s', $level, \HexMakina\Debugger\Debugger::format_file($context['file']), $context['line'], $message);
115 115
       error_log($display_error);
116
-      $display_error.= \HexMakina\Debugger\Debugger::format_trace($context['trace'], false);
116
+      $display_error .= \HexMakina\Debugger\Debugger::format_trace($context['trace'], false);
117 117
       self::HTTP_500($display_error);
118 118
     }
119 119
     else
@@ -165,10 +165,10 @@  discard block
 block discarded – undo
165 165
   // ----------------------------------------------------------- User messages:add one
166 166
   public function report_to_user($level, $message, $context = [])
167 167
   {
168
-    if(!isset($_SESSION[self::REPORTING_USER]))
168
+    if (!isset($_SESSION[self::REPORTING_USER]))
169 169
       $_SESSION[self::REPORTING_USER] = [];
170 170
 
171
-    if(!isset($_SESSION[self::REPORTING_USER][$level]))
171
+    if (!isset($_SESSION[self::REPORTING_USER][$level]))
172 172
       $_SESSION[self::REPORTING_USER][$level] = [];
173 173
 
174 174
     $_SESSION[self::REPORTING_USER][$level][] = [$message, $context];
@@ -203,16 +203,16 @@  discard block
 block discarded – undo
203 203
   // }
204 204
 
205 205
   // ----------------------------------------------------------- CRUD Tracking:get for many models
206
-  public function changes($options=[])
206
+  public function changes($options = [])
207 207
   {
208 208
 
209
-    if(!isset($options['limit']) || empty($options['limit']))
209
+    if (!isset($options['limit']) || empty($options['limit']))
210 210
       $limit = 1000;
211 211
     else  $limit = intval($options['limit']);
212 212
 
213 213
     // TODO SELECT field order can't change without adapting the result parsing code (foreach $res)
214 214
     $table = Crudites::inspect(self::LOG_TABLE_NAME);
215
-    $select_fields = ['SUBSTR(query_on, 1, 10) AS working_day', 'query_table', 'query_id',  'GROUP_CONCAT(DISTINCT query_type, "-", query_by) as action_by'];
215
+    $select_fields = ['SUBSTR(query_on, 1, 10) AS working_day', 'query_table', 'query_id', 'GROUP_CONCAT(DISTINCT query_type, "-", query_by) as action_by'];
216 216
     $q = $table->select($select_fields);
217 217
     $q->order_by(['', 'working_day', 'DESC']);
218 218
     $q->order_by([self::LOG_TABLE_NAME, 'query_table', 'DESC']);
@@ -224,30 +224,30 @@  discard block
 block discarded – undo
224 224
     $q->having("action_by NOT LIKE '%D%'");
225 225
     $q->limit($limit);
226 226
 
227
-    foreach($options as $o => $v)
227
+    foreach ($options as $o => $v)
228 228
     {
229
-          if(preg_match('/id/', $o))                    $q->aw_eq('query_id', $v);
230
-      elseif(preg_match('/tables/', $o))                $q->aw_string_in('query_table', is_array($v) ? $v : [$v]);
231
-      elseif(preg_match('/table/', $o))                 $q->aw_eq('query_table', $v);
232
-      elseif(preg_match('/(type|action)/', $o))         $q->aw_string_in('query_type', is_array($v) ? $v : [$v]);
233
-      elseif(preg_match('/(date|query_on)/', $o))       $q->aw_like('query_on', "$v%");
234
-      elseif(preg_match('/(oper|user|query_by)/', $o))  $q->aw_eq('query_by', $v);
229
+          if (preg_match('/id/', $o))                    $q->aw_eq('query_id', $v);
230
+      elseif (preg_match('/tables/', $o))                $q->aw_string_in('query_table', is_array($v) ? $v : [$v]);
231
+      elseif (preg_match('/table/', $o))                 $q->aw_eq('query_table', $v);
232
+      elseif (preg_match('/(type|action)/', $o))         $q->aw_string_in('query_type', is_array($v) ? $v : [$v]);
233
+      elseif (preg_match('/(date|query_on)/', $o))       $q->aw_like('query_on', "$v%");
234
+      elseif (preg_match('/(oper|user|query_by)/', $o))  $q->aw_eq('query_by', $v);
235 235
     }
236 236
 
237
-    try{$q->run();}
238
-    catch(CruditesException $e){vdt($e);return false;}
237
+    try {$q->run(); }
238
+    catch (CruditesException $e) {vdt($e); return false; }
239 239
 
240 240
     $res = $q->ret_num(); // ret num to list()
241 241
     // ddt($res);
242 242
     $ret = [];
243 243
 
244
-    foreach($res as $r)
244
+    foreach ($res as $r)
245 245
     {
246 246
       list($working_day, $class, $instance_id, $logs) = $r;
247 247
 
248
-      if(!isset($ret[$working_day]))
248
+      if (!isset($ret[$working_day]))
249 249
         $ret[$working_day] = [];
250
-      if(!isset($ret[$working_day][$class]))
250
+      if (!isset($ret[$working_day][$class]))
251 251
         $ret[$working_day][$class] = [];
252 252
 
253 253
       $ret[$working_day][$class][$instance_id] = $logs;
@@ -269,21 +269,21 @@  discard block
 block discarded – undo
269 269
   private static function map_error_level_to_log_level($level) : string
270 270
   {
271 271
     // http://php.net/manual/en/errorfunc.constants.php
272
-    $m=[];
272
+    $m = [];
273 273
 
274
-    $m[E_ERROR]=$m[E_PARSE]=$m[E_CORE_ERROR]=$m[E_COMPILE_ERROR]=$m[E_USER_ERROR]=$m[E_RECOVERABLE_ERROR]=LogLevel::ALERT;
275
-    $m[1]=$m[4]=$m[16]=$m[64]=$m[256]=$m[4096]=LogLevel::ALERT;
274
+    $m[E_ERROR] = $m[E_PARSE] = $m[E_CORE_ERROR] = $m[E_COMPILE_ERROR] = $m[E_USER_ERROR] = $m[E_RECOVERABLE_ERROR] = LogLevel::ALERT;
275
+    $m[1] = $m[4] = $m[16] = $m[64] = $m[256] = $m[4096] = LogLevel::ALERT;
276 276
 
277
-    $m[E_WARNING]=$m[E_CORE_WARNING]=$m[E_COMPILE_WARNING]=$m[E_USER_WARNING]=LogLevel::CRITICAL;
278
-    $m[2]=$m[32]=$m[128]=$m[512]=LogLevel::CRITICAL;
277
+    $m[E_WARNING] = $m[E_CORE_WARNING] = $m[E_COMPILE_WARNING] = $m[E_USER_WARNING] = LogLevel::CRITICAL;
278
+    $m[2] = $m[32] = $m[128] = $m[512] = LogLevel::CRITICAL;
279 279
 
280
-    $m[E_NOTICE]=$m[E_USER_NOTICE]=LogLevel::ERROR;
281
-    $m[8]=$m[1024]=LogLevel::ERROR;
280
+    $m[E_NOTICE] = $m[E_USER_NOTICE] = LogLevel::ERROR;
281
+    $m[8] = $m[1024] = LogLevel::ERROR;
282 282
 
283
-    $m[E_STRICT]=$m[E_DEPRECATED]=$m[E_USER_DEPRECATED]=$m[E_ALL]=LogLevel::DEBUG;
284
-    $m[2048]=$m[8192]=$m[16384]=$m[32767]=LogLevel::DEBUG;
283
+    $m[E_STRICT] = $m[E_DEPRECATED] = $m[E_USER_DEPRECATED] = $m[E_ALL] = LogLevel::DEBUG;
284
+    $m[2048] = $m[8192] = $m[16384] = $m[32767] = LogLevel::DEBUG;
285 285
 
286
-    if(isset($m[$level]))
286
+    if (isset($m[$level]))
287 287
       return $m[$level];
288 288
 
289 289
     throw new \Exception(__FUNCTION__."($level): $level is unknown");
Please login to merge, or discard this patch.
Controllers/ORMController.class.php 2 patches
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -27,19 +27,19 @@  discard block
 block discarded – undo
27 27
     $custom_template = null;
28 28
     $method = $this->router()->target_method();
29 29
 
30
-    foreach(['prepare', "before_$method", $method, "after_$method"] as $step => $chainling)
30
+    foreach (['prepare', "before_$method", $method, "after_$method"] as $step => $chainling)
31 31
     {
32 32
       $this->search_and_execute_trait_methods($chainling);
33
-    	if(method_exists($this, $chainling) && empty($this->errors()))
33
+    	if (method_exists($this, $chainling) && empty($this->errors()))
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()) // logger handled a critical error during the chailing execution
38 38
         {
39 39
           break; // dont go on with other
40 40
         }
41 41
 
42
-        if($chainling === $method)
42
+        if ($chainling === $method)
43 43
         {
44 44
 
45 45
           $custom_template = $res;
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
       }
48 48
     }
49 49
 
50
-    if(method_exists($this, 'conclude')) // conclude always executed, even with has_halting_messages
50
+    if (method_exists($this, 'conclude')) // conclude always executed, even with has_halting_messages
51 51
     	$this->conclude();
52 52
 
53
-    if(method_exists($this, 'display'))
53
+    if (method_exists($this, 'display'))
54 54
     	$template = $this->display($custom_template);
55 55
   }
56 56
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
   {
59 59
     parent::prepare();
60 60
 
61
-    if(!class_exists($this->model_class_name = $this->class_name()))
61
+    if (!class_exists($this->model_class_name = $this->class_name()))
62 62
       throw new \Exception("!class_exists($this->model_class_name)");
63 63
 
64 64
     $this->model_type = $this->model_class_name::model_type();
@@ -68,22 +68,22 @@  discard block
 block discarded – undo
68 68
 
69 69
     $pk_values = [];
70 70
 
71
-    if($this->router()->submits())
71
+    if ($this->router()->submits())
72 72
     {
73 73
       $this->form_model->import($this->sanitize_post_data($this->router()->submitted()));
74 74
       $pk_values = $this->model_class_name::table()->primary_keys_match($this->router()->submitted());
75 75
 
76 76
       $this->load_model = $this->model_class_name::exists($pk_values);
77 77
     }
78
-    elseif($this->router()->requests())
78
+    elseif ($this->router()->requests())
79 79
     {
80 80
       $pk_values = $this->model_class_name::table()->primary_keys_match($this->router()->params());
81 81
 
82
-      if(!is_null($this->load_model = $this->model_class_name::exists($pk_values)))
82
+      if (!is_null($this->load_model = $this->model_class_name::exists($pk_values)))
83 83
         $this->form_model = clone $this->load_model;
84 84
     }
85 85
 
86
-    if(!is_null($this->load_model) && $this->load_model->traceable())
86
+    if (!is_null($this->load_model) && $this->load_model->traceable())
87 87
       $this->viewport('load_model_history', $this->load_model->traces() ?? []);
88 88
   }
89 89
 
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
   // ----------- META -----------
95 95
   public function class_name() : string
96 96
   {
97
-    if(is_null($this->model_class_name))
97
+    if (is_null($this->model_class_name))
98 98
     {
99 99
       $this->model_class_name = get_called_class();
100 100
       $this->model_class_name = str_replace('\Controllers\\', '\Models\\', $this->model_class_name);
@@ -107,12 +107,12 @@  discard block
 block discarded – undo
107 107
   public function persist_model($model) : ?ModelInterface
108 108
   {
109 109
     $this->errors = $model->save($this->operator()->operator_id()); // returns [errors]
110
-    if(empty($this->errors()))
110
+    if (empty($this->errors()))
111 111
     {
112 112
       $this->logger()->nice('CRUDITES_INSTANCE_ALTERED', ['MODEL_'.get_class($model)::model_type().'_INSTANCE']);
113 113
       return $model;
114 114
     }
115
-    foreach($this->errors() as $field => $error_msg)
115
+    foreach ($this->errors() as $field => $error_msg)
116 116
       $this->logger()->warning($error_msg, [$field]);
117 117
 
118 118
     return null;
@@ -123,12 +123,12 @@  discard block
 block discarded – undo
123 123
     return $this->listing(); //default dashboard is a listing
124 124
   }
125 125
 
126
-  public function listing($model=null,$filters=[],$options=[])
126
+  public function listing($model = null, $filters = [], $options = [])
127 127
   {
128 128
     $class_name = is_null($model) ? $this->model_class_name : get_class($model);
129 129
 
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');
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');
132 132
 
133 133
     // dd($filters);
134 134
     $listing = $class_name::filter($filters);
@@ -139,24 +139,24 @@  discard block
 block discarded – undo
139 139
   public function viewport_listing($class_name, $listing, $listing_template)
140 140
   {
141 141
     $listing_fields = [];
142
-    if(empty($listing))
142
+    if (empty($listing))
143 143
     {
144
-      foreach($class_name::table()->columns() as $column)
144
+      foreach ($class_name::table()->columns() as $column)
145 145
       {
146 146
 
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()));
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()));
149 149
       }
150 150
     }
151 151
     else
152 152
     {
153 153
       $current = current($listing);
154
-      if(is_object($current))
154
+      if (is_object($current))
155 155
         $current = get_object_vars($current);
156 156
 
157
-      foreach(array_keys($current) as $field)
157
+      foreach (array_keys($current) as $field)
158 158
       {
159
-        $listing_fields[$field]=L(sprintf('MODEL_%s_FIELD_%s', $class_name::model_type(), $field));
159
+        $listing_fields[$field] = L(sprintf('MODEL_%s_FIELD_%s', $class_name::model_type(), $field));
160 160
       }
161 161
 
162 162
     }
@@ -178,13 +178,13 @@  discard block
 block discarded – undo
178 178
     $this->edit();
179 179
   }
180 180
 
181
-  public function edit(){}
181
+  public function edit() {}
182 182
 
183 183
   public function save()
184 184
   {
185 185
     $model = $this->persist_model($this->form_model);
186 186
 
187
-    if(empty($this->errors()))
187
+    if (empty($this->errors()))
188 188
       $this->route_back($model);
189 189
     else
190 190
     {
@@ -195,21 +195,21 @@  discard block
 block discarded – undo
195 195
 
196 196
   public function before_edit()
197 197
   {
198
-    if(!is_null($this->router()->params('id')) && is_null($this->load_model))
198
+    if (!is_null($this->router()->params('id')) && is_null($this->load_model))
199 199
     {
200 200
       $this->logger()->warning('CRUDITES_ERR_INSTANCE_NOT_FOUND', ['MODEL_'.$this->model_class_name::model_type().'_INSTANCE']);
201 201
       $this->router()->hop($this->model_class_name::model_type());
202 202
     }
203 203
   }
204 204
 
205
-  public function before_save() : array { return [];}
205
+  public function before_save() : array { return []; }
206 206
 
207 207
   // default: hop to altered object
208
-  public function after_save() {$this->router()->hop($this->route_back());}
208
+  public function after_save() {$this->router()->hop($this->route_back()); }
209 209
 
210 210
   public function destroy_confirm()
211 211
   {
212
-    if(is_null($this->load_model))
212
+    if (is_null($this->load_model))
213 213
     {
214 214
       $this->logger()->warning('CRUDITES_ERR_INSTANCE_NOT_FOUND', ['MODEL_'.$this->model_type.'_INSTANCE']);
215 215
       $this->router()->hop($this->model_type);
@@ -222,12 +222,12 @@  discard block
 block discarded – undo
222 222
 
223 223
   public function before_destroy() // default: checks for load_model and immortality, hops back to object on failure
224 224
   {
225
-    if(is_null($this->load_model))
225
+    if (is_null($this->load_model))
226 226
     {
227 227
       $this->logger()->warning('CRUDITES_ERR_INSTANCE_NOT_FOUND', ['MODEL_'.$this->model_type.'_INSTANCE']);
228 228
       $this->router()->hop($this->model_type);
229 229
     }
230
-    elseif($this->load_model->immortal())
230
+    elseif ($this->load_model->immortal())
231 231
     {
232 232
 
233 233
       $this->logger()->warning('CRUDITES_ERR_INSTANCE_IS_IMMORTAL', ['MODEL_'.$this->model_type.'_INSTANCE']);
@@ -237,10 +237,10 @@  discard block
 block discarded – undo
237 237
 
238 238
   public function destroy()
239 239
   {
240
-    if(!$this->router()->submits())
240
+    if (!$this->router()->submits())
241 241
       throw new \Exception('KADRO_ROUTER_MUST_SUBMIT');
242 242
 
243
-    if($this->load_model->destroy($this->operator()->operator_id()) === false)
243
+    if ($this->load_model->destroy($this->operator()->operator_id()) === false)
244 244
     {
245 245
       $this->logger()->info('CRUDITES_ERR_INSTANCE_IS_UNDELETABLE', [''.$this->load_model]);
246 246
       $this->route_back($this->load_model);
@@ -263,10 +263,10 @@  discard block
 block discarded – undo
263 263
 
264 264
     $this->viewport('form_model_type', $this->model_type);
265 265
 
266
-    if(isset($this->load_model))
266
+    if (isset($this->load_model))
267 267
       $this->viewport('load_model', $this->load_model);
268 268
 
269
-    if(isset($this->form_model))
269
+    if (isset($this->form_model))
270 270
       $this->viewport('form_model', $this->form_model);
271 271
   }
272 272
 
@@ -278,15 +278,15 @@  discard block
 block discarded – undo
278 278
 
279 279
     $header = false;
280 280
 
281
-    foreach($collection as $line)
281
+    foreach ($collection as $line)
282 282
     {
283 283
       $line = get_object_vars($line);
284
-      if($header === false)
284
+      if ($header === false)
285 285
       {
286
-        fputcsv($fp,array_keys($line));
286
+        fputcsv($fp, array_keys($line));
287 287
         $header = true;
288 288
       }
289
-      fputcsv($fp,$line);
289
+      fputcsv($fp, $line);
290 290
     }
291 291
     fclose($fp);
292 292
 
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
   public function export()
297 297
   {
298 298
     $format = $this->router()->params('format');
299
-    switch($format)
299
+    switch ($format)
300 300
     {
301 301
       case null:
302 302
         $filename = $this->model_type;
@@ -325,33 +325,33 @@  discard block
 block discarded – undo
325 325
     $route_params = [];
326 326
 
327 327
     $route_name = get_class($model)::model_type().'_';
328
-    if($model->is_new())
329
-      $route_name.= 'new';
328
+    if ($model->is_new())
329
+      $route_name .= 'new';
330 330
     else
331 331
     {
332
-      $route_name.= 'default';
332
+      $route_name .= 'default';
333 333
       $route_params = ['id' => $model->get_id()];
334 334
     }
335 335
     $res = $this->router()->prehop($route_name, $route_params);
336 336
     return $res;
337 337
   }
338 338
 
339
-  public function route_factory($route=null, $route_params=[]) : string
339
+  public function route_factory($route = null, $route_params = []) : string
340 340
   {
341
-    if(is_null($route) && $this->router()->submits())
341
+    if (is_null($route) && $this->router()->submits())
342 342
       $route = $this->form_model;
343 343
 
344
-    if(!is_null($route) && is_subclass_of($route, '\HexMakina\Crudites\Interfaces\ModelInterface'))
344
+    if (!is_null($route) && is_subclass_of($route, '\HexMakina\Crudites\Interfaces\ModelInterface'))
345 345
       $route = $this->route_model($route);
346 346
 
347 347
     return parent::route_factory($route, $route_params);
348 348
   }
349 349
 
350
-  private function sanitize_post_data($post_data=[])
350
+  private function sanitize_post_data($post_data = [])
351 351
   {
352
-    foreach($this->model_class_name::table()->columns() as $col)
352
+    foreach ($this->model_class_name::table()->columns() as $col)
353 353
     {
354
-      if($col->type()->is_boolean())
354
+      if ($col->type()->is_boolean())
355 355
       {
356 356
           $post_data[$col->name()] = !empty($post_data[$col->name()]);
357 357
       }
Please login to merge, or discard this 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 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  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'))
15
+    if (!is_subclass_of($file_manageable_model, '\HexMakina\Crudites\TightModel'))
16 16
       throw new \Exception("__construct($file_manageable_model) // only Model items are manageable");
17 17
 
18 18
     $this->pmi = $file_manageable_model;
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
   public function download($url)
33 33
   {
34 34
     $filename = $this->build_filename();
35
-    $filename .= '.' . pathinfo($url, PATHINFO_EXTENSION);
35
+    $filename .= '.'.pathinfo($url, PATHINFO_EXTENSION);
36 36
 
37 37
     $filepath = $this->build_path_to_file($filename);
38 38
 
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
     return $this->pmi->get_id().'/';  
59 59
 
60 60
     $pmi_model_type = get_class($this->pmi)::model_type();
61
-    if(!isset($this->pmi) || is_null($this->get_type()))
61
+    if (!isset($this->pmi) || is_null($this->get_type()))
62 62
       throw new \Exception(__FUNCTION__." // undefined manageable item or picture type");
63 63
 
64
-    if(!isset($settings[$pmi_model_type][$this->get_type()]['import_directory']))
64
+    if (!isset($settings[$pmi_model_type][$this->get_type()]['import_directory']))
65 65
       throw new \Exception(__FUNCTION__." // undefined configuration for '".($pmi_model_type)."'>'".$this->get_type()."'>'import_directory'");
66 66
     
67 67
     // global $settings;
Please login to merge, or discard this 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.
Auth/ACL.class.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -18,14 +18,14 @@  discard block
 block discarded – undo
18 18
     return in_array($permission_name, self::permissions_names_for($op));
19 19
   }
20 20
 
21
-  public static function query_retrieve($filters=[], $options=[]) : Select
21
+  public static function query_retrieve($filters = [], $options = []) : Select
22 22
   {
23 23
     $options['eager'] = false;
24
-    $ret = parent::query_retrieve($filters,$options);
24
+    $ret = parent::query_retrieve($filters, $options);
25 25
     $eager_params = [];
26
-    $eager_params[Permission::table_name()]=Permission::table_alias();
27
-    $eager_params[Operator::table_name()]=Operator::table_alias();
28
-    $eager_params[ACL::table_name()]=ACL::table_alias();
26
+    $eager_params[Permission::table_name()] = Permission::table_alias();
27
+    $eager_params[Operator::table_name()] = Operator::table_alias();
28
+    $eager_params[ACL::table_name()] = ACL::table_alias();
29 29
 
30 30
     $ret->eager($eager_params);
31 31
 
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
     $res = self::any(['operator_id'=>$op->get_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
     $ret = Permission::filter(['ids'=>$permission_ids]);
44 44
     return $ret;
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
   {
48 48
     $operator_with_perms = get_class($op)::exists($op->operator_id());
49 49
     // $operator_with_perms = get_class($op)::retrieve($operator_with_perms);
50
-    if(is_null($operator_with_perms))
50
+    if (is_null($operator_with_perms))
51 51
       return [];
52 52
 
53
-    return explode(',',$operator_with_perms->get('permission_names'));
53
+    return explode(',', $operator_with_perms->get('permission_names'));
54 54
   }
55 55
 
56 56
   public static function allow_in(OperatorInterface $op, Permission $p)
Please login to merge, or discard this patch.
Auth/Operator.class.php 2 patches
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@  discard block
 block discarded – undo
12 12
 
13 13
   use Permissionability;
14 14
 
15
-	public function __toString()
15
+  public function __toString()
16 16
   {
17 17
     return $this->get('username');
18 18
   }
19 19
 
20
-	public function is_active() : bool
20
+  public function is_active() : bool
21 21
   {
22 22
     return !empty($this->get('active'));
23 23
   }
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
   }
39 39
 
40 40
   public function password_change($string)
41
-	{
42
-		$this->password = password_hash($string, PASSWORD_DEFAULT);
43
-	}
41
+  {
42
+    $this->password = password_hash($string, PASSWORD_DEFAULT);
43
+  }
44 44
 
45
-	public function password_verify($string) : bool
46
-	{
47
-		return password_verify($string, $this->password());
48
-	}
45
+  public function password_verify($string) : bool
46
+  {
47
+    return password_verify($string, $this->password());
48
+  }
49 49
 
50 50
   public function name()
51 51
   {
@@ -61,39 +61,39 @@  discard block
 block discarded – undo
61 61
     return $this->get('phone');
62 62
   }
63 63
 
64
-	public function language_code()
64
+  public function language_code()
65 65
   {
66 66
     return $this->get('language_code');
67 67
   }
68 68
 
69
-	public static function query_retrieve($filters=[], $options=[]) : Select
70
-	{
71
-		$Query = static::table()->select();
72
-  	if(isset($options['eager']) && $options['eager'] === true)
73
-		{
69
+  public static function query_retrieve($filters=[], $options=[]) : Select
70
+  {
71
+    $Query = static::table()->select();
72
+    if(isset($options['eager']) && $options['eager'] === true)
73
+    {
74 74
       $Query->group_by('id');
75 75
 
76 76
       $Query->auto_join([ACL::table(), 'acl'], null, 'LEFT OUTER');
77 77
       $Query->auto_join([Permission::table(), 'kadro_permission'], null, 'LEFT OUTER');
78
-			$Query->select_also(["GROUP_CONCAT(DISTINCT kadro_permission.id) as permission_ids", "GROUP_CONCAT(DISTINCT kadro_permission.name) as permission_names"]);
79
-		}
78
+      $Query->select_also(["GROUP_CONCAT(DISTINCT kadro_permission.id) as permission_ids", "GROUP_CONCAT(DISTINCT kadro_permission.name) as permission_names"]);
79
+    }
80 80
 
81
-		if(isset($filters['model']) && !empty($filters['model']))
82
-		{
83
-			$model = $filters['model'];
84
-			$Query->join([static::otm('t'), static::otm('a')],[[static::otm('a'),static::otm('k'), 't_from','id']], 'INNER');
85
-			$Query->aw_fields_eq(['model_id' => $filters['model']->get_id(), 'model_type' => get_class($filters['model'])::model_type()], static::otm('a'));
86
-		}
81
+    if(isset($filters['model']) && !empty($filters['model']))
82
+    {
83
+      $model = $filters['model'];
84
+      $Query->join([static::otm('t'), static::otm('a')],[[static::otm('a'),static::otm('k'), 't_from','id']], 'INNER');
85
+      $Query->aw_fields_eq(['model_id' => $filters['model']->get_id(), 'model_type' => get_class($filters['model'])::model_type()], static::otm('a'));
86
+    }
87 87
 
88 88
     $Query->order_by([$Query->table_label(), 'name', 'ASC']);
89 89
 
90 90
 
91
-		return $Query;
92
-	}
91
+    return $Query;
92
+  }
93 93
 
94
-	public function immortal() : bool
95
-	{
96
-		return true; // never delete a user, always deactivate
97
-	}
94
+  public function immortal() : bool
95
+  {
96
+    return true; // never delete a user, always deactivate
97
+  }
98 98
 }
99 99
 ?>
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
     return $this->get('language_code');
67 67
   }
68 68
 
69
-	public static function query_retrieve($filters=[], $options=[]) : Select
69
+	public static function query_retrieve($filters = [], $options = []) : Select
70 70
 	{
71 71
 		$Query = static::table()->select();
72
-  	if(isset($options['eager']) && $options['eager'] === true)
72
+  	if (isset($options['eager']) && $options['eager'] === true)
73 73
 		{
74 74
       $Query->group_by('id');
75 75
 
@@ -78,10 +78,10 @@  discard block
 block discarded – undo
78 78
 			$Query->select_also(["GROUP_CONCAT(DISTINCT kadro_permission.id) as permission_ids", "GROUP_CONCAT(DISTINCT kadro_permission.name) as permission_names"]);
79 79
 		}
80 80
 
81
-		if(isset($filters['model']) && !empty($filters['model']))
81
+		if (isset($filters['model']) && !empty($filters['model']))
82 82
 		{
83 83
 			$model = $filters['model'];
84
-			$Query->join([static::otm('t'), static::otm('a')],[[static::otm('a'),static::otm('k'), 't_from','id']], 'INNER');
84
+			$Query->join([static::otm('t'), static::otm('a')], [[static::otm('a'), static::otm('k'), 't_from', 'id']], 'INNER');
85 85
 			$Query->aw_fields_eq(['model_id' => $filters['model']->get_id(), 'model_type' => get_class($filters['model'])::model_type()], static::otm('a'));
86 86
 		}
87 87
 
Please login to merge, or discard this patch.
TableToForm.class.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -3,26 +3,26 @@  discard block
 block discarded – undo
3 3
 namespace HexMakina\kadro;
4 4
 
5 5
 use \HexMakina\Crudites\Interfaces\ModelInterface;
6
-use \HexMakina\Format\HTML\{Form,Element};
6
+use \HexMakina\Format\HTML\{Form, Element};
7 7
 
8 8
 class TableToForm
9 9
 {
10
-  private static function compute_field_value($model,$field_name)
10
+  private static function compute_field_value($model, $field_name)
11 11
   {
12
-    if(method_exists($model,$field_name))
12
+    if (method_exists($model, $field_name))
13 13
       return $model->$field_name();
14 14
 
15
-    if(property_exists($model,$field_name))
15
+    if (property_exists($model, $field_name))
16 16
       return $model->$field_name;
17 17
 
18 18
     return '';
19 19
   }
20 20
 
21
-  public static function label($model,$field_name,$attributes=[],$errors=[])
21
+  public static function label($model, $field_name, $attributes = [], $errors = [])
22 22
   {
23 23
     $label_content = $field_name;
24 24
 
25
-    if(isset($attributes['label']))
25
+    if (isset($attributes['label']))
26 26
     {
27 27
       $label_content = $attributes['label'];
28 28
       unset($attributes['label']);
@@ -44,66 +44,66 @@  discard block
 block discarded – undo
44 44
     return $ret;
45 45
   }
46 46
 
47
-  public static function field(ModelInterface $model,$field_name,$attributes=[],$errors=[]) : string
47
+  public static function field(ModelInterface $model, $field_name, $attributes = [], $errors = []) : string
48 48
   {
49
-    $field_value = $attributes['value'] ?? self::compute_field_value($model,$field_name);
49
+    $field_value = $attributes['value'] ?? self::compute_field_value($model, $field_name);
50 50
     $attributes['name'] = $attributes['name'] ?? $field_name;
51 51
 
52 52
     $table = get_class($model)::table();
53 53
 
54
-    if(is_null($table->column($field_name)))
55
-      return Form::input($field_name,$field_value,$attributes,$errors);
54
+    if (is_null($table->column($field_name)))
55
+      return Form::input($field_name, $field_value, $attributes, $errors);
56 56
 
57 57
     $ret = '';
58 58
 
59 59
     $field = $table->column($field_name);
60 60
 
61 61
 
62
-    if(isset($attributes['required']) && $attributes['required'] === false)
62
+    if (isset($attributes['required']) && $attributes['required'] === false)
63 63
       unset($attributes['required']);
64 64
 
65
-    elseif(!$field->is_nullable())
65
+    elseif (!$field->is_nullable())
66 66
       $attributes[] = 'required';
67 67
 
68
-    if($field->is_auto_incremented())
68
+    if ($field->is_auto_incremented())
69 69
     {
70
-      $ret .= Form::hidden($field->name(),$field_value);
70
+      $ret .= Form::hidden($field->name(), $field_value);
71 71
     }
72
-    elseif($field->type()->is_boolean())
72
+    elseif ($field->type()->is_boolean())
73 73
     {
74 74
       $option_list = $attributes['values'] ?? [0 => 0, 1 => 1];
75
-      $ret .= Form::select($field->name(), $option_list ,$field_value, $attributes); //
75
+      $ret .= Form::select($field->name(), $option_list, $field_value, $attributes); //
76 76
     }
77
-    elseif($field->type()->is_integer())
77
+    elseif ($field->type()->is_integer())
78 78
     {
79
-      $ret .= Form::input($field->name(),$field_value,$attributes,$errors);
79
+      $ret .= Form::input($field->name(), $field_value, $attributes, $errors);
80 80
     }
81
-    elseif($field->type()->is_year())
81
+    elseif ($field->type()->is_year())
82 82
     {
83 83
       $attributes['size'] = $attributes['maxlength'] = 4;
84
-      $ret .= Form::input($field->name(),$field_value,$attributes,$errors);
84
+      $ret .= Form::input($field->name(), $field_value, $attributes, $errors);
85 85
     }
86
-    elseif($field->type()->is_date())
86
+    elseif ($field->type()->is_date())
87 87
     {
88
-      $ret .= Form::date($field->name(),$field_value,$attributes,$errors);
88
+      $ret .= Form::date($field->name(), $field_value, $attributes, $errors);
89 89
     }
90
-    elseif($field->type()->is_time())
90
+    elseif ($field->type()->is_time())
91 91
     {
92
-      $ret .= Form::time($field->name(),$field_value,$attributes,$errors);
92
+      $ret .= Form::time($field->name(), $field_value, $attributes, $errors);
93 93
     }
94
-    elseif($field->type()->is_datetime())
94
+    elseif ($field->type()->is_datetime())
95 95
     {
96
-      $ret .= Form::datetime($field->name(),$field_value,$attributes,$errors);
96
+      $ret .= Form::datetime($field->name(), $field_value, $attributes, $errors);
97 97
     }
98
-    elseif($field->type()->is_text())
98
+    elseif ($field->type()->is_text())
99 99
     {
100
-      $ret .= Form::textarea($field->name(),$field_value,$attributes,$errors);
100
+      $ret .= Form::textarea($field->name(), $field_value, $attributes, $errors);
101 101
     }
102
-    elseif($field->type()->is_enum())
102
+    elseif ($field->type()->is_enum())
103 103
     {
104 104
 
105 105
       $enum_values = [];
106
-      foreach($field->type()->enum_values() as $e_val)
106
+      foreach ($field->type()->enum_values() as $e_val)
107 107
         $enum_values[$e_val] = $e_val;
108 108
 
109 109
       $selected = $attributes['value'] ?? $field_value ?? '';
@@ -112,50 +112,50 @@  discard block
 block discarded – undo
112 112
 
113 113
       // throw new \Exception('ENUM IS NOT HANDLED BY TableToFom');
114 114
     }
115
-    elseif($field->type()->is_string())
115
+    elseif ($field->type()->is_string())
116 116
     {
117 117
       $max_length = $field->type()->length();
118 118
       $attributes['size'] = $attributes['maxlength'] = $max_length;
119
-      $ret .= Form::input($field->name(),$field_value,$attributes,$errors);
119
+      $ret .= Form::input($field->name(), $field_value, $attributes, $errors);
120 120
     }
121 121
     else
122 122
     {
123
-      $ret .= Form::input($field->name(),$field_value,$attributes,$errors);
123
+      $ret .= Form::input($field->name(), $field_value, $attributes, $errors);
124 124
     }
125 125
 
126 126
 
127 127
     return $ret;
128 128
   }
129 129
 
130
-  public static function field_with_label($model,$field_name,$attributes=[],$errors=[]) : string
130
+  public static function field_with_label($model, $field_name, $attributes = [], $errors = []) : string
131 131
   {
132 132
     $field_attributes = $attributes;
133
-    if(isset($attributes['label']))
133
+    if (isset($attributes['label']))
134 134
       unset($field_attributes['label']);
135 135
 
136
-    return sprintf('%s %s', self::label($model,$field_name,$attributes,$errors), self::field($model,$field_name,$field_attributes,$errors));
136
+    return sprintf('%s %s', self::label($model, $field_name, $attributes, $errors), self::field($model, $field_name, $field_attributes, $errors));
137 137
   }
138 138
 
139 139
 
140
-  public static function fields(ModelInterface $model,$group_class=null) : string
140
+  public static function fields(ModelInterface $model, $group_class = null) : string
141 141
   {
142 142
     $table = get_class($model)::table();
143 143
     $ret = '';
144
-    foreach($table->columns() as $column_name => $column)
144
+    foreach ($table->columns() as $column_name => $column)
145 145
     {
146 146
       // vd($column_name);
147 147
 
148 148
       $form_field = '';
149
-      if($column->is_auto_incremented())
149
+      if ($column->is_auto_incremented())
150 150
       {
151
-        if(!$model->is_new())
152
-          $form_field = self::field($model,$column_name);
151
+        if (!$model->is_new())
152
+          $form_field = self::field($model, $column_name);
153 153
       }
154 154
       else
155 155
       {
156
-        $form_field = self::field_with_label($model,$column_name);
157
-        if(!is_null($group_class))
158
-          $form_field = new Element('div',$form_field, ['class' => $group_class]);
156
+        $form_field = self::field_with_label($model, $column_name);
157
+        if (!is_null($group_class))
158
+          $form_field = new Element('div', $form_field, ['class' => $group_class]);
159 159
       }
160 160
       $ret .= PHP_EOL.$form_field;
161 161
     }
Please login to merge, or discard this patch.
Models/Traduko.class.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
     return false;
21 21
   }
22 22
   
23
-  public static function query_retrieve($filters=[], $options=[]) : Select
23
+  public static function query_retrieve($filters = [], $options = []) : Select
24 24
   {
25 25
     $Query = static::table()->select();
26 26
     $Query->order_by(['kategorio', 'ASC']);
Please login to merge, or discard this patch.