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 |
||
60 | abstract class AbstractAdmin implements AdminInterface, DomainObjectInterface, AdminTreeInterface |
||
61 | { |
||
62 | public const CONTEXT_MENU = 'menu'; |
||
63 | public const CONTEXT_DASHBOARD = 'dashboard'; |
||
64 | |||
65 | public const CLASS_REGEX = |
||
66 | '@ |
||
67 | (?:([A-Za-z0-9]*)\\\)? # vendor name / app name |
||
68 | (Bundle\\\)? # optional bundle directory |
||
69 | ([A-Za-z0-9]+?)(?:Bundle)?\\\ # bundle name, with optional suffix |
||
70 | ( |
||
71 | Entity|Document|Model|PHPCR|CouchDocument|Phpcr| |
||
72 | Doctrine\\\Orm|Doctrine\\\Phpcr|Doctrine\\\MongoDB|Doctrine\\\CouchDB |
||
73 | )\\\(.*)@x'; |
||
74 | |||
75 | public const MOSAIC_ICON_CLASS = 'fa fa-th-large fa-fw'; |
||
76 | |||
77 | /** |
||
78 | * The list FieldDescription constructed from the configureListField method. |
||
79 | * |
||
80 | * @var array |
||
81 | */ |
||
82 | protected $listFieldDescriptions = []; |
||
83 | |||
84 | /** |
||
85 | * The show FieldDescription constructed from the configureShowFields method. |
||
86 | * |
||
87 | * @var array |
||
88 | */ |
||
89 | protected $showFieldDescriptions = []; |
||
90 | |||
91 | /** |
||
92 | * The list FieldDescription constructed from the configureFormField method. |
||
93 | * |
||
94 | * @var array |
||
95 | */ |
||
96 | protected $formFieldDescriptions = []; |
||
97 | |||
98 | /** |
||
99 | * The filter FieldDescription constructed from the configureFilterField method. |
||
100 | * |
||
101 | * @var array |
||
102 | */ |
||
103 | protected $filterFieldDescriptions = []; |
||
104 | |||
105 | /** |
||
106 | * The number of result to display in the list. |
||
107 | * |
||
108 | * @var int |
||
109 | */ |
||
110 | protected $maxPerPage = 32; |
||
111 | |||
112 | /** |
||
113 | * The maximum number of page numbers to display in the list. |
||
114 | * |
||
115 | * @var int |
||
116 | */ |
||
117 | protected $maxPageLinks = 25; |
||
118 | |||
119 | /** |
||
120 | * The base route name used to generate the routing information. |
||
121 | * |
||
122 | * @var string |
||
123 | */ |
||
124 | protected $baseRouteName; |
||
125 | |||
126 | /** |
||
127 | * The base route pattern used to generate the routing information. |
||
128 | * |
||
129 | * @var string |
||
130 | */ |
||
131 | protected $baseRoutePattern; |
||
132 | |||
133 | /** |
||
134 | * The base name controller used to generate the routing information. |
||
135 | * |
||
136 | * @var string |
||
137 | */ |
||
138 | protected $baseControllerName; |
||
139 | |||
140 | /** |
||
141 | * The label class name (used in the title/breadcrumb ...). |
||
142 | * |
||
143 | * @var string |
||
144 | */ |
||
145 | protected $classnameLabel; |
||
146 | |||
147 | /** |
||
148 | * The translation domain to be used to translate messages. |
||
149 | * |
||
150 | * @var string |
||
151 | */ |
||
152 | protected $translationDomain = 'messages'; |
||
153 | |||
154 | /** |
||
155 | * Options to set to the form (ie, validation_groups). |
||
156 | * |
||
157 | * @var array |
||
158 | */ |
||
159 | protected $formOptions = []; |
||
160 | |||
161 | /** |
||
162 | * Default values to the datagrid. |
||
163 | * |
||
164 | * @var array |
||
165 | */ |
||
166 | protected $datagridValues = [ |
||
167 | '_page' => 1, |
||
168 | '_per_page' => 32, |
||
169 | ]; |
||
170 | |||
171 | /** |
||
172 | * Predefined per page options. |
||
173 | * |
||
174 | * @var array |
||
175 | */ |
||
176 | protected $perPageOptions = [16, 32, 64, 128, 256]; |
||
177 | |||
178 | /** |
||
179 | * Pager type. |
||
180 | * |
||
181 | * @var string |
||
182 | */ |
||
183 | protected $pagerType = Pager::TYPE_DEFAULT; |
||
184 | |||
185 | /** |
||
186 | * The code related to the admin. |
||
187 | * |
||
188 | * @var string |
||
189 | */ |
||
190 | protected $code; |
||
191 | |||
192 | /** |
||
193 | * The label. |
||
194 | * |
||
195 | * @var string |
||
196 | */ |
||
197 | protected $label; |
||
198 | |||
199 | /** |
||
200 | * Whether or not to persist the filters in the session. |
||
201 | * |
||
202 | * NEXT_MAJOR: remove this property |
||
203 | * |
||
204 | * @var bool |
||
205 | * |
||
206 | * @deprecated since 3.34, to be removed in 4.0. |
||
207 | */ |
||
208 | protected $persistFilters = false; |
||
209 | |||
210 | /** |
||
211 | * Array of routes related to this admin. |
||
212 | * |
||
213 | * @var RouteCollection |
||
214 | */ |
||
215 | protected $routes; |
||
216 | |||
217 | /** |
||
218 | * The subject only set in edit/update/create mode. |
||
219 | * |
||
220 | * @var object |
||
221 | */ |
||
222 | protected $subject; |
||
223 | |||
224 | /** |
||
225 | * Define a Collection of child admin, ie /admin/order/{id}/order-element/{childId}. |
||
226 | * |
||
227 | * @var array |
||
228 | */ |
||
229 | protected $children = []; |
||
230 | |||
231 | /** |
||
232 | * Reference the parent collection. |
||
233 | * |
||
234 | * @var AdminInterface|null |
||
235 | */ |
||
236 | protected $parent = null; |
||
237 | |||
238 | /** |
||
239 | * The related parent association, ie if OrderElement has a parent property named order, |
||
240 | * then the $parentAssociationMapping must be a string named `order`. |
||
241 | * |
||
242 | * NEXT_MAJOR: remove this attribute. |
||
243 | * |
||
244 | * @deprecated This attribute is deprecated since 3.24 and will be removed in 4.0 |
||
245 | * |
||
246 | * @var string |
||
247 | */ |
||
248 | protected $baseCodeRoute = ''; |
||
249 | |||
250 | /** |
||
251 | * NEXT_MAJOR: should be default array and private. |
||
252 | * |
||
253 | * @var string|array |
||
254 | */ |
||
255 | protected $parentAssociationMapping = null; |
||
256 | |||
257 | /** |
||
258 | * Reference the parent FieldDescription related to this admin |
||
259 | * only set for FieldDescription which is associated to an Sub Admin instance. |
||
260 | * |
||
261 | * @var FieldDescriptionInterface |
||
262 | */ |
||
263 | protected $parentFieldDescription; |
||
264 | |||
265 | /** |
||
266 | * If true then the current admin is part of the nested admin set (from the url). |
||
267 | * |
||
268 | * @var bool |
||
269 | */ |
||
270 | protected $currentChild = false; |
||
271 | |||
272 | /** |
||
273 | * The uniqid is used to avoid clashing with 2 admin related to the code |
||
274 | * ie: a Block linked to a Block. |
||
275 | * |
||
276 | * @var string |
||
277 | */ |
||
278 | protected $uniqid; |
||
279 | |||
280 | /** |
||
281 | * The Entity or Document manager. |
||
282 | * |
||
283 | * @var ModelManagerInterface |
||
284 | */ |
||
285 | protected $modelManager; |
||
286 | |||
287 | /** |
||
288 | * The current request object. |
||
289 | * |
||
290 | * @var \Symfony\Component\HttpFoundation\Request |
||
291 | */ |
||
292 | protected $request; |
||
293 | |||
294 | /** |
||
295 | * The translator component. |
||
296 | * |
||
297 | * NEXT_MAJOR: remove this property |
||
298 | * |
||
299 | * @var \Symfony\Component\Translation\TranslatorInterface |
||
300 | * |
||
301 | * @deprecated since 3.9, to be removed with 4.0 |
||
302 | */ |
||
303 | protected $translator; |
||
304 | |||
305 | /** |
||
306 | * The related form contractor. |
||
307 | * |
||
308 | * @var FormContractorInterface |
||
309 | */ |
||
310 | protected $formContractor; |
||
311 | |||
312 | /** |
||
313 | * The related list builder. |
||
314 | * |
||
315 | * @var ListBuilderInterface |
||
316 | */ |
||
317 | protected $listBuilder; |
||
318 | |||
319 | /** |
||
320 | * The related view builder. |
||
321 | * |
||
322 | * @var ShowBuilderInterface |
||
323 | */ |
||
324 | protected $showBuilder; |
||
325 | |||
326 | /** |
||
327 | * The related datagrid builder. |
||
328 | * |
||
329 | * @var DatagridBuilderInterface |
||
330 | */ |
||
331 | protected $datagridBuilder; |
||
332 | |||
333 | /** |
||
334 | * @var RouteBuilderInterface |
||
335 | */ |
||
336 | protected $routeBuilder; |
||
337 | |||
338 | /** |
||
339 | * The datagrid instance. |
||
340 | * |
||
341 | * @var \Sonata\AdminBundle\Datagrid\DatagridInterface |
||
342 | */ |
||
343 | protected $datagrid; |
||
344 | |||
345 | /** |
||
346 | * The router instance. |
||
347 | * |
||
348 | * @var RouteGeneratorInterface |
||
349 | */ |
||
350 | protected $routeGenerator; |
||
351 | |||
352 | /** |
||
353 | * @var SecurityHandlerInterface |
||
354 | */ |
||
355 | protected $securityHandler = null; |
||
356 | |||
357 | /** |
||
358 | * @var ValidatorInterface |
||
359 | */ |
||
360 | protected $validator = null; |
||
361 | |||
362 | /** |
||
363 | * The configuration pool. |
||
364 | * |
||
365 | * @var Pool |
||
366 | */ |
||
367 | protected $configurationPool; |
||
368 | |||
369 | /** |
||
370 | * @var MenuItemInterface |
||
371 | */ |
||
372 | protected $menu; |
||
373 | |||
374 | /** |
||
375 | * @var MenuFactoryInterface |
||
376 | */ |
||
377 | protected $menuFactory; |
||
378 | |||
379 | /** |
||
380 | * @var array |
||
381 | */ |
||
382 | protected $loaded = [ |
||
383 | 'view_fields' => false, |
||
384 | 'view_groups' => false, |
||
385 | 'routes' => false, |
||
386 | 'tab_menu' => false, |
||
387 | ]; |
||
388 | |||
389 | /** |
||
390 | * @var array |
||
391 | */ |
||
392 | protected $formTheme = []; |
||
393 | |||
394 | /** |
||
395 | * @var array |
||
396 | */ |
||
397 | protected $filterTheme = []; |
||
398 | |||
399 | /** |
||
400 | * @var array |
||
401 | * |
||
402 | * @deprecated since 3.34, will be dropped in 4.0. Use TemplateRegistry services instead |
||
403 | */ |
||
404 | protected $templates = []; |
||
405 | |||
406 | /** |
||
407 | * @var AdminExtensionInterface[] |
||
408 | */ |
||
409 | protected $extensions = []; |
||
410 | |||
411 | /** |
||
412 | * @var LabelTranslatorStrategyInterface |
||
413 | */ |
||
414 | protected $labelTranslatorStrategy; |
||
415 | |||
416 | /** |
||
417 | * Setting to true will enable preview mode for |
||
418 | * the entity and show a preview button in the |
||
419 | * edit/create forms. |
||
420 | * |
||
421 | * @var bool |
||
422 | */ |
||
423 | protected $supportsPreviewMode = false; |
||
424 | |||
425 | /** |
||
426 | * Roles and permissions per role. |
||
427 | * |
||
428 | * @var array 'role' => ['permission', 'permission'] |
||
429 | */ |
||
430 | protected $securityInformation = []; |
||
431 | |||
432 | protected $cacheIsGranted = []; |
||
433 | |||
434 | /** |
||
435 | * Action list for the search result. |
||
436 | * |
||
437 | * @var string[] |
||
438 | */ |
||
439 | protected $searchResultActions = ['edit', 'show']; |
||
440 | |||
441 | protected $listModes = [ |
||
442 | 'list' => [ |
||
443 | 'class' => 'fa fa-list fa-fw', |
||
444 | ], |
||
445 | 'mosaic' => [ |
||
446 | 'class' => self::MOSAIC_ICON_CLASS, |
||
447 | ], |
||
448 | ]; |
||
449 | |||
450 | /** |
||
451 | * The Access mapping. |
||
452 | * |
||
453 | * @var array [action1 => requiredRole1, action2 => [requiredRole2, requiredRole3]] |
||
454 | */ |
||
455 | protected $accessMapping = []; |
||
456 | |||
457 | /** |
||
458 | * @var MutableTemplateRegistryInterface |
||
459 | */ |
||
460 | private $templateRegistry; |
||
461 | |||
462 | /** |
||
463 | * The class name managed by the admin class. |
||
464 | * |
||
465 | * @var string |
||
466 | */ |
||
467 | private $class; |
||
468 | |||
469 | /** |
||
470 | * The subclasses supported by the admin class. |
||
471 | * |
||
472 | * @var array |
||
473 | */ |
||
474 | private $subClasses = []; |
||
475 | |||
476 | /** |
||
477 | * The list collection. |
||
478 | * |
||
479 | * @var array |
||
480 | */ |
||
481 | private $list; |
||
482 | |||
483 | /** |
||
484 | * @var FieldDescriptionCollection |
||
485 | */ |
||
486 | private $show; |
||
487 | |||
488 | /** |
||
489 | * @var Form |
||
490 | */ |
||
491 | private $form; |
||
492 | |||
493 | /** |
||
494 | * @var DatagridInterface |
||
495 | */ |
||
496 | private $filter; |
||
497 | |||
498 | /** |
||
499 | * The cached base route name. |
||
500 | * |
||
501 | * @var string |
||
502 | */ |
||
503 | private $cachedBaseRouteName; |
||
504 | |||
505 | /** |
||
506 | * The cached base route pattern. |
||
507 | * |
||
508 | * @var string |
||
509 | */ |
||
510 | private $cachedBaseRoutePattern; |
||
511 | |||
512 | /** |
||
513 | * The form group disposition. |
||
514 | * |
||
515 | * @var array|bool |
||
516 | */ |
||
517 | private $formGroups = false; |
||
518 | |||
519 | /** |
||
520 | * The form tabs disposition. |
||
521 | * |
||
522 | * @var array|bool |
||
523 | */ |
||
524 | private $formTabs = false; |
||
525 | |||
526 | /** |
||
527 | * The view group disposition. |
||
528 | * |
||
529 | * @var array|bool |
||
530 | */ |
||
531 | private $showGroups = false; |
||
532 | |||
533 | /** |
||
534 | * The view tab disposition. |
||
535 | * |
||
536 | * @var array|bool |
||
537 | */ |
||
538 | private $showTabs = false; |
||
539 | |||
540 | /** |
||
541 | * The manager type to use for the admin. |
||
542 | * |
||
543 | * @var string |
||
544 | */ |
||
545 | private $managerType; |
||
546 | |||
547 | /** |
||
548 | * Component responsible for persisting filters. |
||
549 | * |
||
550 | * @var FilterPersisterInterface|null |
||
551 | */ |
||
552 | private $filterPersister; |
||
553 | |||
554 | /** |
||
555 | * @param string $code |
||
556 | * @param string $class |
||
557 | * @param string $baseControllerName |
||
558 | */ |
||
559 | public function __construct($code, $class, $baseControllerName) |
||
560 | { |
||
561 | $this->code = $code; |
||
562 | $this->class = $class; |
||
563 | $this->baseControllerName = $baseControllerName; |
||
564 | |||
565 | $this->predefinePerPageOptions(); |
||
566 | $this->datagridValues['_per_page'] = $this->maxPerPage; |
||
567 | } |
||
568 | |||
569 | /** |
||
570 | * {@inheritdoc} |
||
571 | * |
||
572 | * NEXT_MAJOR: return null to indicate no override |
||
573 | */ |
||
574 | public function getExportFormats() |
||
575 | { |
||
576 | return [ |
||
577 | 'json', 'xml', 'csv', 'xls', |
||
578 | ]; |
||
579 | } |
||
580 | |||
581 | /** |
||
582 | * {@inheritdoc} |
||
583 | */ |
||
584 | public function getExportFields() |
||
585 | { |
||
586 | $fields = $this->getModelManager()->getExportFields($this->getClass()); |
||
587 | |||
588 | foreach ($this->getExtensions() as $extension) { |
||
589 | if (method_exists($extension, 'configureExportFields')) { |
||
590 | $fields = $extension->configureExportFields($this, $fields); |
||
591 | } |
||
592 | } |
||
593 | |||
594 | return $fields; |
||
595 | } |
||
596 | |||
597 | public function getDataSourceIterator() |
||
598 | { |
||
599 | $datagrid = $this->getDatagrid(); |
||
600 | $datagrid->buildPager(); |
||
601 | |||
602 | $fields = []; |
||
603 | |||
604 | foreach ($this->getExportFields() as $key => $field) { |
||
605 | $label = $this->getTranslationLabel($field, 'export', 'label'); |
||
606 | $transLabel = $this->trans($label); |
||
607 | |||
608 | // NEXT_MAJOR: Remove this hack, because all field labels will be translated with the major release |
||
609 | // No translation key exists |
||
610 | if ($transLabel == $label) { |
||
611 | $fields[$key] = $field; |
||
612 | } else { |
||
613 | $fields[$transLabel] = $field; |
||
614 | } |
||
615 | } |
||
616 | |||
617 | return $this->getModelManager()->getDataSourceIterator($datagrid, $fields); |
||
618 | } |
||
619 | |||
620 | public function validate(ErrorElement $errorElement, $object): void |
||
621 | { |
||
622 | } |
||
623 | |||
624 | /** |
||
625 | * define custom variable. |
||
626 | */ |
||
627 | public function initialize(): void |
||
628 | { |
||
629 | if (!$this->classnameLabel) { |
||
630 | $this->classnameLabel = substr($this->getClass(), strrpos($this->getClass(), '\\') + 1); |
||
631 | } |
||
632 | |||
633 | $this->configure(); |
||
634 | } |
||
635 | |||
636 | public function update($object) |
||
637 | { |
||
638 | $this->preUpdate($object); |
||
639 | foreach ($this->extensions as $extension) { |
||
640 | $extension->preUpdate($this, $object); |
||
641 | } |
||
642 | |||
643 | $result = $this->getModelManager()->update($object); |
||
644 | // BC compatibility |
||
645 | if (null !== $result) { |
||
646 | $object = $result; |
||
647 | } |
||
648 | |||
649 | $this->postUpdate($object); |
||
650 | foreach ($this->extensions as $extension) { |
||
651 | $extension->postUpdate($this, $object); |
||
652 | } |
||
653 | |||
654 | return $object; |
||
655 | } |
||
656 | |||
657 | public function create($object) |
||
658 | { |
||
659 | $this->prePersist($object); |
||
660 | foreach ($this->extensions as $extension) { |
||
661 | $extension->prePersist($this, $object); |
||
662 | } |
||
663 | |||
664 | $result = $this->getModelManager()->create($object); |
||
665 | // BC compatibility |
||
666 | if (null !== $result) { |
||
667 | $object = $result; |
||
668 | } |
||
669 | |||
670 | $this->postPersist($object); |
||
671 | foreach ($this->extensions as $extension) { |
||
672 | $extension->postPersist($this, $object); |
||
673 | } |
||
674 | |||
675 | $this->createObjectSecurity($object); |
||
676 | |||
677 | return $object; |
||
678 | } |
||
679 | |||
680 | public function delete($object): void |
||
681 | { |
||
682 | $this->preRemove($object); |
||
683 | foreach ($this->extensions as $extension) { |
||
684 | $extension->preRemove($this, $object); |
||
685 | } |
||
686 | |||
687 | $this->getSecurityHandler()->deleteObjectSecurity($this, $object); |
||
688 | $this->getModelManager()->delete($object); |
||
689 | |||
690 | $this->postRemove($object); |
||
691 | foreach ($this->extensions as $extension) { |
||
692 | $extension->postRemove($this, $object); |
||
693 | } |
||
694 | } |
||
695 | |||
696 | public function preValidate($object): void |
||
697 | { |
||
698 | } |
||
699 | |||
700 | public function preUpdate($object): void |
||
701 | { |
||
702 | } |
||
703 | |||
704 | public function postUpdate($object): void |
||
705 | { |
||
706 | } |
||
707 | |||
708 | public function prePersist($object): void |
||
709 | { |
||
710 | } |
||
711 | |||
712 | public function postPersist($object): void |
||
713 | { |
||
714 | } |
||
715 | |||
716 | public function preRemove($object): void |
||
717 | { |
||
718 | } |
||
719 | |||
720 | public function postRemove($object): void |
||
721 | { |
||
722 | } |
||
723 | |||
724 | public function preBatchAction($actionName, ProxyQueryInterface $query, array &$idx, $allElements): void |
||
725 | { |
||
726 | } |
||
727 | |||
728 | public function getFilterParameters() |
||
729 | { |
||
730 | $parameters = []; |
||
731 | |||
732 | // build the values array |
||
733 | if ($this->hasRequest()) { |
||
734 | $filters = $this->request->query->get('filter', []); |
||
735 | |||
736 | // if filter persistence is configured |
||
737 | // NEXT_MAJOR: remove `$this->persistFilters !== false` from the condition |
||
738 | if (false !== $this->persistFilters && null !== $this->filterPersister) { |
||
|
|||
739 | // if reset filters is asked, remove from storage |
||
740 | if ('reset' === $this->request->query->get('filters')) { |
||
741 | $this->filterPersister->reset($this->getCode()); |
||
742 | } |
||
743 | |||
744 | // if no filters, fetch from storage |
||
745 | // otherwise save to storage |
||
746 | if (empty($filters)) { |
||
747 | $filters = $this->filterPersister->get($this->getCode()); |
||
748 | } else { |
||
749 | $this->filterPersister->set($this->getCode(), $filters); |
||
750 | } |
||
751 | } |
||
752 | |||
753 | $parameters = array_merge( |
||
754 | $this->getModelManager()->getDefaultSortValues($this->getClass()), |
||
755 | $this->datagridValues, |
||
756 | $this->getDefaultFilterValues(), |
||
757 | $filters |
||
758 | ); |
||
759 | |||
760 | if (!$this->determinedPerPageValue($parameters['_per_page'])) { |
||
761 | $parameters['_per_page'] = $this->maxPerPage; |
||
762 | } |
||
763 | |||
764 | // always force the parent value |
||
765 | if ($this->isChild() && $this->getParentAssociationMapping()) { |
||
766 | $name = str_replace('.', '__', $this->getParentAssociationMapping()); |
||
767 | $parameters[$name] = ['value' => $this->request->get($this->getParent()->getIdParameter())]; |
||
768 | } |
||
769 | } |
||
770 | |||
771 | return $parameters; |
||
772 | } |
||
773 | |||
774 | /** |
||
775 | * Returns the name of the parent related field, so the field can be use to set the default |
||
776 | * value (ie the parent object) or to filter the object. |
||
777 | * |
||
778 | * @throws \InvalidArgumentException |
||
779 | * |
||
780 | * @return null|string |
||
781 | */ |
||
782 | public function getParentAssociationMapping() |
||
783 | { |
||
784 | // NEXT_MAJOR: remove array check |
||
785 | if (\is_array($this->parentAssociationMapping) && $this->getParent()) { |
||
786 | $parent = $this->getParent()->getCode(); |
||
787 | |||
788 | if (array_key_exists($parent, $this->parentAssociationMapping)) { |
||
789 | return $this->parentAssociationMapping[$parent]; |
||
790 | } |
||
791 | |||
792 | throw new \InvalidArgumentException(sprintf( |
||
793 | "There's no association between %s and %s.", |
||
794 | $this->getCode(), |
||
795 | $this->getParent()->getCode() |
||
796 | )); |
||
797 | } |
||
798 | |||
799 | // NEXT_MAJOR: remove this line |
||
800 | return $this->parentAssociationMapping; |
||
801 | } |
||
802 | |||
803 | /** |
||
804 | * @param string $code |
||
805 | * @param string $value |
||
806 | */ |
||
807 | final public function addParentAssociationMapping($code, $value): void |
||
808 | { |
||
809 | $this->parentAssociationMapping[$code] = $value; |
||
810 | } |
||
811 | |||
812 | /** |
||
813 | * Returns the baseRoutePattern used to generate the routing information. |
||
814 | * |
||
815 | * @throws \RuntimeException |
||
816 | * |
||
817 | * @return string the baseRoutePattern used to generate the routing information |
||
818 | */ |
||
819 | public function getBaseRoutePattern() |
||
820 | { |
||
821 | if (null !== $this->cachedBaseRoutePattern) { |
||
822 | return $this->cachedBaseRoutePattern; |
||
823 | } |
||
824 | |||
825 | if ($this->isChild()) { // the admin class is a child, prefix it with the parent route pattern |
||
826 | if (!$this->baseRoutePattern) { |
||
827 | preg_match(self::CLASS_REGEX, $this->class, $matches); |
||
828 | |||
829 | if (!$matches) { |
||
830 | throw new \RuntimeException(sprintf('Please define a default `baseRoutePattern` value for the admin class `%s`', get_class($this))); |
||
831 | } |
||
832 | } |
||
833 | |||
834 | $this->cachedBaseRoutePattern = sprintf('%s/%s/%s', |
||
835 | $this->getParent()->getBaseRoutePattern(), |
||
836 | $this->getParent()->getRouterIdParameter(), |
||
837 | $this->baseRoutePattern ?: $this->urlize($matches[5], '-') |
||
838 | ); |
||
839 | } elseif ($this->baseRoutePattern) { |
||
840 | $this->cachedBaseRoutePattern = $this->baseRoutePattern; |
||
841 | } else { |
||
842 | preg_match(self::CLASS_REGEX, $this->class, $matches); |
||
843 | |||
844 | if (!$matches) { |
||
845 | throw new \RuntimeException(sprintf('Please define a default `baseRoutePattern` value for the admin class `%s`', get_class($this))); |
||
846 | } |
||
847 | |||
848 | $this->cachedBaseRoutePattern = sprintf('/%s%s/%s', |
||
849 | empty($matches[1]) ? '' : $this->urlize($matches[1], '-').'/', |
||
850 | $this->urlize($matches[3], '-'), |
||
851 | $this->urlize($matches[5], '-') |
||
852 | ); |
||
853 | } |
||
854 | |||
855 | return $this->cachedBaseRoutePattern; |
||
856 | } |
||
857 | |||
858 | /** |
||
859 | * Returns the baseRouteName used to generate the routing information. |
||
860 | * |
||
861 | * @throws \RuntimeException |
||
862 | * |
||
863 | * @return string the baseRouteName used to generate the routing information |
||
864 | */ |
||
865 | public function getBaseRouteName() |
||
866 | { |
||
867 | if (null !== $this->cachedBaseRouteName) { |
||
868 | return $this->cachedBaseRouteName; |
||
869 | } |
||
870 | |||
871 | if ($this->isChild()) { // the admin class is a child, prefix it with the parent route name |
||
872 | if (!$this->baseRouteName) { |
||
873 | preg_match(self::CLASS_REGEX, $this->class, $matches); |
||
874 | |||
875 | if (!$matches) { |
||
876 | throw new \RuntimeException(sprintf('Cannot automatically determine base route name, please define a default `baseRouteName` value for the admin class `%s`', get_class($this))); |
||
877 | } |
||
878 | } |
||
879 | |||
880 | $this->cachedBaseRouteName = sprintf('%s_%s', |
||
881 | $this->getParent()->getBaseRouteName(), |
||
882 | $this->baseRouteName ?: $this->urlize($matches[5]) |
||
883 | ); |
||
884 | } elseif ($this->baseRouteName) { |
||
885 | $this->cachedBaseRouteName = $this->baseRouteName; |
||
886 | } else { |
||
887 | preg_match(self::CLASS_REGEX, $this->class, $matches); |
||
888 | |||
889 | if (!$matches) { |
||
890 | throw new \RuntimeException(sprintf('Cannot automatically determine base route name, please define a default `baseRouteName` value for the admin class `%s`', get_class($this))); |
||
891 | } |
||
892 | |||
893 | $this->cachedBaseRouteName = sprintf('admin_%s%s_%s', |
||
894 | empty($matches[1]) ? '' : $this->urlize($matches[1]).'_', |
||
895 | $this->urlize($matches[3]), |
||
896 | $this->urlize($matches[5]) |
||
897 | ); |
||
898 | } |
||
899 | |||
900 | return $this->cachedBaseRouteName; |
||
901 | } |
||
902 | |||
903 | public function getClass() |
||
904 | { |
||
905 | if ($this->hasActiveSubClass()) { |
||
906 | if ($this->getParentFieldDescription()) { |
||
907 | throw new \RuntimeException('Feature not implemented: an embedded admin cannot have subclass'); |
||
908 | } |
||
909 | |||
910 | $subClass = $this->getRequest()->query->get('subclass'); |
||
911 | |||
912 | if (!$this->hasSubClass($subClass)) { |
||
913 | throw new \RuntimeException(sprintf('Subclass "%" is not defined.', $subClass)); |
||
914 | } |
||
915 | |||
916 | return $this->getSubClass($subClass); |
||
917 | } |
||
918 | |||
919 | // see https://github.com/sonata-project/SonataCoreBundle/commit/247eeb0a7ca7211142e101754769d70bc402a5b4 |
||
920 | if ($this->subject && is_object($this->subject)) { |
||
921 | return ClassUtils::getClass($this->subject); |
||
922 | } |
||
923 | |||
924 | return $this->class; |
||
925 | } |
||
926 | |||
927 | public function getSubClasses() |
||
928 | { |
||
929 | return $this->subClasses; |
||
930 | } |
||
931 | |||
932 | /** |
||
933 | * NEXT_MAJOR: remove this method. |
||
934 | */ |
||
935 | public function addSubClass($subClass): void |
||
936 | { |
||
937 | @trigger_error(sprintf( |
||
938 | 'Method "%s" is deprecated since 3.30 and will be removed in 4.0.', |
||
939 | __METHOD__ |
||
940 | ), E_USER_DEPRECATED); |
||
941 | |||
942 | if (!in_array($subClass, $this->subClasses)) { |
||
943 | $this->subClasses[] = $subClass; |
||
944 | } |
||
945 | } |
||
946 | |||
947 | public function setSubClasses(array $subClasses): void |
||
948 | { |
||
949 | $this->subClasses = $subClasses; |
||
950 | } |
||
951 | |||
952 | public function hasSubClass($name) |
||
953 | { |
||
954 | return isset($this->subClasses[$name]); |
||
955 | } |
||
956 | |||
957 | public function hasActiveSubClass() |
||
958 | { |
||
959 | if (count($this->subClasses) > 0 && $this->request) { |
||
960 | return null !== $this->getRequest()->query->get('subclass'); |
||
961 | } |
||
962 | |||
963 | return false; |
||
964 | } |
||
965 | |||
966 | public function getActiveSubClass() |
||
967 | { |
||
968 | if (!$this->hasActiveSubClass()) { |
||
969 | return; |
||
970 | } |
||
971 | |||
972 | return $this->getSubClass($this->getActiveSubclassCode()); |
||
973 | } |
||
974 | |||
975 | public function getActiveSubclassCode() |
||
976 | { |
||
977 | if (!$this->hasActiveSubClass()) { |
||
978 | return; |
||
979 | } |
||
980 | |||
981 | $subClass = $this->getRequest()->query->get('subclass'); |
||
982 | |||
983 | if (!$this->hasSubClass($subClass)) { |
||
984 | return; |
||
985 | } |
||
986 | |||
987 | return $subClass; |
||
988 | } |
||
989 | |||
990 | public function getBatchActions() |
||
991 | { |
||
992 | $actions = []; |
||
993 | |||
994 | if ($this->hasRoute('delete') && $this->hasAccess('delete')) { |
||
995 | $actions['delete'] = [ |
||
996 | 'label' => 'action_delete', |
||
997 | 'translation_domain' => 'SonataAdminBundle', |
||
998 | 'ask_confirmation' => true, // by default always true |
||
999 | ]; |
||
1000 | } |
||
1001 | |||
1002 | $actions = $this->configureBatchActions($actions); |
||
1003 | |||
1004 | foreach ($this->getExtensions() as $extension) { |
||
1005 | $actions = $extension->configureBatchActions($this, $actions); |
||
1006 | } |
||
1007 | |||
1008 | foreach ($actions as $name => &$action) { |
||
1009 | if (!array_key_exists('label', $action)) { |
||
1010 | $action['label'] = $this->getTranslationLabel($name, 'batch', 'label'); |
||
1011 | } |
||
1012 | |||
1013 | if (!array_key_exists('translation_domain', $action)) { |
||
1014 | $action['translation_domain'] = $this->getTranslationDomain(); |
||
1015 | } |
||
1016 | } |
||
1017 | |||
1018 | return $actions; |
||
1019 | } |
||
1020 | |||
1021 | public function getRoutes() |
||
1022 | { |
||
1023 | $this->buildRoutes(); |
||
1024 | |||
1025 | return $this->routes; |
||
1026 | } |
||
1027 | |||
1028 | public function getRouterIdParameter() |
||
1029 | { |
||
1030 | return '{'.$this->getIdParameter().'}'; |
||
1031 | } |
||
1032 | |||
1033 | public function getIdParameter() |
||
1043 | |||
1044 | public function hasRoute($name) |
||
1045 | { |
||
1046 | if (!$this->routeGenerator) { |
||
1047 | throw new \RuntimeException('RouteGenerator cannot be null'); |
||
1048 | } |
||
1049 | |||
1050 | return $this->routeGenerator->hasAdminRoute($this, $name); |
||
1051 | } |
||
1052 | |||
1053 | public function isCurrentRoute($name, $adminCode = null) |
||
1054 | { |
||
1055 | if (!$this->hasRequest()) { |
||
1056 | return false; |
||
1057 | } |
||
1058 | |||
1059 | $request = $this->getRequest(); |
||
1060 | $route = $request->get('_route'); |
||
1061 | |||
1062 | if ($adminCode) { |
||
1063 | $admin = $this->getConfigurationPool()->getAdminByAdminCode($adminCode); |
||
1064 | } else { |
||
1065 | $admin = $this; |
||
1066 | } |
||
1067 | |||
1068 | if (!$admin) { |
||
1069 | return false; |
||
1070 | } |
||
1071 | |||
1072 | return ($admin->getBaseRouteName().'_'.$name) == $route; |
||
1073 | } |
||
1074 | |||
1075 | public function generateObjectUrl($name, $object, array $parameters = [], $absolute = RoutingUrlGeneratorInterface::ABSOLUTE_PATH) |
||
1076 | { |
||
1077 | $parameters['id'] = $this->getUrlsafeIdentifier($object); |
||
1078 | |||
1081 | |||
1082 | public function generateUrl($name, array $parameters = [], $absolute = RoutingUrlGeneratorInterface::ABSOLUTE_PATH) |
||
1086 | |||
1087 | public function generateMenuUrl($name, array $parameters = [], $absolute = RoutingUrlGeneratorInterface::ABSOLUTE_PATH) |
||
1091 | |||
1092 | final public function setTemplateRegistry(MutableTemplateRegistryInterface $templateRegistry): void |
||
1096 | |||
1097 | public function setTemplates(array $templates): void |
||
1104 | |||
1105 | /** |
||
1106 | * {@inheritdoc} |
||
1107 | */ |
||
1108 | public function setTemplate($name, $template): void |
||
1115 | |||
1116 | /** |
||
1117 | * @deprecated since 3.34, will be dropped in 4.0. Use TemplateRegistry services instead |
||
1118 | * |
||
1119 | * @return array |
||
1120 | */ |
||
1121 | public function getTemplates(): array |
||
1125 | |||
1126 | /** |
||
1127 | * @deprecated since 3.34, will be dropped in 4.0. Use TemplateRegistry services instead |
||
1128 | * |
||
1129 | * @param string $name |
||
1130 | * |
||
1131 | * @return null|string |
||
1132 | */ |
||
1133 | public function getTemplate($name) |
||
1137 | |||
1138 | public function getNewInstance() |
||
1147 | |||
1148 | public function getFormBuilder() |
||
1161 | |||
1162 | /** |
||
1163 | * This method is being called by the main admin class and the child class, |
||
1164 | * the getFormBuilder is only call by the main admin class. |
||
1165 | */ |
||
1166 | public function defineFormBuilder(FormBuilderInterface $formBuilder): void |
||
1178 | |||
1179 | public function attachAdminClass(FieldDescriptionInterface $fieldDescription): void |
||
1201 | |||
1202 | public function getObject($id) |
||
1211 | |||
1212 | public function getForm() |
||
1218 | |||
1219 | public function getList() |
||
1225 | |||
1226 | public function createQuery($context = 'list') |
||
1242 | |||
1243 | public function getDatagrid() |
||
1249 | |||
1250 | public function buildTabMenu($action, AdminInterface $childAdmin = null): void |
||
1275 | |||
1276 | /** |
||
1277 | * @param string $action |
||
1278 | * |
||
1279 | * @return ItemInterface |
||
1280 | */ |
||
1281 | public function getSideMenu($action, AdminInterface $childAdmin = null) |
||
1291 | |||
1292 | /** |
||
1293 | * Returns the root code. |
||
1294 | * |
||
1295 | * @return string the root code |
||
1296 | */ |
||
1297 | public function getRootCode() |
||
1301 | |||
1302 | /** |
||
1303 | * Returns the master admin. |
||
1304 | * |
||
1305 | * @return AbstractAdmin the root admin class |
||
1306 | */ |
||
1307 | public function getRoot() |
||
1317 | |||
1318 | public function setBaseControllerName($baseControllerName): void |
||
1322 | |||
1323 | public function getBaseControllerName() |
||
1327 | |||
1328 | /** |
||
1329 | * @param string $label |
||
1330 | */ |
||
1331 | public function setLabel($label): void |
||
1335 | |||
1336 | public function getLabel() |
||
1340 | |||
1341 | /** |
||
1342 | * @param bool $persist |
||
1343 | * |
||
1344 | * NEXT_MAJOR: remove this method |
||
1345 | * |
||
1346 | * @deprecated since 3.34, to be removed in 4.0. |
||
1347 | */ |
||
1348 | public function setPersistFilters($persist): void |
||
1357 | |||
1358 | /** |
||
1359 | * @param FilterPersisterInterface|null $filterPersister |
||
1360 | */ |
||
1361 | public function setFilterPersister(FilterPersisterInterface $filterPersister = null): void |
||
1367 | |||
1368 | /** |
||
1369 | * @param int $maxPerPage |
||
1370 | */ |
||
1371 | public function setMaxPerPage($maxPerPage): void |
||
1375 | |||
1376 | /** |
||
1377 | * @return int |
||
1378 | */ |
||
1379 | public function getMaxPerPage() |
||
1383 | |||
1384 | /** |
||
1385 | * @param int $maxPageLinks |
||
1386 | */ |
||
1387 | public function setMaxPageLinks($maxPageLinks): void |
||
1391 | |||
1392 | /** |
||
1393 | * @return int |
||
1394 | */ |
||
1395 | public function getMaxPageLinks() |
||
1399 | |||
1400 | public function getFormGroups() |
||
1404 | |||
1405 | public function setFormGroups(array $formGroups): void |
||
1409 | |||
1410 | public function removeFieldFromFormGroup($key): void |
||
1420 | |||
1421 | /** |
||
1422 | * @param array $group |
||
1423 | */ |
||
1424 | public function reorderFormGroup($group, array $keys): void |
||
1430 | |||
1431 | public function getFormTabs() |
||
1435 | |||
1436 | public function setFormTabs(array $formTabs): void |
||
1440 | |||
1441 | public function getShowTabs() |
||
1445 | |||
1446 | public function setShowTabs(array $showTabs): void |
||
1450 | |||
1451 | public function getShowGroups() |
||
1455 | |||
1456 | public function setShowGroups(array $showGroups): void |
||
1460 | |||
1461 | public function reorderShowGroup($group, array $keys): void |
||
1467 | |||
1468 | public function setParentFieldDescription(FieldDescriptionInterface $parentFieldDescription): void |
||
1472 | |||
1473 | public function getParentFieldDescription() |
||
1477 | |||
1478 | public function hasParentFieldDescription() |
||
1482 | |||
1483 | public function setSubject($subject): void |
||
1500 | |||
1501 | public function getSubject() |
||
1513 | |||
1514 | public function hasSubject() |
||
1518 | |||
1519 | public function getFormFieldDescriptions() |
||
1525 | |||
1526 | public function getFormFieldDescription($name) |
||
1530 | |||
1531 | /** |
||
1532 | * Returns true if the admin has a FieldDescription with the given $name. |
||
1533 | * |
||
1534 | * @param string $name |
||
1535 | * |
||
1536 | * @return bool |
||
1537 | */ |
||
1538 | public function hasFormFieldDescription($name) |
||
1542 | |||
1543 | public function addFormFieldDescription($name, FieldDescriptionInterface $fieldDescription): void |
||
1547 | |||
1548 | /** |
||
1549 | * remove a FieldDescription. |
||
1550 | * |
||
1551 | * @param string $name |
||
1552 | */ |
||
1553 | public function removeFormFieldDescription($name): void |
||
1557 | |||
1558 | /** |
||
1559 | * build and return the collection of form FieldDescription. |
||
1560 | * |
||
1561 | * @return array collection of form FieldDescription |
||
1562 | */ |
||
1563 | public function getShowFieldDescriptions() |
||
1569 | |||
1570 | /** |
||
1571 | * Returns the form FieldDescription with the given $name. |
||
1572 | * |
||
1573 | * @param string $name |
||
1574 | * |
||
1575 | * @return FieldDescriptionInterface |
||
1576 | */ |
||
1577 | public function getShowFieldDescription($name) |
||
1583 | |||
1584 | public function hasShowFieldDescription($name) |
||
1588 | |||
1589 | public function addShowFieldDescription($name, FieldDescriptionInterface $fieldDescription): void |
||
1593 | |||
1594 | public function removeShowFieldDescription($name): void |
||
1598 | |||
1599 | public function getListFieldDescriptions() |
||
1605 | |||
1606 | public function getListFieldDescription($name) |
||
1610 | |||
1611 | public function hasListFieldDescription($name) |
||
1617 | |||
1618 | public function addListFieldDescription($name, FieldDescriptionInterface $fieldDescription): void |
||
1622 | |||
1623 | public function removeListFieldDescription($name): void |
||
1627 | |||
1628 | public function getFilterFieldDescription($name) |
||
1632 | |||
1633 | public function hasFilterFieldDescription($name) |
||
1637 | |||
1638 | public function addFilterFieldDescription($name, FieldDescriptionInterface $fieldDescription): void |
||
1642 | |||
1643 | public function removeFilterFieldDescription($name): void |
||
1647 | |||
1648 | public function getFilterFieldDescriptions() |
||
1654 | |||
1655 | public function addChild(AdminInterface $child): void |
||
1686 | |||
1687 | public function hasChild($code) |
||
1691 | |||
1692 | public function getChildren() |
||
1696 | |||
1697 | public function getChild($code) |
||
1701 | |||
1702 | public function setParent(AdminInterface $parent): void |
||
1706 | |||
1707 | public function getParent() |
||
1711 | |||
1712 | final public function getRootAncestor() |
||
1722 | |||
1723 | final public function getChildDepth() |
||
1735 | |||
1736 | final public function getCurrentLeafChildAdmin() |
||
1750 | |||
1751 | public function isChild() |
||
1755 | |||
1756 | /** |
||
1757 | * Returns true if the admin has children, false otherwise. |
||
1758 | * |
||
1759 | * @return bool if the admin has children |
||
1760 | */ |
||
1761 | public function hasChildren() |
||
1765 | |||
1766 | public function setUniqid($uniqid): void |
||
1770 | |||
1771 | public function getUniqid() |
||
1779 | |||
1780 | /** |
||
1781 | * {@inheritdoc} |
||
1782 | */ |
||
1783 | public function getClassnameLabel() |
||
1787 | |||
1788 | public function getPersistentParameters() |
||
1804 | |||
1805 | /** |
||
1806 | * {@inheritdoc} |
||
1807 | */ |
||
1808 | public function getPersistentParameter($name) |
||
1814 | |||
1815 | public function setCurrentChild($currentChild): void |
||
1819 | |||
1820 | public function getCurrentChild() |
||
1824 | |||
1825 | /** |
||
1826 | * Returns the current child admin instance. |
||
1827 | * |
||
1828 | * @return AdminInterface|null the current child admin instance |
||
1829 | */ |
||
1830 | public function getCurrentChildAdmin() |
||
1838 | |||
1839 | public function trans($id, array $parameters = [], $domain = null, $locale = null) |
||
1850 | |||
1851 | /** |
||
1852 | * Translate a message id. |
||
1853 | * |
||
1854 | * NEXT_MAJOR: remove this method |
||
1855 | * |
||
1856 | * @param string $id |
||
1857 | * @param int $count |
||
1858 | * @param string|null $domain |
||
1859 | * @param string|null $locale |
||
1860 | * |
||
1861 | * @return string the translated string |
||
1862 | * |
||
1863 | * @deprecated since 3.9, to be removed with 4.0 |
||
1864 | */ |
||
1865 | public function transChoice($id, $count, array $parameters = [], $domain = null, $locale = null) |
||
1876 | |||
1877 | public function setTranslationDomain($translationDomain): void |
||
1881 | |||
1882 | public function getTranslationDomain() |
||
1886 | |||
1887 | /** |
||
1888 | * {@inheritdoc} |
||
1889 | * |
||
1890 | * NEXT_MAJOR: remove this method |
||
1891 | * |
||
1892 | * @deprecated since 3.9, to be removed with 4.0 |
||
1893 | */ |
||
1894 | public function setTranslator(TranslatorInterface $translator): void |
||
1906 | |||
1907 | /** |
||
1908 | * {@inheritdoc} |
||
1909 | * |
||
1910 | * NEXT_MAJOR: remove this method |
||
1911 | * |
||
1912 | * @deprecated since 3.9, to be removed with 4.0 |
||
1913 | */ |
||
1914 | public function getTranslator() |
||
1923 | |||
1924 | public function getTranslationLabel($label, $context = '', $type = '') |
||
1928 | |||
1929 | public function setRequest(Request $request): void |
||
1937 | |||
1938 | public function getRequest() |
||
1946 | |||
1947 | public function hasRequest() |
||
1951 | |||
1952 | public function setFormContractor(FormContractorInterface $formBuilder): void |
||
1956 | |||
1957 | /** |
||
1958 | * @return FormContractorInterface |
||
1959 | */ |
||
1960 | public function getFormContractor() |
||
1964 | |||
1965 | public function setDatagridBuilder(DatagridBuilderInterface $datagridBuilder): void |
||
1969 | |||
1970 | public function getDatagridBuilder() |
||
1974 | |||
1975 | public function setListBuilder(ListBuilderInterface $listBuilder): void |
||
1979 | |||
1980 | public function getListBuilder() |
||
1984 | |||
1985 | public function setShowBuilder(ShowBuilderInterface $showBuilder): void |
||
1989 | |||
1990 | /** |
||
1991 | * @return ShowBuilderInterface |
||
1992 | */ |
||
1993 | public function getShowBuilder() |
||
1997 | |||
1998 | public function setConfigurationPool(Pool $configurationPool): void |
||
2002 | |||
2003 | /** |
||
2004 | * @return Pool |
||
2005 | */ |
||
2006 | public function getConfigurationPool() |
||
2010 | |||
2011 | public function setRouteGenerator(RouteGeneratorInterface $routeGenerator): void |
||
2015 | |||
2016 | /** |
||
2017 | * @return RouteGeneratorInterface |
||
2018 | */ |
||
2019 | public function getRouteGenerator() |
||
2023 | |||
2024 | public function getCode() |
||
2028 | |||
2029 | public function getBaseCodeRoute() |
||
2037 | |||
2038 | public function getModelManager() |
||
2042 | |||
2043 | public function setModelManager(ModelManagerInterface $modelManager): void |
||
2047 | |||
2048 | public function getManagerType() |
||
2052 | |||
2053 | /** |
||
2054 | * @param string $type |
||
2055 | */ |
||
2056 | public function setManagerType($type): void |
||
2060 | |||
2061 | public function getObjectIdentifier() |
||
2065 | |||
2066 | /** |
||
2067 | * Set the roles and permissions per role. |
||
2068 | */ |
||
2069 | public function setSecurityInformation(array $information): void |
||
2073 | |||
2074 | public function getSecurityInformation() |
||
2078 | |||
2079 | /** |
||
2080 | * Return the list of permissions the user should have in order to display the admin. |
||
2081 | * |
||
2082 | * @param string $context |
||
2083 | * |
||
2084 | * @return array |
||
2085 | */ |
||
2086 | public function getPermissionsShow($context) |
||
2095 | |||
2096 | public function showIn($context) |
||
2105 | |||
2106 | public function createObjectSecurity($object): void |
||
2110 | |||
2111 | public function setSecurityHandler(SecurityHandlerInterface $securityHandler): void |
||
2115 | |||
2116 | public function getSecurityHandler() |
||
2120 | |||
2121 | public function isGranted($name, $object = null) |
||
2131 | |||
2132 | public function getUrlsafeIdentifier($entity) |
||
2136 | |||
2137 | public function getNormalizedIdentifier($entity) |
||
2141 | |||
2142 | public function id($entity) |
||
2146 | |||
2147 | public function setValidator($validator): void |
||
2158 | |||
2159 | public function getValidator() |
||
2163 | |||
2164 | public function getShow() |
||
2170 | |||
2171 | public function setFormTheme(array $formTheme): void |
||
2175 | |||
2176 | public function getFormTheme() |
||
2180 | |||
2181 | public function setFilterTheme(array $filterTheme): void |
||
2185 | |||
2186 | public function getFilterTheme() |
||
2190 | |||
2191 | public function addExtension(AdminExtensionInterface $extension): void |
||
2195 | |||
2196 | public function getExtensions() |
||
2200 | |||
2201 | public function setMenuFactory(MenuFactoryInterface $menuFactory): void |
||
2205 | |||
2206 | public function getMenuFactory() |
||
2210 | |||
2211 | public function setRouteBuilder(RouteBuilderInterface $routeBuilder): void |
||
2215 | |||
2216 | public function getRouteBuilder() |
||
2220 | |||
2221 | public function toString($object) |
||
2233 | |||
2234 | public function setLabelTranslatorStrategy(LabelTranslatorStrategyInterface $labelTranslatorStrategy): void |
||
2238 | |||
2239 | public function getLabelTranslatorStrategy() |
||
2243 | |||
2244 | public function supportsPreviewMode() |
||
2248 | |||
2249 | /** |
||
2250 | * Set custom per page options. |
||
2251 | */ |
||
2252 | public function setPerPageOptions(array $options): void |
||
2256 | |||
2257 | /** |
||
2258 | * Returns predefined per page options. |
||
2259 | * |
||
2260 | * @return array |
||
2261 | */ |
||
2262 | public function getPerPageOptions() |
||
2266 | |||
2267 | /** |
||
2268 | * Set pager type. |
||
2269 | * |
||
2270 | * @param string $pagerType |
||
2271 | */ |
||
2272 | public function setPagerType($pagerType): void |
||
2276 | |||
2277 | /** |
||
2278 | * Get pager type. |
||
2279 | * |
||
2280 | * @return string |
||
2281 | */ |
||
2282 | public function getPagerType() |
||
2286 | |||
2287 | /** |
||
2288 | * Returns true if the per page value is allowed, false otherwise. |
||
2289 | * |
||
2290 | * @param int $perPage |
||
2291 | * |
||
2292 | * @return bool |
||
2293 | */ |
||
2294 | public function determinedPerPageValue($perPage) |
||
2298 | |||
2299 | public function isAclEnabled() |
||
2303 | |||
2304 | public function getObjectMetadata($object) |
||
2308 | |||
2309 | public function getListModes() |
||
2313 | |||
2314 | public function setListMode($mode): void |
||
2322 | |||
2323 | public function getListMode() |
||
2331 | |||
2332 | public function getAccessMapping() |
||
2336 | |||
2337 | public function checkAccess($action, $object = null): void |
||
2359 | |||
2360 | /** |
||
2361 | * {@inheritdoc} |
||
2362 | */ |
||
2363 | public function hasAccess($action, $object = null) |
||
2383 | |||
2384 | final public function getActionButtons($action, $object = null) |
||
2452 | |||
2453 | /** |
||
2454 | * {@inheritdoc} |
||
2455 | */ |
||
2456 | public function getDashboardActions() |
||
2483 | |||
2484 | /** |
||
2485 | * {@inheritdoc} |
||
2486 | */ |
||
2487 | final public function showMosaicButton($isShown): void |
||
2495 | |||
2496 | /** |
||
2497 | * {@inheritdoc} |
||
2498 | */ |
||
2499 | final public function getSearchResultLink($object) |
||
2507 | |||
2508 | /** |
||
2509 | * Checks if a filter type is set to a default value. |
||
2510 | * |
||
2511 | * @param string $name |
||
2512 | * |
||
2513 | * @return bool |
||
2514 | */ |
||
2515 | final public function isDefaultFilter($name) |
||
2526 | |||
2527 | /** |
||
2528 | * Check object existence and access, without throw Exception. |
||
2529 | * |
||
2530 | * @param string $action |
||
2531 | * @param object $object |
||
2532 | * |
||
2533 | * @return bool |
||
2534 | */ |
||
2535 | public function canAccessObject($action, $object) |
||
2539 | |||
2540 | /** |
||
2541 | * Hook to run after initilization. |
||
2542 | */ |
||
2543 | protected function configure(): void |
||
2546 | |||
2547 | /** |
||
2548 | * urlize the given word. |
||
2549 | * |
||
2550 | * @param string $word |
||
2551 | * @param string $sep the separator |
||
2552 | * |
||
2553 | * @return string |
||
2554 | */ |
||
2555 | final protected function urlize($word, $sep = '_') |
||
2559 | |||
2560 | final protected function getTemplateRegistry(): MutableTemplateRegistryInterface |
||
2564 | |||
2565 | /** |
||
2566 | * Returns a list of default filters. |
||
2567 | * |
||
2568 | * @return array |
||
2569 | */ |
||
2570 | final protected function getDefaultFilterValues() |
||
2585 | |||
2586 | protected function configureFormFields(FormMapper $form): void |
||
2589 | |||
2590 | protected function configureListFields(ListMapper $list): void |
||
2593 | |||
2594 | protected function configureDatagridFilters(DatagridMapper $filter): void |
||
2597 | |||
2598 | protected function configureShowFields(ShowMapper $show): void |
||
2601 | |||
2602 | protected function configureRoutes(RouteCollection $collection): void |
||
2605 | |||
2606 | protected function configureActionButtons($buttonList, $action, $object = null) |
||
2610 | |||
2611 | /** |
||
2612 | * Allows you to customize batch actions. |
||
2613 | * |
||
2614 | * @param array $actions List of actions |
||
2615 | * |
||
2616 | * @return array |
||
2617 | */ |
||
2618 | protected function configureBatchActions($actions) |
||
2622 | |||
2623 | /** |
||
2624 | * NEXT_MAJOR: remove this method. |
||
2625 | * |
||
2626 | * @return mixed |
||
2627 | * |
||
2628 | * @deprecated Use configureTabMenu instead |
||
2629 | */ |
||
2630 | protected function configureSideMenu(MenuItemInterface $menu, $action, AdminInterface $childAdmin = null) |
||
2633 | |||
2634 | /** |
||
2635 | * Configures the tab menu in your admin. |
||
2636 | * |
||
2637 | * @param string $action |
||
2638 | * |
||
2639 | * @return mixed |
||
2640 | */ |
||
2641 | protected function configureTabMenu(MenuItemInterface $menu, $action, AdminInterface $childAdmin = null) |
||
2647 | |||
2648 | /** |
||
2649 | * build the view FieldDescription array. |
||
2650 | */ |
||
2651 | protected function buildShow(): void |
||
2666 | |||
2667 | /** |
||
2668 | * build the list FieldDescription array. |
||
2669 | */ |
||
2670 | protected function buildList(): void |
||
2726 | |||
2727 | /** |
||
2728 | * Build the form FieldDescription collection. |
||
2729 | */ |
||
2730 | protected function buildForm(): void |
||
2763 | |||
2764 | /** |
||
2765 | * Gets the subclass corresponding to the given name. |
||
2766 | * |
||
2767 | * @param string $name The name of the sub class |
||
2768 | * |
||
2769 | * @return string the subclass |
||
2770 | */ |
||
2771 | protected function getSubClass($name) |
||
2783 | |||
2784 | /** |
||
2785 | * Attach the inline validator to the model metadata, this must be done once per admin. |
||
2786 | */ |
||
2787 | protected function attachInlineValidator(): void |
||
2814 | |||
2815 | /** |
||
2816 | * Predefine per page options. |
||
2817 | */ |
||
2818 | protected function predefinePerPageOptions(): void |
||
2824 | |||
2825 | /** |
||
2826 | * Return list routes with permissions name. |
||
2827 | * |
||
2828 | * @return array |
||
2829 | */ |
||
2830 | protected function getAccess() |
||
2852 | |||
2853 | /** |
||
2854 | * Returns a list of default filters. |
||
2855 | */ |
||
2856 | protected function configureDefaultFilterValues(array &$filterValues): void |
||
2859 | |||
2860 | /** |
||
2861 | * {@inheritdoc} |
||
2862 | */ |
||
2863 | private function buildDatagrid(): void |
||
2915 | |||
2916 | /** |
||
2917 | * Build all the related urls to the current admin. |
||
2918 | */ |
||
2919 | private function buildRoutes(): void |
||
2942 | } |
||
2943 |
This property has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.