@@ -30,7 +30,7 @@ discard block |
||
30 | 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 | |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | if(method_exists($this, 'conclude')) // conclude always executed, even with has_halting_messages |
51 | - $this->conclude(); |
|
51 | + $this->conclude(); |
|
52 | 52 | |
53 | 53 | if(method_exists($this, 'display')) |
54 | - $this->display($custom_template); // ret value ignored.. |
|
54 | + $this->display($custom_template); // ret value ignored.. |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | public function prepare() |
@@ -27,19 +27,19 @@ discard block |
||
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 |
||
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 | $this->display($custom_template); // ret value ignored.. |
55 | 55 | } |
56 | 56 | |
@@ -58,7 +58,7 @@ discard block |
||
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 |
||
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) && is_subclass_of($this->load_model, '\HexMakina\Crudites\Interfaces\TraceableInterface') && $this->load_model->traceable()) |
|
86 | + if (!is_null($this->load_model) && is_subclass_of($this->load_model, '\HexMakina\Crudites\Interfaces\TraceableInterface') && $this->load_model->traceable()) |
|
87 | 87 | { |
88 | 88 | // $traces = $this->tracer()->traces_by_model($this->load_model); |
89 | 89 | $traces = $this->tracer()->history_by_model($this->load_model); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | // ----------- META ----------- |
100 | 100 | public function class_name() : string |
101 | 101 | { |
102 | - if(is_null($this->model_class_name)) |
|
102 | + if (is_null($this->model_class_name)) |
|
103 | 103 | { |
104 | 104 | $this->model_class_name = get_called_class(); |
105 | 105 | $this->model_class_name = str_replace('\Controllers\\', '\Models\\', $this->model_class_name); |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | public function persist_model($model) : ?ModelInterface |
113 | 113 | { |
114 | 114 | $this->errors = $model->save($this->operator()->operator_id(), $this->tracer()); // returns [errors] |
115 | - if(empty($this->errors())) |
|
115 | + if (empty($this->errors())) |
|
116 | 116 | { |
117 | 117 | $this->logger()->nice(L('CRUDITES_INSTANCE_ALTERED', [L('MODEL_'.get_class($model)::model_type().'_INSTANCE')])); |
118 | 118 | return $model; |
119 | 119 | } |
120 | - foreach($this->errors() as $field => $error_msg) |
|
120 | + foreach ($this->errors() as $field => $error_msg) |
|
121 | 121 | $this->logger()->warning(L($error_msg, [$field])); |
122 | 122 | |
123 | 123 | return null; |
@@ -128,12 +128,12 @@ discard block |
||
128 | 128 | return $this->listing(); //default dashboard is a listing |
129 | 129 | } |
130 | 130 | |
131 | - public function listing($model=null,$filters=[],$options=[]) |
|
131 | + public function listing($model = null, $filters = [], $options = []) |
|
132 | 132 | { |
133 | 133 | $class_name = is_null($model) ? $this->model_class_name : get_class($model); |
134 | 134 | |
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'); |
|
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'); |
|
137 | 137 | |
138 | 138 | // dd($filters); |
139 | 139 | $listing = $class_name::filter($filters); |
@@ -144,24 +144,24 @@ discard block |
||
144 | 144 | public function viewport_listing($class_name, $listing, $listing_template) |
145 | 145 | { |
146 | 146 | $listing_fields = []; |
147 | - if(empty($listing)) |
|
147 | + if (empty($listing)) |
|
148 | 148 | { |
149 | - foreach($class_name::table()->columns() as $column) |
|
149 | + foreach ($class_name::table()->columns() as $column) |
|
150 | 150 | { |
151 | 151 | |
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())); |
|
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())); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | else |
157 | 157 | { |
158 | 158 | $current = current($listing); |
159 | - if(is_object($current)) |
|
159 | + if (is_object($current)) |
|
160 | 160 | $current = get_object_vars($current); |
161 | 161 | |
162 | - foreach(array_keys($current) as $field) |
|
162 | + foreach (array_keys($current) as $field) |
|
163 | 163 | { |
164 | - $listing_fields[$field]=L(sprintf('MODEL_%s_FIELD_%s', $class_name::model_type(), $field)); |
|
164 | + $listing_fields[$field] = L(sprintf('MODEL_%s_FIELD_%s', $class_name::model_type(), $field)); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | } |
@@ -183,13 +183,13 @@ discard block |
||
183 | 183 | $this->edit(); |
184 | 184 | } |
185 | 185 | |
186 | - public function edit(){} |
|
186 | + public function edit() {} |
|
187 | 187 | |
188 | 188 | public function save() |
189 | 189 | { |
190 | 190 | $model = $this->persist_model($this->form_model); |
191 | 191 | |
192 | - if(empty($this->errors())) |
|
192 | + if (empty($this->errors())) |
|
193 | 193 | $this->route_back($model); |
194 | 194 | else |
195 | 195 | { |
@@ -200,21 +200,21 @@ discard block |
||
200 | 200 | |
201 | 201 | public function before_edit() |
202 | 202 | { |
203 | - if(!is_null($this->router()->params('id')) && is_null($this->load_model)) |
|
203 | + if (!is_null($this->router()->params('id')) && is_null($this->load_model)) |
|
204 | 204 | { |
205 | 205 | $this->logger()->warning(L('CRUDITES_ERR_INSTANCE_NOT_FOUND', [L('MODEL_'.$this->model_class_name::model_type().'_INSTANCE')])); |
206 | 206 | $this->router()->hop($this->model_class_name::model_type()); |
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
210 | - public function before_save() : array { return [];} |
|
210 | + public function before_save() : array { return []; } |
|
211 | 211 | |
212 | 212 | // default: hop to altered object |
213 | - public function after_save() {$this->router()->hop($this->route_back());} |
|
213 | + public function after_save() {$this->router()->hop($this->route_back()); } |
|
214 | 214 | |
215 | 215 | public function destroy_confirm() |
216 | 216 | { |
217 | - if(is_null($this->load_model)) |
|
217 | + if (is_null($this->load_model)) |
|
218 | 218 | { |
219 | 219 | $this->logger()->warning(L('CRUDITES_ERR_INSTANCE_NOT_FOUND', [L('MODEL_'.$this->model_type.'_INSTANCE')])); |
220 | 220 | $this->router()->hop($this->model_type); |
@@ -227,12 +227,12 @@ discard block |
||
227 | 227 | |
228 | 228 | public function before_destroy() // default: checks for load_model and immortality, hops back to object on failure |
229 | 229 | { |
230 | - if(is_null($this->load_model)) |
|
230 | + if (is_null($this->load_model)) |
|
231 | 231 | { |
232 | 232 | $this->logger()->warning(L('CRUDITES_ERR_INSTANCE_NOT_FOUND', [L('MODEL_'.$this->model_type.'_INSTANCE')])); |
233 | 233 | $this->router()->hop($this->model_type); |
234 | 234 | } |
235 | - elseif($this->load_model->immortal()) |
|
235 | + elseif ($this->load_model->immortal()) |
|
236 | 236 | { |
237 | 237 | |
238 | 238 | $this->logger()->warning(L('CRUDITES_ERR_INSTANCE_IS_IMMORTAL', [L('MODEL_'.$this->model_type.'_INSTANCE')])); |
@@ -242,10 +242,10 @@ discard block |
||
242 | 242 | |
243 | 243 | public function destroy() |
244 | 244 | { |
245 | - if(!$this->router()->submits()) |
|
245 | + if (!$this->router()->submits()) |
|
246 | 246 | throw new \Exception('KADRO_ROUTER_MUST_SUBMIT'); |
247 | 247 | |
248 | - if($this->load_model->destroy($this->operator()->operator_id(), $this->tracer()) === false) |
|
248 | + if ($this->load_model->destroy($this->operator()->operator_id(), $this->tracer()) === false) |
|
249 | 249 | { |
250 | 250 | $this->logger()->info(L('CRUDITES_ERR_INSTANCE_IS_UNDELETABLE', [''.$this->load_model])); |
251 | 251 | $this->route_back($this->load_model); |
@@ -268,10 +268,10 @@ discard block |
||
268 | 268 | |
269 | 269 | $this->viewport('form_model_type', $this->model_type); |
270 | 270 | |
271 | - if(isset($this->load_model)) |
|
271 | + if (isset($this->load_model)) |
|
272 | 272 | $this->viewport('load_model', $this->load_model); |
273 | 273 | |
274 | - if(isset($this->form_model)) |
|
274 | + if (isset($this->form_model)) |
|
275 | 275 | $this->viewport('form_model', $this->form_model); |
276 | 276 | } |
277 | 277 | |
@@ -283,15 +283,15 @@ discard block |
||
283 | 283 | |
284 | 284 | $header = false; |
285 | 285 | |
286 | - foreach($collection as $line) |
|
286 | + foreach ($collection as $line) |
|
287 | 287 | { |
288 | 288 | $line = get_object_vars($line); |
289 | - if($header === false) |
|
289 | + if ($header === false) |
|
290 | 290 | { |
291 | - fputcsv($fp,array_keys($line)); |
|
291 | + fputcsv($fp, array_keys($line)); |
|
292 | 292 | $header = true; |
293 | 293 | } |
294 | - fputcsv($fp,$line); |
|
294 | + fputcsv($fp, $line); |
|
295 | 295 | } |
296 | 296 | fclose($fp); |
297 | 297 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | public function export() |
302 | 302 | { |
303 | 303 | $format = $this->router()->params('format'); |
304 | - switch($format) |
|
304 | + switch ($format) |
|
305 | 305 | { |
306 | 306 | case null: |
307 | 307 | $filename = $this->model_type; |
@@ -330,33 +330,33 @@ discard block |
||
330 | 330 | $route_params = []; |
331 | 331 | |
332 | 332 | $route_name = get_class($model)::model_type().'_'; |
333 | - if($model->is_new()) |
|
334 | - $route_name.= 'new'; |
|
333 | + if ($model->is_new()) |
|
334 | + $route_name .= 'new'; |
|
335 | 335 | else |
336 | 336 | { |
337 | - $route_name.= 'default'; |
|
337 | + $route_name .= 'default'; |
|
338 | 338 | $route_params = ['id' => $model->get_id()]; |
339 | 339 | } |
340 | 340 | $res = $this->router()->prehop($route_name, $route_params); |
341 | 341 | return $res; |
342 | 342 | } |
343 | 343 | |
344 | - public function route_factory($route=null, $route_params=[]) : string |
|
344 | + public function route_factory($route = null, $route_params = []) : string |
|
345 | 345 | { |
346 | - if(is_null($route) && $this->router()->submits()) |
|
346 | + if (is_null($route) && $this->router()->submits()) |
|
347 | 347 | $route = $this->form_model; |
348 | 348 | |
349 | - if(!is_null($route) && is_subclass_of($route, '\HexMakina\Crudites\Interfaces\ModelInterface')) |
|
349 | + if (!is_null($route) && is_subclass_of($route, '\HexMakina\Crudites\Interfaces\ModelInterface')) |
|
350 | 350 | $route = $this->route_model($route); |
351 | 351 | |
352 | 352 | return parent::route_factory($route, $route_params); |
353 | 353 | } |
354 | 354 | |
355 | - private function sanitize_post_data($post_data=[]) |
|
355 | + private function sanitize_post_data($post_data = []) |
|
356 | 356 | { |
357 | - foreach($this->model_class_name::table()->columns() as $col) |
|
357 | + foreach ($this->model_class_name::table()->columns() as $col) |
|
358 | 358 | { |
359 | - if($col->type()->is_boolean()) |
|
359 | + if ($col->type()->is_boolean()) |
|
360 | 360 | { |
361 | 361 | $post_data[$col->name()] = !empty($post_data[$col->name()]); |
362 | 362 | } |
@@ -34,9 +34,12 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -37,8 +37,9 @@ discard block |
||
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 |
||
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 | } |
@@ -18,14 +18,14 @@ discard block |
||
18 | 18 | return in_array($permission_name, self::permissions_names_for($op)); |
19 | 19 | } |
20 | 20 | |
21 | - public static function query_retrieve($filters=[], $options=[]) : SelectInterface |
|
21 | + public static function query_retrieve($filters = [], $options = []) : SelectInterface |
|
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 |
||
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 | $ret = Permission::filter(['ids'=>$permission_ids]); |
44 | 44 | return $ret; |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | { |
49 | 49 | $operator_with_perms = get_class($op)::exists($op->operator_id()); |
50 | 50 | // $operator_with_perms = get_class($op)::retrieve($operator_with_perms); |
51 | - if(is_null($operator_with_perms)) |
|
51 | + if (is_null($operator_with_perms)) |
|
52 | 52 | return []; |
53 | 53 | |
54 | - return explode(',',$operator_with_perms->get('permission_names')); |
|
54 | + return explode(',', $operator_with_perms->get('permission_names')); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | public static function allow_in(OperatorInterface $op, Permission $p) |
@@ -13,17 +13,17 @@ |
||
13 | 13 | public function match($requestUrl = null, $requestMethod = null); |
14 | 14 | |
15 | 15 | // generates URL for href and location |
16 | - public function prehop($route, $route_params=[]); |
|
16 | + public function prehop($route, $route_params = []); |
|
17 | 17 | |
18 | 18 | // heads to another location |
19 | - public function hop($route, $route_params=[]); |
|
19 | + public function hop($route, $route_params = []); |
|
20 | 20 | |
21 | 21 | // do you GET it ? |
22 | 22 | public function requests() : bool; |
23 | 23 | |
24 | 24 | // have you POSTed it ? |
25 | 25 | public function submits() : bool; |
26 | - public function submitted($param_name=null); |
|
26 | + public function submitted($param_name = null); |
|
27 | 27 | |
28 | 28 | public function send_file($file_path); |
29 | 29 |
@@ -1,3 +1,3 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace HexMakina\kadro\Auth; |
3 | -class AccessRefusedException extends \Exception{} |
|
3 | +class AccessRefusedException extends \Exception {} |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | return $this->get('language_code'); |
67 | 67 | } |
68 | 68 | |
69 | - public static function query_retrieve($filters=[], $options=[]) : SelectInterface |
|
69 | + public static function query_retrieve($filters = [], $options = []) : SelectInterface |
|
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,9 +78,9 @@ discard block |
||
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 | - $Query->join([static::otm('t'), static::otm('a')],[[static::otm('a'),static::otm('k'), 't_from','id']], 'INNER'); |
|
83 | + $Query->join([static::otm('t'), static::otm('a')], [[static::otm('a'), static::otm('k'), 't_from', 'id']], 'INNER'); |
|
84 | 84 | $Query->aw_fields_eq(['model_id' => $filters['model']->get_id(), 'model_type' => get_class($filters['model'])::model_type()], static::otm('a')); |
85 | 85 | } |
86 | 86 |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | interface DisplayControllerInterface extends BaseController |
6 | 6 | { |
7 | 7 | |
8 | - /* |
|
8 | + /* |
|
9 | 9 | The viewport is an associative array of values to be exported as variables in the view |
10 | 10 | the assoc keys will be the variable names |
11 | 11 | |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | returns null |
43 | 43 | */ |
44 | 44 | |
45 | - public function viewport($key=null, $value=null, $coercion=false); |
|
45 | + public function viewport($key=null, $value=null, $coercion=false); |
|
46 | 46 | |
47 | - public function display($custom_template = null, $standalone=false); |
|
47 | + public function display($custom_template = null, $standalone=false); |
|
48 | 48 | |
49 | 49 | } |
@@ -42,9 +42,9 @@ |
||
42 | 42 | returns null |
43 | 43 | */ |
44 | 44 | |
45 | - public function viewport($key=null, $value=null, $coercion=false); |
|
45 | + public function viewport($key = null, $value = null, $coercion = false); |
|
46 | 46 | |
47 | - public function display($custom_template = null, $standalone=false); |
|
47 | + public function display($custom_template = null, $standalone = false); |
|
48 | 48 | |
49 | 49 | } |
50 | 50 |