@@ -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 | $template = $this->display($custom_template); |
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,23 @@ 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 | - $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,13 +81,13 @@ discard block |
||
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 | 93 | if(!is_null($this->load_model) && is_subclass_of($this->load_model, '\HexMakina\Crudites\Interfaces\TraceableInterface') && $this->load_model->traceable()) |
@@ -117,8 +124,9 @@ discard block |
||
117 | 124 | $this->logger()->nice(L('CRUDITES_INSTANCE_ALTERED', [L('MODEL_'.get_class($model)::model_type().'_INSTANCE')])); |
118 | 125 | return $model; |
119 | 126 | } |
120 | - foreach($this->errors() as $field => $error_msg) |
|
121 | - $this->logger()->warning(L($error_msg, [$field])); |
|
127 | + foreach($this->errors() as $field => $error_msg) { |
|
128 | + $this->logger()->warning(L($error_msg, [$field])); |
|
129 | + } |
|
122 | 130 | |
123 | 131 | return null; |
124 | 132 | } |
@@ -132,8 +140,12 @@ discard block |
||
132 | 140 | { |
133 | 141 | $class_name = is_null($model) ? $this->model_class_name : get_class($model); |
134 | 142 | |
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'); |
|
143 | + if(!isset($filters['date_start'])) { |
|
144 | + $filters['date_start'] = $this->box('StateAgent')->filters('date_start'); |
|
145 | + } |
|
146 | + if(!isset($filters['date_stop'])) { |
|
147 | + $filters['date_stop'] = $this->box('StateAgent')->filters('date_stop'); |
|
148 | + } |
|
137 | 149 | |
138 | 150 | // dd($filters); |
139 | 151 | $listing = $class_name::filter($filters); |
@@ -149,15 +161,16 @@ discard block |
||
149 | 161 | foreach($class_name::table()->columns() as $column) |
150 | 162 | { |
151 | 163 | |
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())); |
|
164 | + if(!$column->is_auto_incremented() && !$column->is_hidden()) { |
|
165 | + $listing_fields[$column->name()]=L(sprintf('MODEL_%s_FIELD_%s', $class_name::model_type(), $column->name())); |
|
166 | + } |
|
154 | 167 | } |
155 | - } |
|
156 | - else |
|
168 | + } else |
|
157 | 169 | { |
158 | 170 | $current = current($listing); |
159 | - if(is_object($current)) |
|
160 | - $current = get_object_vars($current); |
|
171 | + if(is_object($current)) { |
|
172 | + $current = get_object_vars($current); |
|
173 | + } |
|
161 | 174 | |
162 | 175 | foreach(array_keys($current) as $field) |
163 | 176 | { |
@@ -189,9 +202,9 @@ discard block |
||
189 | 202 | { |
190 | 203 | $model = $this->persist_model($this->form_model); |
191 | 204 | |
192 | - if(empty($this->errors())) |
|
193 | - $this->route_back($model); |
|
194 | - else |
|
205 | + if(empty($this->errors())) { |
|
206 | + $this->route_back($model); |
|
207 | + } else |
|
195 | 208 | { |
196 | 209 | $this->edit(); |
197 | 210 | return 'edit'; |
@@ -231,8 +244,7 @@ discard block |
||
231 | 244 | { |
232 | 245 | $this->logger()->warning(L('CRUDITES_ERR_INSTANCE_NOT_FOUND', [L('MODEL_'.$this->model_type.'_INSTANCE')])); |
233 | 246 | $this->router()->hop($this->model_type); |
234 | - } |
|
235 | - elseif($this->load_model->immortal()) |
|
247 | + } elseif($this->load_model->immortal()) |
|
236 | 248 | { |
237 | 249 | |
238 | 250 | $this->logger()->warning(L('CRUDITES_ERR_INSTANCE_IS_IMMORTAL', [L('MODEL_'.$this->model_type.'_INSTANCE')])); |
@@ -242,15 +254,15 @@ discard block |
||
242 | 254 | |
243 | 255 | public function destroy() |
244 | 256 | { |
245 | - if(!$this->router()->submits()) |
|
246 | - throw new \Exception('KADRO_ROUTER_MUST_SUBMIT'); |
|
257 | + if(!$this->router()->submits()) { |
|
258 | + throw new \Exception('KADRO_ROUTER_MUST_SUBMIT'); |
|
259 | + } |
|
247 | 260 | |
248 | 261 | if($this->load_model->destroy($this->operator()->operator_id(), $this->tracer()) === false) |
249 | 262 | { |
250 | 263 | $this->logger()->info(L('CRUDITES_ERR_INSTANCE_IS_UNDELETABLE', [''.$this->load_model])); |
251 | 264 | $this->route_back($this->load_model); |
252 | - } |
|
253 | - else |
|
265 | + } else |
|
254 | 266 | { |
255 | 267 | $this->logger()->nice(L('CRUDITES_INSTANCE_DESTROYED', [L('MODEL_'.$this->model_type.'_INSTANCE')])); |
256 | 268 | $this->route_back($this->model_type); |
@@ -268,11 +280,13 @@ discard block |
||
268 | 280 | |
269 | 281 | $this->viewport('form_model_type', $this->model_type); |
270 | 282 | |
271 | - if(isset($this->load_model)) |
|
272 | - $this->viewport('load_model', $this->load_model); |
|
283 | + if(isset($this->load_model)) { |
|
284 | + $this->viewport('load_model', $this->load_model); |
|
285 | + } |
|
273 | 286 | |
274 | - if(isset($this->form_model)) |
|
275 | - $this->viewport('form_model', $this->form_model); |
|
287 | + if(isset($this->form_model)) { |
|
288 | + $this->viewport('form_model', $this->form_model); |
|
289 | + } |
|
276 | 290 | } |
277 | 291 | |
278 | 292 | public function collection_to_csv($collection, $filename) |
@@ -330,9 +344,9 @@ discard block |
||
330 | 344 | $route_params = []; |
331 | 345 | |
332 | 346 | $route_name = get_class($model)::model_type().'_'; |
333 | - if($model->is_new()) |
|
334 | - $route_name.= 'new'; |
|
335 | - else |
|
347 | + if($model->is_new()) { |
|
348 | + $route_name.= 'new'; |
|
349 | + } else |
|
336 | 350 | { |
337 | 351 | $route_name.= 'default'; |
338 | 352 | $route_params = ['id' => $model->get_id()]; |
@@ -343,11 +357,13 @@ discard block |
||
343 | 357 | |
344 | 358 | public function route_factory($route=null, $route_params=[]) : string |
345 | 359 | { |
346 | - if(is_null($route) && $this->router()->submits()) |
|
347 | - $route = $this->form_model; |
|
360 | + if(is_null($route) && $this->router()->submits()) { |
|
361 | + $route = $this->form_model; |
|
362 | + } |
|
348 | 363 | |
349 | - if(!is_null($route) && is_subclass_of($route, '\HexMakina\Crudites\Interfaces\ModelInterface')) |
|
350 | - $route = $this->route_model($route); |
|
364 | + if(!is_null($route) && is_subclass_of($route, '\HexMakina\Crudites\Interfaces\ModelInterface')) { |
|
365 | + $route = $this->route_model($route); |
|
366 | + } |
|
351 | 367 | |
352 | 368 | return parent::route_factory($route, $route_params); |
353 | 369 | } |