Total Complexity | 98 |
Total Lines | 767 |
Duplicated Lines | 0 % |
Changes | 4 | ||
Bugs | 0 | Features | 0 |
Complex classes like Base often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Base, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
22 | abstract class Base |
||
23 | implements \Aimeos\Admin\JQAdm\Iface, \Aimeos\Macro\Iface |
||
24 | { |
||
25 | use \Aimeos\Macro\Macroable; |
||
26 | |||
27 | |||
28 | private $view; |
||
29 | private $aimeos; |
||
30 | private $context; |
||
31 | private $subclients; |
||
32 | private $object; |
||
33 | |||
34 | |||
35 | /** |
||
36 | * Initializes the class instance. |
||
37 | * |
||
38 | * @param \Aimeos\MShop\ContextIface $context Context object |
||
39 | */ |
||
40 | public function __construct( \Aimeos\MShop\ContextIface $context ) |
||
41 | { |
||
42 | $this->context = $context; |
||
43 | } |
||
44 | |||
45 | |||
46 | /** |
||
47 | * Adds the required data used in the attribute template |
||
48 | * |
||
49 | * @param \Aimeos\Base\View\Iface $view View object |
||
50 | * @return \Aimeos\Base\View\Iface View object with assigned parameters |
||
51 | */ |
||
52 | public function data( \Aimeos\Base\View\Iface $view ) : \Aimeos\Base\View\Iface |
||
53 | { |
||
54 | return $view; |
||
55 | } |
||
56 | |||
57 | |||
58 | /** |
||
59 | * Returns the Aimeos bootstrap object |
||
60 | * |
||
61 | * @return \Aimeos\Bootstrap The Aimeos bootstrap object |
||
62 | */ |
||
63 | public function getAimeos() : \Aimeos\Bootstrap |
||
64 | { |
||
65 | if( !isset( $this->aimeos ) ) { |
||
66 | throw new \Aimeos\Admin\JQAdm\Exception( $this->context->translate( 'admin', 'Aimeos object not available' ) ); |
||
67 | } |
||
68 | |||
69 | return $this->aimeos; |
||
70 | } |
||
71 | |||
72 | |||
73 | /** |
||
74 | * Sets the Aimeos bootstrap object |
||
75 | * |
||
76 | * @param \Aimeos\Bootstrap $aimeos The Aimeos bootstrap object |
||
77 | * @return \Aimeos\Admin\JQAdm\Iface Reference to this object for fluent calls |
||
78 | */ |
||
79 | public function setAimeos( \Aimeos\Bootstrap $aimeos ) : \Aimeos\Admin\JQAdm\Iface |
||
80 | { |
||
81 | $this->aimeos = $aimeos; |
||
82 | return $this; |
||
83 | } |
||
84 | |||
85 | |||
86 | /** |
||
87 | * Makes the outer decorator object available to inner objects |
||
88 | * |
||
89 | * @param \Aimeos\Admin\JQAdm\Iface $object Outmost object |
||
90 | * @return \Aimeos\Admin\JQAdm\Iface Same object for fluent interface |
||
91 | */ |
||
92 | public function setObject( \Aimeos\Admin\JQAdm\Iface $object ) : \Aimeos\Admin\JQAdm\Iface |
||
96 | } |
||
97 | |||
98 | |||
99 | /** |
||
100 | * Returns the view object that will generate the admin output. |
||
101 | * |
||
102 | * @return \Aimeos\Base\View\Iface The view object which generates the admin output |
||
103 | */ |
||
104 | protected function view() : \Aimeos\Base\View\Iface |
||
111 | } |
||
112 | |||
113 | |||
114 | /** |
||
115 | * Sets the view object that will generate the admin output. |
||
116 | * |
||
117 | * @param \Aimeos\Base\View\Iface $view The view object which generates the admin output |
||
118 | * @return \Aimeos\Admin\JQAdm\Iface Reference to this object for fluent calls |
||
119 | */ |
||
120 | public function setView( \Aimeos\Base\View\Iface $view ) : \Aimeos\Admin\JQAdm\Iface |
||
124 | } |
||
125 | |||
126 | |||
127 | /** |
||
128 | * Batch update of a resource |
||
129 | * |
||
130 | * @return string|null Output to display |
||
131 | */ |
||
132 | public function batch() : ?string |
||
133 | { |
||
134 | return $this->redirect( 'attribute', 'search', null, 'save' ); |
||
135 | } |
||
136 | |||
137 | |||
138 | /** |
||
139 | * Copies a resource |
||
140 | * |
||
141 | * @return string|null Output to display |
||
142 | */ |
||
143 | public function copy() : ?string |
||
144 | { |
||
145 | $body = null; |
||
146 | $view = $this->view(); |
||
147 | |||
148 | foreach( $this->getSubClients() as $idx => $client ) |
||
149 | { |
||
150 | $view->tabindex = ++$idx + 1; |
||
151 | $body .= $client->copy(); |
||
152 | } |
||
153 | |||
154 | return $body; |
||
155 | } |
||
156 | |||
157 | |||
158 | /** |
||
159 | * Creates a new resource |
||
160 | * |
||
161 | * @return string|null Output to display |
||
162 | */ |
||
163 | public function create() : ?string |
||
164 | { |
||
165 | $body = null; |
||
166 | $view = $this->view(); |
||
167 | |||
168 | foreach( $this->getSubClients() as $idx => $client ) |
||
169 | { |
||
170 | $view->tabindex = ++$idx + 1; |
||
171 | $body .= $client->create(); |
||
172 | } |
||
173 | |||
174 | return $body; |
||
175 | } |
||
176 | |||
177 | |||
178 | /** |
||
179 | * Deletes a resource |
||
180 | * |
||
181 | * @return string|null Output to display |
||
182 | */ |
||
183 | public function delete() : ?string |
||
184 | { |
||
185 | $body = null; |
||
186 | |||
187 | foreach( $this->getSubClients() as $client ) { |
||
188 | $body .= $client->delete(); |
||
189 | } |
||
190 | |||
191 | return $body; |
||
192 | } |
||
193 | |||
194 | |||
195 | /** |
||
196 | * Exports a resource |
||
197 | * |
||
198 | * @return string|null Output to display |
||
199 | */ |
||
200 | public function export() : ?string |
||
201 | { |
||
202 | $body = null; |
||
203 | |||
204 | foreach( $this->getSubClients() as $client ) { |
||
205 | $body .= $client->export(); |
||
206 | } |
||
207 | |||
208 | return $body; |
||
209 | } |
||
210 | |||
211 | |||
212 | /** |
||
213 | * Returns a resource |
||
214 | * |
||
215 | * @return string|null Output to display |
||
216 | */ |
||
217 | public function get() : ?string |
||
218 | { |
||
219 | $body = null; |
||
220 | $view = $this->view(); |
||
221 | |||
222 | foreach( $this->getSubClients() as $idx => $client ) |
||
223 | { |
||
224 | $view->tabindex = ++$idx + 1; |
||
225 | $body .= $client->get(); |
||
226 | } |
||
227 | |||
228 | return $body; |
||
229 | } |
||
230 | |||
231 | |||
232 | /** |
||
233 | * Imports a resource |
||
234 | * |
||
235 | * @return string|null Output to display |
||
236 | * @deprecated 2021.01 |
||
237 | */ |
||
238 | public function import() : ?string |
||
239 | { |
||
240 | $body = null; |
||
241 | |||
242 | foreach( $this->getSubClients() as $client ) { |
||
243 | $body .= $client->import(); |
||
244 | } |
||
245 | |||
246 | return null; |
||
247 | } |
||
248 | |||
249 | |||
250 | /** |
||
251 | * Saves the data |
||
252 | * |
||
253 | * @return string|null Output to display |
||
254 | */ |
||
255 | public function save() : ?string |
||
256 | { |
||
257 | $body = null; |
||
258 | |||
259 | foreach( $this->getSubClients() as $client ) { |
||
260 | $body .= $client->save(); |
||
261 | } |
||
262 | |||
263 | return $body; |
||
264 | } |
||
265 | |||
266 | |||
267 | /** |
||
268 | * Returns a list of resource according to the conditions |
||
269 | * |
||
270 | * @return string|null Output to display |
||
271 | */ |
||
272 | public function search() : ?string |
||
273 | { |
||
274 | $body = null; |
||
275 | |||
276 | foreach( $this->getSubClients() as $client ) { |
||
277 | $body .= $client->search(); |
||
278 | } |
||
279 | |||
280 | return $body; |
||
281 | } |
||
282 | |||
283 | |||
284 | /** |
||
285 | * Returns the PSR-7 response object for the request |
||
286 | * |
||
287 | * @return \Psr\Http\Message\ResponseInterface Response object |
||
288 | */ |
||
289 | public function response() : \Psr\Http\Message\ResponseInterface |
||
290 | { |
||
291 | return $this->view()->response(); |
||
292 | } |
||
293 | |||
294 | |||
295 | /** |
||
296 | * Adds the decorators to the client object |
||
297 | * |
||
298 | * @param \Aimeos\Admin\JQAdm\Iface $client Admin object |
||
299 | * @param array $decorators List of decorator name that should be wrapped around the client |
||
300 | * @param string $classprefix Decorator class prefix, e.g. "\Aimeos\Admin\JQAdm\Catalog\Decorator\" |
||
301 | * @return \Aimeos\Admin\JQAdm\Iface Admin object |
||
302 | */ |
||
303 | protected function addDecorators( \Aimeos\Admin\JQAdm\Iface $client, array $decorators, string $classprefix ) : \Aimeos\Admin\JQAdm\Iface |
||
304 | { |
||
305 | foreach( $decorators as $name ) |
||
306 | { |
||
307 | $classname = $classprefix . $name; |
||
308 | |||
309 | if( ctype_alnum( $name ) === false ) |
||
310 | { |
||
311 | $msg = $this->context->translate( 'admin', 'Invalid class name "%1$s"' ); |
||
312 | throw new \Aimeos\Admin\JQAdm\Exception( sprintf( $msg, $classname ) ); |
||
313 | } |
||
314 | |||
315 | if( class_exists( $classname ) === false ) |
||
316 | { |
||
317 | $msg = $this->context->translate( 'admin', 'Class "%1$s" not found' ); |
||
318 | throw new \Aimeos\Admin\JQAdm\Exception( sprintf( $msg, $classname ) ); |
||
319 | } |
||
320 | |||
321 | $client = new $classname( $client, $this->context ); |
||
322 | |||
323 | \Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Admin\\JQAdm\\Common\\Decorator\\Iface', $client ); |
||
324 | } |
||
325 | |||
326 | return $client; |
||
327 | } |
||
328 | |||
329 | |||
330 | /** |
||
331 | * Adds the decorators to the client object |
||
332 | * |
||
333 | * @param \Aimeos\Admin\JQAdm\Iface $client Admin object |
||
334 | * @param string $path Admin string in lower case, e.g. "catalog/detail/basic" |
||
335 | * @return \Aimeos\Admin\JQAdm\Iface Admin object |
||
336 | */ |
||
337 | protected function addClientDecorators( \Aimeos\Admin\JQAdm\Iface $client, string $path ) : \Aimeos\Admin\JQAdm\Iface |
||
338 | { |
||
339 | if( !is_string( $path ) || $path === '' ) |
||
|
|||
340 | { |
||
341 | $msg = $this->context->translate( 'admin', 'Invalid domain "%1$s"' ); |
||
342 | throw new \Aimeos\Admin\JQAdm\Exception( sprintf( $msg, $path ) ); |
||
343 | } |
||
344 | |||
345 | $localClass = str_replace( '/', '\\', ucwords( $path, '/' ) ); |
||
346 | $config = $this->context->config(); |
||
347 | |||
348 | $classprefix = '\\Aimeos\\Admin\\JQAdm\\Common\\Decorator\\'; |
||
349 | $decorators = $config->get( 'admin/jqadm/' . $path . '/decorators/global', [] ); |
||
350 | $client = $this->addDecorators( $client, $decorators, $classprefix ); |
||
351 | |||
352 | $classprefix = '\\Aimeos\\Admin\\JQAdm\\' . $localClass . '\\Decorator\\'; |
||
353 | $decorators = $config->get( 'admin/jqadm/' . $path . '/decorators/local', [] ); |
||
354 | $client = $this->addDecorators( $client, $decorators, $classprefix ); |
||
355 | |||
356 | return $client; |
||
357 | } |
||
358 | |||
359 | |||
360 | /** |
||
361 | * Returns the sub-client given by its name. |
||
362 | * |
||
363 | * @param string $path Name of the sub-part in lower case (can contain a path like catalog/filter/tree) |
||
364 | * @param string|null $name Name of the implementation, will be from configuration (or Default) if null |
||
365 | * @return \Aimeos\Admin\JQAdm\Iface Sub-part object |
||
366 | */ |
||
367 | protected function createSubClient( string $path, string $name = null ) : \Aimeos\Admin\JQAdm\Iface |
||
395 | } |
||
396 | |||
397 | |||
398 | /** |
||
399 | * Returns the value for the given key in the array |
||
400 | * |
||
401 | * @param array $values Multi-dimensional associative list of key/value pairs |
||
402 | * @param string $key Parameter key like "name" or "list/test" for associative arrays |
||
403 | * @param mixed $default Returned value if no one for key is available |
||
404 | * @return mixed Value from the array or default value if not present in array |
||
405 | */ |
||
406 | protected function val( array $values, $key, $default = null ) |
||
407 | { |
||
408 | foreach( explode( '/', trim( $key, '/' ) ) as $part ) |
||
409 | { |
||
410 | if( is_array( $values ) && isset( $values[$part] ) ) { |
||
411 | $values = $values[$part]; |
||
412 | } else { |
||
413 | return $default; |
||
414 | } |
||
415 | } |
||
416 | |||
417 | return $values; |
||
418 | } |
||
419 | |||
420 | |||
421 | /** |
||
422 | * Returns the known client parameters and their values |
||
423 | * |
||
424 | * @param array $names List of parameter names |
||
425 | * @return array Associative list of parameters names as key and their values |
||
426 | */ |
||
427 | protected function getClientParams( $names = ['id', 'resource', 'site', 'locale'] ) : array |
||
428 | { |
||
429 | $list = []; |
||
430 | |||
431 | foreach( $names as $name ) |
||
432 | { |
||
433 | if( ( $val = $this->view->param( $name ) ) !== null && !is_array( $val ) ) { |
||
434 | $list[$name] = $val; |
||
435 | } |
||
436 | } |
||
437 | |||
438 | return $list; |
||
439 | } |
||
440 | |||
441 | |||
442 | /** |
||
443 | * Returns the context object. |
||
444 | * |
||
445 | * @return \Aimeos\MShop\ContextIface Context object |
||
446 | */ |
||
447 | protected function context() : \Aimeos\MShop\ContextIface |
||
450 | } |
||
451 | |||
452 | |||
453 | /** |
||
454 | * Returns the available class names without namespace that are stored in the given path |
||
455 | * |
||
456 | * @param string $relpath Path relative to the include paths |
||
457 | * @param string[] $excludes List of file names to execlude |
||
458 | * @return string[] List of available class names |
||
459 | */ |
||
460 | protected function getClassNames( string $relpath, array $excludes = ['Base.php', 'Iface.php', 'Example.php', 'None.php'] ) : array |
||
461 | { |
||
462 | $list = []; |
||
463 | |||
464 | foreach( $this->getAimeos()->getIncludePaths() as $path ) |
||
465 | { |
||
466 | $path .= DIRECTORY_SEPARATOR . $relpath; |
||
467 | |||
468 | if( is_dir( $path ) ) |
||
469 | { |
||
470 | foreach( new \DirectoryIterator( $path ) as $entry ) |
||
471 | { |
||
472 | if( $entry->isFile() && !in_array( $entry->getFileName(), $excludes ) ) { |
||
473 | $list[] = pathinfo( $entry->getFileName(), PATHINFO_FILENAME ); |
||
474 | } |
||
475 | } |
||
476 | } |
||
477 | } |
||
478 | |||
479 | sort( $list ); |
||
480 | return $list; |
||
481 | } |
||
482 | |||
483 | |||
484 | /** |
||
485 | * Returns the array of criteria conditions based on the given parameters |
||
486 | * |
||
487 | * @param array $params List of criteria data with condition, sorting and paging |
||
488 | * @return array Multi-dimensional associative list of criteria conditions |
||
489 | */ |
||
490 | protected function getCriteriaConditions( array $params ) : array |
||
491 | { |
||
492 | $expr = []; |
||
493 | |||
494 | if( isset( $params['key'] ) ) |
||
495 | { |
||
496 | foreach( (array) $params['key'] as $idx => $key ) |
||
497 | { |
||
498 | if( $key != '' && isset( $params['op'][$idx] ) && $params['op'][$idx] != '' |
||
499 | && isset( $params['val'][$idx] ) && $params['val'][$idx] != '' |
||
500 | ) { |
||
501 | $expr[] = [$params['op'][$idx] => [$key => $params['val'][$idx]]]; |
||
502 | } |
||
503 | } |
||
504 | |||
505 | if( !empty( $expr ) ) { |
||
506 | $expr = ['&&' => $expr]; |
||
507 | } |
||
508 | } |
||
509 | |||
510 | return $expr; |
||
511 | } |
||
512 | |||
513 | |||
514 | /** |
||
515 | * Returns the outer decoratorator of the object |
||
516 | * |
||
517 | * @return \Aimeos\Admin\JQAdm\Iface Outmost object |
||
518 | */ |
||
519 | protected function object() : Iface |
||
520 | { |
||
521 | if( isset( $this->object ) ) { |
||
522 | return $this->object; |
||
523 | } |
||
524 | |||
525 | return $this; |
||
526 | } |
||
527 | |||
528 | |||
529 | /** |
||
530 | * Returns the sub-client given by its name. |
||
531 | * |
||
532 | * @param string $type Name of the client type |
||
533 | * @param string|null $name Name of the sub-client (Default if null) |
||
534 | * @return \Aimeos\Admin\JQAdm\Iface Sub-client object |
||
535 | */ |
||
536 | public function getSubClient( string $type, string $name = null ) : \Aimeos\Admin\JQAdm\Iface |
||
537 | { |
||
538 | $msg = $this->context()->translate( 'admin', 'Not implemented' ); |
||
539 | throw new \Aimeos\Admin\JQAdm\Exception( $msg ); |
||
540 | } |
||
541 | |||
542 | |||
543 | /** |
||
544 | * Returns the configured sub-clients or the ones named in the default parameter if none are configured. |
||
545 | * |
||
546 | * @return array List of sub-clients implementing \Aimeos\Admin\JQAdm\Iface ordered in the same way as the names |
||
547 | */ |
||
548 | protected function getSubClients() : array |
||
549 | { |
||
550 | if( !isset( $this->subclients ) ) |
||
551 | { |
||
552 | $this->subclients = []; |
||
553 | |||
554 | foreach( $this->getSubClientNames() as $name ) { |
||
555 | $this->subclients[] = $this->getSubClient( $name ); |
||
556 | } |
||
557 | } |
||
558 | |||
559 | return $this->subclients; |
||
560 | } |
||
561 | |||
562 | |||
563 | /** |
||
564 | * Returns the list of sub-client names configured for the client. |
||
565 | * |
||
566 | * @return array List of admin client names |
||
567 | */ |
||
568 | protected function getSubClientNames() : array |
||
571 | } |
||
572 | |||
573 | |||
574 | /** |
||
575 | * Initializes the criteria object based on the given parameter |
||
576 | * |
||
577 | * @param \Aimeos\Base\Criteria\Iface $criteria Criteria object |
||
578 | * @param array $params List of criteria data with condition, sorting and paging |
||
579 | * @return \Aimeos\Base\Criteria\Iface Initialized criteria object |
||
580 | */ |
||
581 | protected function initCriteria( \Aimeos\Base\Criteria\Iface $criteria, array $params ) : \Aimeos\Base\Criteria\Iface |
||
582 | { |
||
583 | if( isset( $params['sort'] ) && !empty( $params['sort'] ) ) { |
||
584 | $criteria->order( $params['sort'] ); |
||
585 | } |
||
586 | |||
587 | return $criteria->slice( $params['page']['offset'] ?? 0, $params['page']['limit'] ?? 25 ) |
||
588 | ->add( $criteria->parse( $this->getCriteriaConditions( $params['filter'] ?? [] ) ) ); |
||
589 | } |
||
590 | |||
591 | |||
592 | /** |
||
593 | * Flattens the nested configuration array |
||
594 | * |
||
595 | * @param array $config Multi-dimensional list of key/value pairs |
||
596 | * @param string $path Path of keys separated by slashes (/) to add new values for |
||
597 | * @return array List of arrays with "key" and "val" keys |
||
598 | */ |
||
599 | protected function flatten( array $config, string $path = '' ) : array |
||
600 | { |
||
601 | $list = []; |
||
602 | |||
603 | foreach( $config as $key => $val ) |
||
604 | { |
||
605 | if( is_array( $val ) ) { |
||
606 | $list = array_merge( $list, $this->flatten( $val, $path . '/' . $key ) ); |
||
607 | } else { |
||
608 | $list[] = ['key' => trim( $path . '/' . $key, '/' ), 'val' => $val]; |
||
609 | } |
||
610 | } |
||
611 | |||
612 | return $list; |
||
613 | } |
||
614 | |||
615 | |||
616 | /** |
||
617 | * Writes the exception details to the log |
||
618 | * |
||
619 | * @param \Exception $e Exception object |
||
620 | * @return \Aimeos\Admin\JQAdm\Iface Reference to this object for fluent calls |
||
621 | */ |
||
622 | protected function log( \Exception $e ) : Iface |
||
623 | { |
||
624 | $msg = $e->getMessage() . PHP_EOL; |
||
625 | |||
626 | if( $e instanceof \Aimeos\Admin\JQAdm\Exception ) { |
||
627 | $msg .= print_r( $e->getDetails(), true ) . PHP_EOL; |
||
628 | } |
||
629 | |||
630 | $this->context->logger()->error( $msg . $e->getTraceAsString(), 'admin/jqadm' ); |
||
631 | |||
632 | return $this; |
||
633 | } |
||
634 | |||
635 | |||
636 | /** |
||
637 | * Adds a redirect to the response for the next action |
||
638 | * |
||
639 | * @param string $resource Resource name |
||
640 | * @param string|null $action Next action |
||
641 | * @param string|null $id ID of the next resource item |
||
642 | * @param string|null $method Current method name |
||
643 | * @param array $params URL parameters to use |
||
644 | * @return string|null Returns value for the actions |
||
645 | */ |
||
646 | protected function redirect( string $resource, ?string $action, string $id = null, |
||
647 | string $method = null, array $params = [] ) : ?string |
||
648 | { |
||
649 | $params += $this->getClientParams(); |
||
650 | $context = $this->context(); |
||
651 | $view = $this->view(); |
||
652 | |||
653 | $params['resource'] = $resource; |
||
654 | unset( $params['id'] ); |
||
655 | |||
656 | switch( $action ) |
||
657 | { |
||
658 | case 'search': |
||
659 | $url = $view->link( 'admin/jqadm/url/search', $params ); break; |
||
660 | case 'create': |
||
661 | $url = $view->link( 'admin/jqadm/url/create', ['parentid' => $id] + $params ); break; |
||
662 | case 'copy': |
||
663 | $url = $view->link( 'admin/jqadm/url/copy', ['id' => $id] + $params ); break; |
||
664 | default: |
||
665 | $url = $view->link( 'admin/jqadm/url/get', ['id' => $id] + $params ); |
||
666 | } |
||
667 | |||
668 | switch( $method ) |
||
669 | { |
||
670 | case 'save': |
||
671 | $context->session()->set( 'info', [$context->translate( 'admin', 'Item saved successfully' )] ); break; |
||
672 | case 'delete': |
||
673 | $context->session()->set( 'info', [$context->translate( 'admin', 'Item deleted successfully' )] ); break; |
||
674 | } |
||
675 | |||
676 | $view->response()->withStatus( 302 ); |
||
677 | $view->response()->withHeader( 'Location', $url ); |
||
678 | $view->response()->withHeader( 'Cache-Control', 'no-store' ); |
||
679 | |||
680 | return null; |
||
681 | } |
||
682 | |||
683 | |||
684 | /** |
||
685 | * Writes the exception details to the log |
||
686 | * |
||
687 | * @param \Exception $e Exception object |
||
688 | * @param string $method Method it's called from |
||
689 | * @return \Aimeos\Admin\JQAdm\Iface Reference to this object for fluent calls |
||
690 | */ |
||
691 | protected function report( \Exception $e, string $method ) : Iface |
||
717 | } |
||
718 | |||
719 | |||
720 | /** |
||
721 | * Checks and returns the request parameter for the given name |
||
722 | * |
||
723 | * @param string $name Name of the request parameter, can be a path like 'page/limit' |
||
724 | * @return mixed Parameter value |
||
725 | * @throws \Aimeos\Admin\JQAdm\Exception If the parameter is missing |
||
726 | */ |
||
727 | protected function require( string $name ) |
||
728 | { |
||
729 | if( ( $value = $this->view()->param( $name ) ) !== null ) { |
||
730 | return $value; |
||
731 | } |
||
732 | |||
733 | $msg = $this->context->translate( 'admin', 'Required parameter "%1$s" is missing' ); |
||
734 | throw new \Aimeos\Admin\JQAdm\Exception( sprintf( $msg, $name ) ); |
||
735 | } |
||
736 | |||
737 | |||
738 | /** |
||
739 | * Stores and returns the parameters used for searching items |
||
740 | * |
||
741 | * @param array $params GET/POST parameter set |
||
742 | * @param string $name Name of the panel/subpanel |
||
743 | * @return array Associative list of parameters for searching items |
||
744 | */ |
||
745 | protected function storeFilter( array $params, string $name ) : array |
||
762 | ]; |
||
763 | } |
||
764 | |||
765 | |||
766 | /** |
||
767 | * Throws an exception with given details |
||
768 | * |
||
769 | * @param array $errors List of key/message pairs of errors |
||
770 | * @throws \Aimeos\Admin\JQAdm\Exception Exception with error details |
||
771 | */ |
||
772 | protected function notify( array $errors ) : Iface |
||
773 | { |
||
774 | $list = []; |
||
775 | $i18n = $this->context->i18n(); |
||
789 | } |
||
790 | } |
||
791 |