Complex classes like AbstractAdmin 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. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
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 AbstractAdmin, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
63 | abstract class AbstractAdmin implements AdminInterface, DomainObjectInterface, AdminTreeInterface |
||
64 | { |
||
65 | public const CONTEXT_MENU = 'menu'; |
||
66 | public const CONTEXT_DASHBOARD = 'dashboard'; |
||
67 | |||
68 | public const CLASS_REGEX = |
||
69 | '@ |
||
70 | (?:([A-Za-z0-9]*)\\\)? # vendor name / app name |
||
71 | (Bundle\\\)? # optional bundle directory |
||
72 | ([A-Za-z0-9]+?)(?:Bundle)?\\\ # bundle name, with optional suffix |
||
73 | ( |
||
74 | Entity|Document|Model|PHPCR|CouchDocument|Phpcr| |
||
75 | Doctrine\\\Orm|Doctrine\\\Phpcr|Doctrine\\\MongoDB|Doctrine\\\CouchDB |
||
76 | )\\\(.*)@x'; |
||
77 | |||
78 | public const MOSAIC_ICON_CLASS = 'fa fa-th-large fa-fw'; |
||
79 | |||
80 | /** |
||
81 | * The list FieldDescription constructed from the configureListField method. |
||
82 | * |
||
83 | * @var FieldDescriptionInterface[] |
||
84 | */ |
||
85 | protected $listFieldDescriptions = []; |
||
86 | |||
87 | /** |
||
88 | * The show FieldDescription constructed from the configureShowFields method. |
||
89 | * |
||
90 | * @var FieldDescriptionInterface[] |
||
91 | */ |
||
92 | protected $showFieldDescriptions = []; |
||
93 | |||
94 | /** |
||
95 | * The list FieldDescription constructed from the configureFormField method. |
||
96 | * |
||
97 | * @var FieldDescriptionInterface[] |
||
98 | */ |
||
99 | protected $formFieldDescriptions = []; |
||
100 | |||
101 | /** |
||
102 | * The filter FieldDescription constructed from the configureFilterField method. |
||
103 | * |
||
104 | * @var FieldDescriptionInterface[] |
||
105 | */ |
||
106 | protected $filterFieldDescriptions = []; |
||
107 | |||
108 | /** |
||
109 | * NEXT_MAJOR: Remove this property. |
||
110 | * |
||
111 | * The number of result to display in the list. |
||
112 | * |
||
113 | * @deprecated since sonata-project/admin-bundle 3.67. |
||
114 | * |
||
115 | * @var int |
||
116 | */ |
||
117 | protected $maxPerPage = 32; |
||
118 | |||
119 | /** |
||
120 | * The maximum number of page numbers to display in the list. |
||
121 | * |
||
122 | * @var int |
||
123 | */ |
||
124 | protected $maxPageLinks = 25; |
||
125 | |||
126 | /** |
||
127 | * The base route name used to generate the routing information. |
||
128 | * |
||
129 | * @var string |
||
130 | */ |
||
131 | protected $baseRouteName; |
||
132 | |||
133 | /** |
||
134 | * The base route pattern used to generate the routing information. |
||
135 | * |
||
136 | * @var string |
||
137 | */ |
||
138 | protected $baseRoutePattern; |
||
139 | |||
140 | /** |
||
141 | * The base name controller used to generate the routing information. |
||
142 | * |
||
143 | * @var string |
||
144 | */ |
||
145 | protected $baseControllerName; |
||
146 | |||
147 | /** |
||
148 | * The label class name (used in the title/breadcrumb ...). |
||
149 | * |
||
150 | * @var string |
||
151 | */ |
||
152 | protected $classnameLabel; |
||
153 | |||
154 | /** |
||
155 | * The translation domain to be used to translate messages. |
||
156 | * |
||
157 | * @var string |
||
158 | */ |
||
159 | protected $translationDomain = 'messages'; |
||
160 | |||
161 | /** |
||
162 | * Options to set to the form (ie, validation_groups). |
||
163 | * |
||
164 | * @var array |
||
165 | */ |
||
166 | protected $formOptions = []; |
||
167 | |||
168 | /** |
||
169 | * NEXT_MAJOR: Remove this property. |
||
170 | * |
||
171 | * Default values to the datagrid. |
||
172 | * |
||
173 | * @deprecated since sonata-project/admin-bundle 3.67, use configureDefaultSortValues() instead. |
||
174 | * |
||
175 | * @var array |
||
176 | */ |
||
177 | protected $datagridValues = [ |
||
178 | '_page' => 1, |
||
179 | '_per_page' => 32, |
||
180 | ]; |
||
181 | |||
182 | /** |
||
183 | * NEXT_MAJOR: Remove this property. |
||
184 | * |
||
185 | * Predefined per page options. |
||
186 | * |
||
187 | * @deprecated since sonata-project/admin-bundle 3.67. |
||
188 | * |
||
189 | * @var array |
||
190 | */ |
||
191 | protected $perPageOptions = [16, 32, 64, 128, 256]; |
||
192 | |||
193 | /** |
||
194 | * Pager type. |
||
195 | * |
||
196 | * @var string |
||
197 | */ |
||
198 | protected $pagerType = Pager::TYPE_DEFAULT; |
||
199 | |||
200 | /** |
||
201 | * The code related to the admin. |
||
202 | * |
||
203 | * @var string |
||
204 | */ |
||
205 | protected $code; |
||
206 | |||
207 | /** |
||
208 | * The label. |
||
209 | * |
||
210 | * @var string |
||
211 | */ |
||
212 | protected $label; |
||
213 | |||
214 | /** |
||
215 | * Whether or not to persist the filters in the session. |
||
216 | * |
||
217 | * NEXT_MAJOR: remove this property |
||
218 | * |
||
219 | * @var bool |
||
220 | * |
||
221 | * @deprecated since sonata-project/admin-bundle 3.34, to be removed in 4.0. |
||
222 | */ |
||
223 | protected $persistFilters = false; |
||
224 | |||
225 | /** |
||
226 | * Array of routes related to this admin. |
||
227 | * |
||
228 | * @var RouteCollection |
||
229 | */ |
||
230 | protected $routes; |
||
231 | |||
232 | /** |
||
233 | * The subject only set in edit/update/create mode. |
||
234 | * |
||
235 | * @var object|null |
||
236 | */ |
||
237 | protected $subject; |
||
238 | |||
239 | /** |
||
240 | * Define a Collection of child admin, ie /admin/order/{id}/order-element/{childId}. |
||
241 | * |
||
242 | * @var array |
||
243 | */ |
||
244 | protected $children = []; |
||
245 | |||
246 | /** |
||
247 | * Reference the parent admin. |
||
248 | * |
||
249 | * @var AdminInterface|null |
||
250 | */ |
||
251 | protected $parent; |
||
252 | |||
253 | /** |
||
254 | * The base code route refer to the prefix used to generate the route name. |
||
255 | * |
||
256 | * NEXT_MAJOR: remove this attribute. |
||
257 | * |
||
258 | * @deprecated This attribute is deprecated since sonata-project/admin-bundle 3.24 and will be removed in 4.0 |
||
259 | * |
||
260 | * @var string |
||
261 | */ |
||
262 | protected $baseCodeRoute = ''; |
||
263 | |||
264 | /** |
||
265 | * NEXT_MAJOR: should be default array and private. |
||
266 | * |
||
267 | * @var string|array |
||
268 | */ |
||
269 | protected $parentAssociationMapping; |
||
270 | |||
271 | /** |
||
272 | * Reference the parent FieldDescription related to this admin |
||
273 | * only set for FieldDescription which is associated to an Sub Admin instance. |
||
274 | * |
||
275 | * @var FieldDescriptionInterface |
||
276 | */ |
||
277 | protected $parentFieldDescription; |
||
278 | |||
279 | /** |
||
280 | * If true then the current admin is part of the nested admin set (from the url). |
||
281 | * |
||
282 | * @var bool |
||
283 | */ |
||
284 | protected $currentChild = false; |
||
285 | |||
286 | /** |
||
287 | * The uniqid is used to avoid clashing with 2 admin related to the code |
||
288 | * ie: a Block linked to a Block. |
||
289 | * |
||
290 | * @var string |
||
291 | */ |
||
292 | protected $uniqid; |
||
293 | |||
294 | /** |
||
295 | * The Entity or Document manager. |
||
296 | * |
||
297 | * @var ModelManagerInterface |
||
298 | */ |
||
299 | protected $modelManager; |
||
300 | |||
301 | /** |
||
302 | * The current request object. |
||
303 | * |
||
304 | * @var Request|null |
||
305 | */ |
||
306 | protected $request; |
||
307 | |||
308 | /** |
||
309 | * The translator component. |
||
310 | * |
||
311 | * NEXT_MAJOR: remove this property |
||
312 | * |
||
313 | * @var DeprecatedTranslatorInterface|TranslatorInterface |
||
314 | * |
||
315 | * @deprecated since sonata-project/admin-bundle 3.9, to be removed with 4.0 |
||
316 | */ |
||
317 | protected $translator; |
||
318 | |||
319 | /** |
||
320 | * The related form contractor. |
||
321 | * |
||
322 | * @var FormContractorInterface |
||
323 | */ |
||
324 | protected $formContractor; |
||
325 | |||
326 | /** |
||
327 | * The related list builder. |
||
328 | * |
||
329 | * @var ListBuilderInterface |
||
330 | */ |
||
331 | protected $listBuilder; |
||
332 | |||
333 | /** |
||
334 | * The related view builder. |
||
335 | * |
||
336 | * @var ShowBuilderInterface |
||
337 | */ |
||
338 | protected $showBuilder; |
||
339 | |||
340 | /** |
||
341 | * The related datagrid builder. |
||
342 | * |
||
343 | * @var DatagridBuilderInterface |
||
344 | */ |
||
345 | protected $datagridBuilder; |
||
346 | |||
347 | /** |
||
348 | * @var RouteBuilderInterface |
||
349 | */ |
||
350 | protected $routeBuilder; |
||
351 | |||
352 | /** |
||
353 | * The datagrid instance. |
||
354 | * |
||
355 | * @var DatagridInterface|null |
||
356 | */ |
||
357 | protected $datagrid; |
||
358 | |||
359 | /** |
||
360 | * The router instance. |
||
361 | * |
||
362 | * @var RouteGeneratorInterface|null |
||
363 | */ |
||
364 | protected $routeGenerator; |
||
365 | |||
366 | /** |
||
367 | * The generated breadcrumbs. |
||
368 | * |
||
369 | * NEXT_MAJOR : remove this property |
||
370 | * |
||
371 | * @var array |
||
372 | */ |
||
373 | protected $breadcrumbs = []; |
||
374 | |||
375 | /** |
||
376 | * @var SecurityHandlerInterface |
||
377 | */ |
||
378 | protected $securityHandler; |
||
379 | |||
380 | /** |
||
381 | * @var ValidatorInterface |
||
382 | */ |
||
383 | protected $validator; |
||
384 | |||
385 | /** |
||
386 | * The configuration pool. |
||
387 | * |
||
388 | * @var Pool |
||
389 | */ |
||
390 | protected $configurationPool; |
||
391 | |||
392 | /** |
||
393 | * @var ItemInterface |
||
394 | */ |
||
395 | protected $menu; |
||
396 | |||
397 | /** |
||
398 | * @var FactoryInterface |
||
399 | */ |
||
400 | protected $menuFactory; |
||
401 | |||
402 | /** |
||
403 | * @var array<string, bool> |
||
404 | */ |
||
405 | protected $loaded = [ |
||
406 | 'view_fields' => false, // NEXT_MAJOR: Remove this unused value. |
||
407 | 'view_groups' => false, // NEXT_MAJOR: Remove this unused value. |
||
408 | 'routes' => false, |
||
409 | 'tab_menu' => false, |
||
410 | 'show' => false, |
||
411 | 'list' => false, |
||
412 | 'form' => false, |
||
413 | 'datagrid' => false, |
||
414 | ]; |
||
415 | |||
416 | /** |
||
417 | * @var string[] |
||
418 | */ |
||
419 | protected $formTheme = []; |
||
420 | |||
421 | /** |
||
422 | * @var string[] |
||
423 | */ |
||
424 | protected $filterTheme = []; |
||
425 | |||
426 | /** |
||
427 | * @var array<string, string> |
||
428 | * |
||
429 | * @deprecated since sonata-project/admin-bundle 3.34, will be dropped in 4.0. Use TemplateRegistry services instead |
||
430 | */ |
||
431 | protected $templates = []; |
||
432 | |||
433 | /** |
||
434 | * @var AdminExtensionInterface[] |
||
435 | */ |
||
436 | protected $extensions = []; |
||
437 | |||
438 | /** |
||
439 | * @var LabelTranslatorStrategyInterface |
||
440 | */ |
||
441 | protected $labelTranslatorStrategy; |
||
442 | |||
443 | /** |
||
444 | * Setting to true will enable preview mode for |
||
445 | * the entity and show a preview button in the |
||
446 | * edit/create forms. |
||
447 | * |
||
448 | * @var bool |
||
449 | */ |
||
450 | protected $supportsPreviewMode = false; |
||
451 | |||
452 | /** |
||
453 | * Roles and permissions per role. |
||
454 | * |
||
455 | * @var array 'role' => ['permission', 'permission'] |
||
456 | */ |
||
457 | protected $securityInformation = []; |
||
458 | |||
459 | protected $cacheIsGranted = []; |
||
460 | |||
461 | /** |
||
462 | * Action list for the search result. |
||
463 | * |
||
464 | * @var string[] |
||
465 | */ |
||
466 | protected $searchResultActions = ['edit', 'show']; |
||
467 | |||
468 | protected $listModes = [ |
||
469 | 'list' => [ |
||
470 | 'class' => 'fa fa-list fa-fw', |
||
471 | ], |
||
472 | 'mosaic' => [ |
||
473 | 'class' => self::MOSAIC_ICON_CLASS, |
||
474 | ], |
||
475 | ]; |
||
476 | |||
477 | /** |
||
478 | * The Access mapping. |
||
479 | * |
||
480 | * @var array [action1 => requiredRole1, action2 => [requiredRole2, requiredRole3]] |
||
481 | */ |
||
482 | protected $accessMapping = []; |
||
483 | |||
484 | /** |
||
485 | * @var MutableTemplateRegistryInterface |
||
486 | */ |
||
487 | private $templateRegistry; |
||
488 | |||
489 | /** |
||
490 | * The class name managed by the admin class. |
||
491 | * |
||
492 | * @var string |
||
493 | */ |
||
494 | private $class; |
||
495 | |||
496 | /** |
||
497 | * The subclasses supported by the admin class. |
||
498 | * |
||
499 | * @var array<string, string> |
||
500 | */ |
||
501 | private $subClasses = []; |
||
502 | |||
503 | /** |
||
504 | * The list collection. |
||
505 | * |
||
506 | * @var FieldDescriptionCollection|null |
||
507 | */ |
||
508 | private $list; |
||
509 | |||
510 | /** |
||
511 | * @var FieldDescriptionCollection|null |
||
512 | */ |
||
513 | private $show; |
||
514 | |||
515 | /** |
||
516 | * @var FormInterface|null |
||
517 | */ |
||
518 | private $form; |
||
519 | |||
520 | /** |
||
521 | * The cached base route name. |
||
522 | * |
||
523 | * @var string |
||
524 | */ |
||
525 | private $cachedBaseRouteName; |
||
526 | |||
527 | /** |
||
528 | * The cached base route pattern. |
||
529 | * |
||
530 | * @var string |
||
531 | */ |
||
532 | private $cachedBaseRoutePattern; |
||
533 | |||
534 | /** |
||
535 | * The form group disposition. |
||
536 | * |
||
537 | * NEXT_MAJOR: must have `[]` as default value and remove the possibility to |
||
538 | * hold boolean values. |
||
539 | * |
||
540 | * @var array|bool |
||
541 | */ |
||
542 | private $formGroups = false; |
||
543 | |||
544 | /** |
||
545 | * The form tabs disposition. |
||
546 | * |
||
547 | * NEXT_MAJOR: must have `[]` as default value and remove the possibility to |
||
548 | * hold boolean values. |
||
549 | * |
||
550 | * @var array|bool |
||
551 | */ |
||
552 | private $formTabs = false; |
||
553 | |||
554 | /** |
||
555 | * The view group disposition. |
||
556 | * |
||
557 | * NEXT_MAJOR: must have `[]` as default value and remove the possibility to |
||
558 | * hold boolean values. |
||
559 | * |
||
560 | * @var array|bool |
||
561 | */ |
||
562 | private $showGroups = false; |
||
563 | |||
564 | /** |
||
565 | * The view tab disposition. |
||
566 | * |
||
567 | * NEXT_MAJOR: must have `[]` as default value and remove the possibility to |
||
568 | * hold boolean values. |
||
569 | * |
||
570 | * @var array|bool |
||
571 | */ |
||
572 | private $showTabs = false; |
||
573 | |||
574 | /** |
||
575 | * The manager type to use for the admin. |
||
576 | * |
||
577 | * @var string |
||
578 | */ |
||
579 | private $managerType; |
||
580 | |||
581 | /** |
||
582 | * The breadcrumbsBuilder component. |
||
583 | * |
||
584 | * @var BreadcrumbsBuilderInterface |
||
585 | */ |
||
586 | private $breadcrumbsBuilder; |
||
587 | |||
588 | /** |
||
589 | * Component responsible for persisting filters. |
||
590 | * |
||
591 | * @var FilterPersisterInterface|null |
||
592 | */ |
||
593 | private $filterPersister; |
||
594 | |||
595 | /** |
||
596 | * @param string $code |
||
597 | * @param string $class |
||
598 | * @param string|null $baseControllerName |
||
599 | */ |
||
600 | public function __construct($code, $class, $baseControllerName = null) |
||
633 | |||
634 | /** |
||
635 | * {@inheritdoc} |
||
636 | */ |
||
637 | public function getExportFormats() |
||
643 | |||
644 | /** |
||
645 | * @return array |
||
646 | */ |
||
647 | public function getExportFields() |
||
659 | |||
660 | public function getDataSourceIterator() |
||
686 | |||
687 | public function validate(ErrorElement $errorElement, $object) |
||
690 | |||
691 | /** |
||
692 | * define custom variable. |
||
693 | */ |
||
694 | public function initialize() |
||
710 | |||
711 | public function configure() |
||
714 | |||
715 | public function update($object) |
||
735 | |||
736 | public function create($object) |
||
758 | |||
759 | public function delete($object) |
||
774 | |||
775 | /** |
||
776 | * @param object $object |
||
777 | */ |
||
778 | public function preValidate($object) |
||
781 | |||
782 | public function preUpdate($object) |
||
785 | |||
786 | public function postUpdate($object) |
||
789 | |||
790 | public function prePersist($object) |
||
793 | |||
794 | public function postPersist($object) |
||
797 | |||
798 | public function preRemove($object) |
||
801 | |||
802 | public function postRemove($object) |
||
805 | |||
806 | public function preBatchAction($actionName, ProxyQueryInterface $query, array &$idx, $allElements) |
||
809 | |||
810 | public function getFilterParameters() |
||
862 | |||
863 | /** |
||
864 | * NEXT_MAJOR: Change the visibility to protected (similar to buildShow, buildForm, ...). |
||
865 | */ |
||
866 | public function buildDatagrid() |
||
920 | |||
921 | /** |
||
922 | * Returns the name of the parent related field, so the field can be use to set the default |
||
923 | * value (ie the parent object) or to filter the object. |
||
924 | * |
||
925 | * @throws \InvalidArgumentException |
||
926 | * |
||
927 | * @return string|null |
||
928 | */ |
||
929 | public function getParentAssociationMapping() |
||
949 | |||
950 | /** |
||
951 | * @param string $code |
||
952 | * @param string $value |
||
953 | */ |
||
954 | final public function addParentAssociationMapping($code, $value) |
||
958 | |||
959 | /** |
||
960 | * Returns the baseRoutePattern used to generate the routing information. |
||
961 | * |
||
962 | * @throws \RuntimeException |
||
963 | * |
||
964 | * @return string the baseRoutePattern used to generate the routing information |
||
965 | */ |
||
966 | public function getBaseRoutePattern() |
||
1014 | |||
1015 | /** |
||
1016 | * Returns the baseRouteName used to generate the routing information. |
||
1017 | * |
||
1018 | * @throws \RuntimeException |
||
1019 | * |
||
1020 | * @return string the baseRouteName used to generate the routing information |
||
1021 | */ |
||
1022 | public function getBaseRouteName() |
||
1071 | |||
1072 | /** |
||
1073 | * urlize the given word. |
||
1074 | * |
||
1075 | * @param string $word |
||
1076 | * @param string $sep the separator |
||
1077 | * |
||
1078 | * @return string |
||
1079 | */ |
||
1080 | public function urlize($word, $sep = '_') |
||
1084 | |||
1085 | public function getClass() |
||
1108 | |||
1109 | public function getSubClasses() |
||
1113 | |||
1114 | /** |
||
1115 | * NEXT_MAJOR: remove this method. |
||
1116 | */ |
||
1117 | public function addSubClass($subClass) |
||
1128 | |||
1129 | public function setSubClasses(array $subClasses) |
||
1133 | |||
1134 | public function hasSubClass($name) |
||
1138 | |||
1139 | public function hasActiveSubClass() |
||
1147 | |||
1148 | public function getActiveSubClass() |
||
1169 | |||
1170 | public function getActiveSubclassCode() |
||
1210 | |||
1211 | public function getBatchActions() |
||
1244 | |||
1245 | public function getRoutes() |
||
1251 | |||
1252 | public function getRouterIdParameter() |
||
1256 | |||
1257 | public function getIdParameter() |
||
1267 | |||
1268 | public function hasRoute($name) |
||
1276 | |||
1277 | /** |
||
1278 | * @param string $name |
||
1279 | * @param string|null $adminCode |
||
1280 | * |
||
1281 | * @return bool |
||
1282 | */ |
||
1283 | public function isCurrentRoute($name, $adminCode = null) |
||
1304 | |||
1305 | public function generateObjectUrl($name, $object, array $parameters = [], $referenceType = RoutingUrlGeneratorInterface::ABSOLUTE_PATH) |
||
1311 | |||
1312 | public function generateUrl($name, array $parameters = [], $referenceType = RoutingUrlGeneratorInterface::ABSOLUTE_PATH) |
||
1316 | |||
1317 | public function generateMenuUrl($name, array $parameters = [], $referenceType = RoutingUrlGeneratorInterface::ABSOLUTE_PATH) |
||
1321 | |||
1322 | final public function setTemplateRegistry(MutableTemplateRegistryInterface $templateRegistry) |
||
1326 | |||
1327 | /** |
||
1328 | * @param array<string, string> $templates |
||
1329 | */ |
||
1330 | public function setTemplates(array $templates) |
||
1337 | |||
1338 | /** |
||
1339 | * @param string $name |
||
1340 | * @param string $template |
||
1341 | */ |
||
1342 | public function setTemplate($name, $template) |
||
1349 | |||
1350 | /** |
||
1351 | * @deprecated since sonata-project/admin-bundle 3.34, will be dropped in 4.0. Use TemplateRegistry services instead |
||
1352 | * |
||
1353 | * @return array<string, string> |
||
1354 | */ |
||
1355 | public function getTemplates() |
||
1359 | |||
1360 | /** |
||
1361 | * @deprecated since sonata-project/admin-bundle 3.34, will be dropped in 4.0. Use TemplateRegistry services instead |
||
1362 | * |
||
1363 | * @param string $name |
||
1364 | * |
||
1365 | * @return string|null |
||
1366 | */ |
||
1367 | public function getTemplate($name) |
||
1371 | |||
1372 | public function getNewInstance() |
||
1384 | |||
1385 | public function getFormBuilder() |
||
1398 | |||
1399 | /** |
||
1400 | * This method is being called by the main admin class and the child class, |
||
1401 | * the getFormBuilder is only call by the main admin class. |
||
1402 | */ |
||
1403 | public function defineFormBuilder(FormBuilderInterface $formBuilder) |
||
1429 | |||
1430 | public function attachAdminClass(FieldDescriptionInterface $fieldDescription) |
||
1463 | |||
1464 | public function getObject($id) |
||
1473 | |||
1474 | public function getForm() |
||
1480 | |||
1481 | public function getList() |
||
1487 | |||
1488 | /** |
||
1489 | * @final since sonata-project/admin-bundle 3.63.0 |
||
1490 | */ |
||
1491 | public function createQuery($context = 'list') |
||
1509 | |||
1510 | public function getDatagrid() |
||
1516 | |||
1517 | public function buildTabMenu($action, ?AdminInterface $childAdmin = null) |
||
1544 | |||
1545 | public function buildSideMenu($action, ?AdminInterface $childAdmin = null) |
||
1549 | |||
1550 | /** |
||
1551 | * @param string $action |
||
1552 | * |
||
1553 | * @return ItemInterface |
||
1554 | */ |
||
1555 | public function getSideMenu($action, ?AdminInterface $childAdmin = null) |
||
1565 | |||
1566 | /** |
||
1567 | * Returns the root code. |
||
1568 | * |
||
1569 | * @return string the root code |
||
1570 | */ |
||
1571 | public function getRootCode() |
||
1575 | |||
1576 | /** |
||
1577 | * Returns the master admin. |
||
1578 | * |
||
1579 | * @return AdminInterface the root admin class |
||
1580 | */ |
||
1581 | public function getRoot() |
||
1589 | |||
1590 | public function setBaseControllerName($baseControllerName) |
||
1594 | |||
1595 | public function getBaseControllerName() |
||
1599 | |||
1600 | /** |
||
1601 | * @param string $label |
||
1602 | */ |
||
1603 | public function setLabel($label) |
||
1607 | |||
1608 | public function getLabel() |
||
1612 | |||
1613 | /** |
||
1614 | * @param bool $persist |
||
1615 | * |
||
1616 | * NEXT_MAJOR: remove this method |
||
1617 | * |
||
1618 | * @deprecated since sonata-project/admin-bundle 3.34, to be removed in 4.0. |
||
1619 | */ |
||
1620 | public function setPersistFilters($persist) |
||
1629 | |||
1630 | public function setFilterPersister(?FilterPersisterInterface $filterPersister = null) |
||
1636 | |||
1637 | /** |
||
1638 | * NEXT_MAJOR: Remove this method. |
||
1639 | * |
||
1640 | * @deprecated since sonata-project/admin-bundle 3.67, to be removed in 4.0. |
||
1641 | * |
||
1642 | * @param int $maxPerPage |
||
1643 | */ |
||
1644 | public function setMaxPerPage($maxPerPage) |
||
1653 | |||
1654 | /** |
||
1655 | * @return int |
||
1656 | */ |
||
1657 | public function getMaxPerPage() |
||
1665 | |||
1666 | /** |
||
1667 | * @param int $maxPageLinks |
||
1668 | */ |
||
1669 | public function setMaxPageLinks($maxPageLinks) |
||
1673 | |||
1674 | /** |
||
1675 | * @return int |
||
1676 | */ |
||
1677 | public function getMaxPageLinks() |
||
1681 | |||
1682 | public function getFormGroups() |
||
1694 | |||
1695 | public function setFormGroups(array $formGroups) |
||
1699 | |||
1700 | public function removeFieldFromFormGroup($key) |
||
1710 | |||
1711 | /** |
||
1712 | * @param string $group |
||
1713 | */ |
||
1714 | public function reorderFormGroup($group, array $keys) |
||
1721 | |||
1722 | public function getFormTabs() |
||
1734 | |||
1735 | public function setFormTabs(array $formTabs) |
||
1739 | |||
1740 | public function getShowTabs() |
||
1752 | |||
1753 | public function setShowTabs(array $showTabs) |
||
1757 | |||
1758 | public function getShowGroups() |
||
1770 | |||
1771 | public function setShowGroups(array $showGroups) |
||
1775 | |||
1776 | public function reorderShowGroup($group, array $keys) |
||
1783 | |||
1784 | public function setParentFieldDescription(FieldDescriptionInterface $parentFieldDescription) |
||
1788 | |||
1789 | public function getParentFieldDescription() |
||
1810 | |||
1811 | public function hasParentFieldDescription() |
||
1815 | |||
1816 | public function setSubject($subject) |
||
1831 | |||
1832 | public function getSubject() |
||
1852 | |||
1853 | public function hasSubject() |
||
1865 | |||
1866 | public function getFormFieldDescriptions() |
||
1872 | |||
1873 | public function getFormFieldDescription($name) |
||
1897 | |||
1898 | /** |
||
1899 | * Returns true if the admin has a FieldDescription with the given $name. |
||
1900 | * |
||
1901 | * @param string $name |
||
1902 | * |
||
1903 | * @return bool |
||
1904 | */ |
||
1905 | public function hasFormFieldDescription($name) |
||
1911 | |||
1912 | public function addFormFieldDescription($name, FieldDescriptionInterface $fieldDescription) |
||
1916 | |||
1917 | /** |
||
1918 | * remove a FieldDescription. |
||
1919 | * |
||
1920 | * @param string $name |
||
1921 | */ |
||
1922 | public function removeFormFieldDescription($name) |
||
1926 | |||
1927 | /** |
||
1928 | * build and return the collection of form FieldDescription. |
||
1929 | * |
||
1930 | * @return FieldDescriptionInterface[] collection of form FieldDescription |
||
1931 | */ |
||
1932 | public function getShowFieldDescriptions() |
||
1938 | |||
1939 | /** |
||
1940 | * Returns the form FieldDescription with the given $name. |
||
1941 | * |
||
1942 | * @param string $name |
||
1943 | * |
||
1944 | * @return FieldDescriptionInterface |
||
1945 | */ |
||
1946 | public function getShowFieldDescription($name) |
||
1970 | |||
1971 | public function hasShowFieldDescription($name) |
||
1977 | |||
1978 | public function addShowFieldDescription($name, FieldDescriptionInterface $fieldDescription) |
||
1982 | |||
1983 | public function removeShowFieldDescription($name) |
||
1987 | |||
1988 | public function getListFieldDescriptions() |
||
1994 | |||
1995 | public function getListFieldDescription($name) |
||
2020 | |||
2021 | public function hasListFieldDescription($name) |
||
2027 | |||
2028 | public function addListFieldDescription($name, FieldDescriptionInterface $fieldDescription) |
||
2032 | |||
2033 | public function removeListFieldDescription($name) |
||
2037 | |||
2038 | public function getFilterFieldDescription($name) |
||
2062 | |||
2063 | public function hasFilterFieldDescription($name) |
||
2069 | |||
2070 | public function addFilterFieldDescription($name, FieldDescriptionInterface $fieldDescription) |
||
2074 | |||
2075 | public function removeFilterFieldDescription($name) |
||
2079 | |||
2080 | public function getFilterFieldDescriptions() |
||
2086 | |||
2087 | public function addChild(AdminInterface $child) |
||
2119 | |||
2120 | public function hasChild($code) |
||
2124 | |||
2125 | public function getChildren() |
||
2129 | |||
2130 | public function getChild($code) |
||
2151 | |||
2152 | public function setParent(AdminInterface $parent) |
||
2156 | |||
2157 | public function getParent() |
||
2177 | |||
2178 | final public function getRootAncestor() |
||
2188 | |||
2189 | final public function getChildDepth() |
||
2201 | |||
2202 | final public function getCurrentLeafChildAdmin() |
||
2216 | |||
2217 | public function isChild() |
||
2221 | |||
2222 | /** |
||
2223 | * Returns true if the admin has children, false otherwise. |
||
2224 | * |
||
2225 | * @return bool if the admin has children |
||
2226 | */ |
||
2227 | public function hasChildren() |
||
2231 | |||
2232 | public function setUniqid($uniqid) |
||
2236 | |||
2237 | public function getUniqid() |
||
2245 | |||
2246 | /** |
||
2247 | * Returns the classname label. |
||
2248 | * |
||
2249 | * @return string the classname label |
||
2250 | */ |
||
2251 | public function getClassnameLabel() |
||
2255 | |||
2256 | public function getPersistentParameters() |
||
2275 | |||
2276 | /** |
||
2277 | * @param string $name |
||
2278 | * |
||
2279 | * @return mixed|null |
||
2280 | */ |
||
2281 | public function getPersistentParameter($name) |
||
2287 | |||
2288 | public function getBreadcrumbs($action) |
||
2299 | |||
2300 | /** |
||
2301 | * Generates the breadcrumbs array. |
||
2302 | * |
||
2303 | * Note: the method will be called by the top admin instance (parent => child) |
||
2304 | * |
||
2305 | * @param string $action |
||
2306 | * |
||
2307 | * @return array |
||
2308 | */ |
||
2309 | public function buildBreadcrumbs($action, ?ItemInterface $menu = null) |
||
2323 | |||
2324 | /** |
||
2325 | * NEXT_MAJOR : remove this method. |
||
2326 | * |
||
2327 | * @return BreadcrumbsBuilderInterface |
||
2328 | */ |
||
2329 | final public function getBreadcrumbsBuilder() |
||
2344 | |||
2345 | /** |
||
2346 | * NEXT_MAJOR : remove this method. |
||
2347 | * |
||
2348 | * @return AbstractAdmin |
||
2349 | */ |
||
2350 | final public function setBreadcrumbsBuilder(BreadcrumbsBuilderInterface $value) |
||
2361 | |||
2362 | public function setCurrentChild($currentChild) |
||
2366 | |||
2367 | /** |
||
2368 | * NEXT_MAJOR: Remove this method. |
||
2369 | * |
||
2370 | * @deprecated since sonata-project/admin-bundle 3.65, to be removed in 4.0 |
||
2371 | */ |
||
2372 | public function getCurrentChild() |
||
2383 | |||
2384 | public function isCurrentChild(): bool |
||
2388 | |||
2389 | /** |
||
2390 | * Returns the current child admin instance. |
||
2391 | * |
||
2392 | * @return AdminInterface|null the current child admin instance |
||
2393 | */ |
||
2394 | public function getCurrentChildAdmin() |
||
2404 | |||
2405 | public function trans($id, array $parameters = [], $domain = null, $locale = null) |
||
2416 | |||
2417 | /** |
||
2418 | * Translate a message id. |
||
2419 | * |
||
2420 | * NEXT_MAJOR: remove this method |
||
2421 | * |
||
2422 | * @param string $id |
||
2423 | * @param int $count |
||
2424 | * @param string|null $domain |
||
2425 | * @param string|null $locale |
||
2426 | * |
||
2427 | * @return string the translated string |
||
2428 | * |
||
2429 | * @deprecated since sonata-project/admin-bundle 3.9, to be removed with 4.0 |
||
2430 | */ |
||
2431 | public function transChoice($id, $count, array $parameters = [], $domain = null, $locale = null) |
||
2442 | |||
2443 | public function setTranslationDomain($translationDomain) |
||
2447 | |||
2448 | public function getTranslationDomain() |
||
2452 | |||
2453 | /** |
||
2454 | * {@inheritdoc} |
||
2455 | * |
||
2456 | * NEXT_MAJOR: remove this method |
||
2457 | * |
||
2458 | * @deprecated since sonata-project/admin-bundle 3.9, to be removed with 4.0 |
||
2459 | * |
||
2460 | * @param DeprecatedTranslatorInterface|TranslatorInterface $translator |
||
2461 | */ |
||
2462 | public function setTranslator($translator) |
||
2484 | |||
2485 | /** |
||
2486 | * {@inheritdoc} |
||
2487 | * |
||
2488 | * NEXT_MAJOR: remove this method |
||
2489 | * |
||
2490 | * @deprecated since sonata-project/admin-bundle 3.9, to be removed with 4.0 |
||
2491 | */ |
||
2492 | public function getTranslator() |
||
2501 | |||
2502 | public function getTranslationLabel($label, $context = '', $type = '') |
||
2506 | |||
2507 | public function setRequest(Request $request) |
||
2515 | |||
2516 | public function getRequest() |
||
2525 | |||
2526 | public function hasRequest() |
||
2530 | |||
2531 | public function setFormContractor(FormContractorInterface $formBuilder) |
||
2535 | |||
2536 | /** |
||
2537 | * @return FormContractorInterface |
||
2538 | */ |
||
2539 | public function getFormContractor() |
||
2543 | |||
2544 | public function setDatagridBuilder(DatagridBuilderInterface $datagridBuilder) |
||
2548 | |||
2549 | public function getDatagridBuilder() |
||
2553 | |||
2554 | public function setListBuilder(ListBuilderInterface $listBuilder) |
||
2558 | |||
2559 | public function getListBuilder() |
||
2563 | |||
2564 | public function setShowBuilder(ShowBuilderInterface $showBuilder) |
||
2568 | |||
2569 | /** |
||
2570 | * @return ShowBuilderInterface |
||
2571 | */ |
||
2572 | public function getShowBuilder() |
||
2576 | |||
2577 | public function setConfigurationPool(Pool $configurationPool) |
||
2581 | |||
2582 | /** |
||
2583 | * @return Pool |
||
2584 | */ |
||
2585 | public function getConfigurationPool() |
||
2589 | |||
2590 | public function setRouteGenerator(RouteGeneratorInterface $routeGenerator) |
||
2594 | |||
2595 | /** |
||
2596 | * @return RouteGeneratorInterface |
||
2597 | */ |
||
2598 | public function getRouteGenerator() |
||
2602 | |||
2603 | public function getCode() |
||
2607 | |||
2608 | /** |
||
2609 | * NEXT_MAJOR: Remove this function. |
||
2610 | * |
||
2611 | * @deprecated This method is deprecated since sonata-project/admin-bundle 3.24 and will be removed in 4.0 |
||
2612 | * |
||
2613 | * @param string $baseCodeRoute |
||
2614 | */ |
||
2615 | public function setBaseCodeRoute($baseCodeRoute) |
||
2624 | |||
2625 | public function getBaseCodeRoute() |
||
2647 | |||
2648 | public function getModelManager() |
||
2652 | |||
2653 | public function setModelManager(ModelManagerInterface $modelManager) |
||
2657 | |||
2658 | public function getManagerType() |
||
2662 | |||
2663 | /** |
||
2664 | * @param string $type |
||
2665 | */ |
||
2666 | public function setManagerType($type) |
||
2670 | |||
2671 | public function getObjectIdentifier() |
||
2675 | |||
2676 | /** |
||
2677 | * Set the roles and permissions per role. |
||
2678 | */ |
||
2679 | public function setSecurityInformation(array $information) |
||
2683 | |||
2684 | public function getSecurityInformation() |
||
2688 | |||
2689 | /** |
||
2690 | * Return the list of permissions the user should have in order to display the admin. |
||
2691 | * |
||
2692 | * @param string $context |
||
2693 | * |
||
2694 | * @return array |
||
2695 | */ |
||
2696 | public function getPermissionsShow($context) |
||
2705 | |||
2706 | public function showIn($context) |
||
2715 | |||
2716 | public function createObjectSecurity($object) |
||
2720 | |||
2721 | public function setSecurityHandler(SecurityHandlerInterface $securityHandler) |
||
2725 | |||
2726 | public function getSecurityHandler() |
||
2730 | |||
2731 | public function isGranted($name, $object = null) |
||
2742 | |||
2743 | public function getUrlSafeIdentifier($model) |
||
2747 | |||
2748 | public function getNormalizedIdentifier($model) |
||
2752 | |||
2753 | public function id($model) |
||
2757 | |||
2758 | public function setValidator($validator) |
||
2770 | |||
2771 | public function getValidator() |
||
2775 | |||
2776 | public function getShow() |
||
2782 | |||
2783 | public function setFormTheme(array $formTheme) |
||
2787 | |||
2788 | public function getFormTheme() |
||
2792 | |||
2793 | public function setFilterTheme(array $filterTheme) |
||
2797 | |||
2798 | public function getFilterTheme() |
||
2802 | |||
2803 | public function addExtension(AdminExtensionInterface $extension) |
||
2807 | |||
2808 | public function getExtensions() |
||
2812 | |||
2813 | public function setMenuFactory(FactoryInterface $menuFactory) |
||
2817 | |||
2818 | public function getMenuFactory() |
||
2822 | |||
2823 | public function setRouteBuilder(RouteBuilderInterface $routeBuilder) |
||
2827 | |||
2828 | public function getRouteBuilder() |
||
2832 | |||
2833 | public function toString($object) |
||
2845 | |||
2846 | public function setLabelTranslatorStrategy(LabelTranslatorStrategyInterface $labelTranslatorStrategy) |
||
2850 | |||
2851 | public function getLabelTranslatorStrategy() |
||
2855 | |||
2856 | public function supportsPreviewMode() |
||
2860 | |||
2861 | /** |
||
2862 | * NEXT_MAJOR: Remove this. |
||
2863 | * |
||
2864 | * @deprecated since sonata-project/admin-bundle 3.67, to be removed in 4.0. |
||
2865 | * |
||
2866 | * Set custom per page options. |
||
2867 | */ |
||
2868 | public function setPerPageOptions(array $options) |
||
2877 | |||
2878 | /** |
||
2879 | * Returns predefined per page options. |
||
2880 | * |
||
2881 | * @return array |
||
2882 | */ |
||
2883 | public function getPerPageOptions() |
||
2895 | |||
2896 | /** |
||
2897 | * Set pager type. |
||
2898 | * |
||
2899 | * @param string $pagerType |
||
2900 | */ |
||
2901 | public function setPagerType($pagerType) |
||
2905 | |||
2906 | /** |
||
2907 | * Get pager type. |
||
2908 | * |
||
2909 | * @return string |
||
2910 | */ |
||
2911 | public function getPagerType() |
||
2915 | |||
2916 | /** |
||
2917 | * Returns true if the per page value is allowed, false otherwise. |
||
2918 | * |
||
2919 | * @param int $perPage |
||
2920 | * |
||
2921 | * @return bool |
||
2922 | */ |
||
2923 | public function determinedPerPageValue($perPage) |
||
2927 | |||
2928 | public function isAclEnabled() |
||
2932 | |||
2933 | public function getObjectMetadata($object) |
||
2937 | |||
2938 | public function getListModes() |
||
2942 | |||
2943 | public function setListMode($mode) |
||
2951 | |||
2952 | public function getListMode() |
||
2960 | |||
2961 | public function getAccessMapping() |
||
2965 | |||
2966 | public function checkAccess($action, $object = null) |
||
2988 | |||
2989 | /** |
||
2990 | * Hook to handle access authorization, without throw Exception. |
||
2991 | * |
||
2992 | * @param string $action |
||
2993 | * @param object $object |
||
2994 | * |
||
2995 | * @return bool |
||
2996 | */ |
||
2997 | public function hasAccess($action, $object = null) |
||
3017 | |||
3018 | /** |
||
3019 | * @param string $action |
||
3020 | * @param object|null $object |
||
3021 | * |
||
3022 | * @return array |
||
3023 | */ |
||
3024 | public function configureActionButtons($action, $object = null) |
||
3098 | |||
3099 | /** |
||
3100 | * @param string $action |
||
3101 | * @param object $object |
||
3102 | * |
||
3103 | * @return array |
||
3104 | */ |
||
3105 | public function getActionButtons($action, $object = null) |
||
3118 | |||
3119 | /** |
||
3120 | * Get the list of actions that can be accessed directly from the dashboard. |
||
3121 | * |
||
3122 | * @return array |
||
3123 | */ |
||
3124 | public function getDashboardActions() |
||
3151 | |||
3152 | /** |
||
3153 | * Setting to true will enable mosaic button for the admin screen. |
||
3154 | * Setting to false will hide mosaic button for the admin screen. |
||
3155 | * |
||
3156 | * @param bool $isShown |
||
3157 | */ |
||
3158 | final public function showMosaicButton($isShown) |
||
3166 | |||
3167 | /** |
||
3168 | * @param object $object |
||
3169 | */ |
||
3170 | final public function getSearchResultLink($object) |
||
3180 | |||
3181 | /** |
||
3182 | * NEXT_MAJOR: remove this method. |
||
3183 | * |
||
3184 | * Checks if a filter type is set to a default value. |
||
3185 | * |
||
3186 | * @param string $name |
||
3187 | * |
||
3188 | * @return bool |
||
3189 | */ |
||
3190 | final public function isDefaultFilter($name) |
||
3206 | |||
3207 | /** |
||
3208 | * Check object existence and access, without throw Exception. |
||
3209 | * |
||
3210 | * @param string $action |
||
3211 | * @param object $object |
||
3212 | * |
||
3213 | * @return bool |
||
3214 | */ |
||
3215 | public function canAccessObject($action, $object) |
||
3219 | |||
3220 | protected function configureQuery(ProxyQueryInterface $query): ProxyQueryInterface |
||
3224 | |||
3225 | /** |
||
3226 | * @return MutableTemplateRegistryInterface |
||
3227 | */ |
||
3228 | final protected function getTemplateRegistry() |
||
3232 | |||
3233 | /** |
||
3234 | * Returns a list of default sort values. |
||
3235 | * |
||
3236 | * @return array{_page?: int, _per_page?: int, _sort_by?: string, _sort_order?: string} |
||
3237 | */ |
||
3238 | final protected function getDefaultSortValues(): array |
||
3253 | |||
3254 | /** |
||
3255 | * Returns a list of default filters. |
||
3256 | * |
||
3257 | * @return array |
||
3258 | */ |
||
3259 | final protected function getDefaultFilterValues() |
||
3274 | |||
3275 | protected function configureFormFields(FormMapper $form) |
||
3278 | |||
3279 | protected function configureListFields(ListMapper $list) |
||
3282 | |||
3283 | protected function configureDatagridFilters(DatagridMapper $filter) |
||
3286 | |||
3287 | protected function configureShowFields(ShowMapper $show) |
||
3290 | |||
3291 | protected function configureRoutes(RouteCollection $collection) |
||
3294 | |||
3295 | /** |
||
3296 | * Allows you to customize batch actions. |
||
3297 | * |
||
3298 | * @param array $actions List of actions |
||
3299 | * |
||
3300 | * @return array |
||
3301 | */ |
||
3302 | protected function configureBatchActions($actions) |
||
3306 | |||
3307 | /** |
||
3308 | * NEXT_MAJOR: remove this method. |
||
3309 | * |
||
3310 | * @deprecated Use configureTabMenu instead |
||
3311 | */ |
||
3312 | protected function configureSideMenu(ItemInterface $menu, string $action, ?AdminInterface $childAdmin = null) |
||
3315 | |||
3316 | /** |
||
3317 | * Configures the tab menu in your admin. |
||
3318 | * |
||
3319 | * @param string $action |
||
3320 | */ |
||
3321 | protected function configureTabMenu(ItemInterface $menu, $action, ?AdminInterface $childAdmin = null) |
||
3327 | |||
3328 | /** |
||
3329 | * build the view FieldDescription array. |
||
3330 | */ |
||
3331 | protected function buildShow() |
||
3348 | |||
3349 | /** |
||
3350 | * build the list FieldDescription array. |
||
3351 | */ |
||
3352 | protected function buildList() |
||
3409 | |||
3410 | /** |
||
3411 | * Build the form FieldDescription collection. |
||
3412 | */ |
||
3413 | protected function buildForm() |
||
3428 | |||
3429 | /** |
||
3430 | * Gets the subclass corresponding to the given name. |
||
3431 | * |
||
3432 | * @param string $name The name of the sub class |
||
3433 | * |
||
3434 | * @return string the subclass |
||
3435 | */ |
||
3436 | protected function getSubClass($name) |
||
3445 | |||
3446 | /** |
||
3447 | * Attach the inline validator to the model metadata, this must be done once per admin. |
||
3448 | */ |
||
3449 | protected function attachInlineValidator() |
||
3486 | |||
3487 | /** |
||
3488 | * NEXT_MAJOR: Remove this function. |
||
3489 | * |
||
3490 | * @deprecated since sonata-project/admin-bundle 3.67, to be removed in 4.0. |
||
3491 | * |
||
3492 | * Predefine per page options. |
||
3493 | */ |
||
3494 | protected function predefinePerPageOptions() |
||
3500 | |||
3501 | /** |
||
3502 | * Return list routes with permissions name. |
||
3503 | * |
||
3504 | * @return array<string, string> |
||
3505 | */ |
||
3506 | protected function getAccess() |
||
3531 | |||
3532 | /** |
||
3533 | * Configures a list of default filters. |
||
3534 | */ |
||
3535 | protected function configureDefaultFilterValues(array &$filterValues) |
||
3538 | |||
3539 | /** |
||
3540 | * Configures a list of default sort values. |
||
3541 | * |
||
3542 | * Example: |
||
3543 | * $sortValues['_sort_by'] = 'foo' |
||
3544 | * $sortValues['_sort_order'] = 'DESC' |
||
3545 | */ |
||
3546 | protected function configureDefaultSortValues(array &$sortValues) |
||
3549 | |||
3550 | /** |
||
3551 | * Set the parent object, if any, to the provided object. |
||
3552 | */ |
||
3553 | final protected function appendParentObject(object $object): void |
||
3581 | |||
3582 | /** |
||
3583 | * Build all the related urls to the current admin. |
||
3584 | */ |
||
3585 | private function buildRoutes(): void |
||
3608 | } |
||
3609 | |||
3611 |
If you suppress an error, we recommend checking for the error condition explicitly: