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 |
||
59 | abstract class AbstractAdmin implements AdminInterface, DomainObjectInterface, AdminTreeInterface |
||
60 | { |
||
61 | public const CONTEXT_MENU = 'menu'; |
||
62 | public const CONTEXT_DASHBOARD = 'dashboard'; |
||
63 | |||
64 | public const CLASS_REGEX = |
||
65 | '@ |
||
66 | (?:([A-Za-z0-9]*)\\\)? # vendor name / app name |
||
67 | (Bundle\\\)? # optional bundle directory |
||
68 | ([A-Za-z0-9]+?)(?:Bundle)?\\\ # bundle name, with optional suffix |
||
69 | ( |
||
70 | Entity|Document|Model|PHPCR|CouchDocument|Phpcr| |
||
71 | Doctrine\\\Orm|Doctrine\\\Phpcr|Doctrine\\\MongoDB|Doctrine\\\CouchDB |
||
72 | )\\\(.*)@x'; |
||
73 | |||
74 | public const MOSAIC_ICON_CLASS = 'fa fa-th-large fa-fw'; |
||
75 | |||
76 | /** |
||
77 | * The list FieldDescription constructed from the configureListField method. |
||
78 | * |
||
79 | * @var FieldDescriptionInterface[] |
||
80 | */ |
||
81 | protected $listFieldDescriptions = []; |
||
82 | |||
83 | /** |
||
84 | * The show FieldDescription constructed from the configureShowFields method. |
||
85 | * |
||
86 | * @var FieldDescriptionInterface[] |
||
87 | */ |
||
88 | protected $showFieldDescriptions = []; |
||
89 | |||
90 | /** |
||
91 | * The list FieldDescription constructed from the configureFormField method. |
||
92 | * |
||
93 | * @var FieldDescriptionInterface[] |
||
94 | */ |
||
95 | protected $formFieldDescriptions = []; |
||
96 | |||
97 | /** |
||
98 | * The filter FieldDescription constructed from the configureFilterField method. |
||
99 | * |
||
100 | * @var FieldDescriptionInterface[] |
||
101 | */ |
||
102 | protected $filterFieldDescriptions = []; |
||
103 | |||
104 | /** |
||
105 | * NEXT_MAJOR: Remove this property. |
||
106 | * |
||
107 | * The number of result to display in the list. |
||
108 | * |
||
109 | * @deprecated since sonata-project/admin-bundle 3.67. |
||
110 | * |
||
111 | * @var int |
||
112 | */ |
||
113 | protected $maxPerPage = 32; |
||
114 | |||
115 | /** |
||
116 | * The maximum number of page numbers to display in the list. |
||
117 | * |
||
118 | * @var int |
||
119 | */ |
||
120 | protected $maxPageLinks = 25; |
||
121 | |||
122 | /** |
||
123 | * The base route name used to generate the routing information. |
||
124 | * |
||
125 | * @var string |
||
126 | */ |
||
127 | protected $baseRouteName; |
||
128 | |||
129 | /** |
||
130 | * The base route pattern used to generate the routing information. |
||
131 | * |
||
132 | * @var string |
||
133 | */ |
||
134 | protected $baseRoutePattern; |
||
135 | |||
136 | /** |
||
137 | * The base name controller used to generate the routing information. |
||
138 | * |
||
139 | * @var string |
||
140 | */ |
||
141 | protected $baseControllerName; |
||
142 | |||
143 | /** |
||
144 | * The label class name (used in the title/breadcrumb ...). |
||
145 | * |
||
146 | * @var string |
||
147 | */ |
||
148 | protected $classnameLabel; |
||
149 | |||
150 | /** |
||
151 | * The translation domain to be used to translate messages. |
||
152 | * |
||
153 | * @var string |
||
154 | */ |
||
155 | protected $translationDomain = 'messages'; |
||
156 | |||
157 | /** |
||
158 | * Options to set to the form (ie, validation_groups). |
||
159 | * |
||
160 | * @var array |
||
161 | */ |
||
162 | protected $formOptions = []; |
||
163 | |||
164 | /** |
||
165 | * NEXT_MAJOR: Remove this property. |
||
166 | * |
||
167 | * Default values to the datagrid. |
||
168 | * |
||
169 | * @deprecated since sonata-project/admin-bundle 3.67, use configureDefaultSortValues() instead. |
||
170 | * |
||
171 | * @var array |
||
172 | */ |
||
173 | protected $datagridValues = [ |
||
174 | '_page' => 1, |
||
175 | '_per_page' => 32, |
||
176 | ]; |
||
177 | |||
178 | /** |
||
179 | * NEXT_MAJOR: Remove this property. |
||
180 | * |
||
181 | * Predefined per page options. |
||
182 | * |
||
183 | * @deprecated since sonata-project/admin-bundle 3.67. |
||
184 | * |
||
185 | * @var array |
||
186 | */ |
||
187 | protected $perPageOptions = [16, 32, 64, 128, 256]; |
||
188 | |||
189 | /** |
||
190 | * Pager type. |
||
191 | * |
||
192 | * @var string |
||
193 | */ |
||
194 | protected $pagerType = Pager::TYPE_DEFAULT; |
||
195 | |||
196 | /** |
||
197 | * The code related to the admin. |
||
198 | * |
||
199 | * @var string |
||
200 | */ |
||
201 | protected $code; |
||
202 | |||
203 | /** |
||
204 | * The label. |
||
205 | * |
||
206 | * @var string |
||
207 | */ |
||
208 | protected $label; |
||
209 | |||
210 | /** |
||
211 | * Whether or not to persist the filters in the session. |
||
212 | * |
||
213 | * NEXT_MAJOR: remove this property |
||
214 | * |
||
215 | * @var bool |
||
216 | * |
||
217 | * @deprecated since sonata-project/admin-bundle 3.34, to be removed in 4.0. |
||
218 | */ |
||
219 | protected $persistFilters = false; |
||
220 | |||
221 | /** |
||
222 | * Array of routes related to this admin. |
||
223 | * |
||
224 | * @var RouteCollection |
||
225 | */ |
||
226 | protected $routes; |
||
227 | |||
228 | /** |
||
229 | * The subject only set in edit/update/create mode. |
||
230 | * |
||
231 | * @var object|null |
||
232 | */ |
||
233 | protected $subject; |
||
234 | |||
235 | /** |
||
236 | * Define a Collection of child admin, ie /admin/order/{id}/order-element/{childId}. |
||
237 | * |
||
238 | * @var array |
||
239 | */ |
||
240 | protected $children = []; |
||
241 | |||
242 | /** |
||
243 | * Reference the parent admin. |
||
244 | * |
||
245 | * @var AdminInterface|null |
||
246 | */ |
||
247 | protected $parent; |
||
248 | |||
249 | /** |
||
250 | * The base code route refer to the prefix used to generate the route name. |
||
251 | * |
||
252 | * NEXT_MAJOR: remove this attribute. |
||
253 | * |
||
254 | * @deprecated This attribute is deprecated since sonata-project/admin-bundle 3.24 and will be removed in 4.0 |
||
255 | * |
||
256 | * @var string |
||
257 | */ |
||
258 | protected $baseCodeRoute = ''; |
||
259 | |||
260 | /** |
||
261 | * NEXT_MAJOR: should be default array and private. |
||
262 | * |
||
263 | * @var string|array |
||
264 | */ |
||
265 | protected $parentAssociationMapping; |
||
266 | |||
267 | /** |
||
268 | * Reference the parent FieldDescription related to this admin |
||
269 | * only set for FieldDescription which is associated to an Sub Admin instance. |
||
270 | * |
||
271 | * @var FieldDescriptionInterface |
||
272 | */ |
||
273 | protected $parentFieldDescription; |
||
274 | |||
275 | /** |
||
276 | * If true then the current admin is part of the nested admin set (from the url). |
||
277 | * |
||
278 | * @var bool |
||
279 | */ |
||
280 | protected $currentChild = false; |
||
281 | |||
282 | /** |
||
283 | * The uniqid is used to avoid clashing with 2 admin related to the code |
||
284 | * ie: a Block linked to a Block. |
||
285 | * |
||
286 | * @var string |
||
287 | */ |
||
288 | protected $uniqid; |
||
289 | |||
290 | /** |
||
291 | * The Entity or Document manager. |
||
292 | * |
||
293 | * @var ModelManagerInterface |
||
294 | */ |
||
295 | protected $modelManager; |
||
296 | |||
297 | /** |
||
298 | * The current request object. |
||
299 | * |
||
300 | * @var Request|null |
||
301 | */ |
||
302 | protected $request; |
||
303 | |||
304 | /** |
||
305 | * The translator component. |
||
306 | * |
||
307 | * NEXT_MAJOR: remove this property |
||
308 | * |
||
309 | * @var \Symfony\Component\Translation\TranslatorInterface |
||
310 | * |
||
311 | * @deprecated since sonata-project/admin-bundle 3.9, to be removed with 4.0 |
||
312 | */ |
||
313 | protected $translator; |
||
314 | |||
315 | /** |
||
316 | * The related form contractor. |
||
317 | * |
||
318 | * @var FormContractorInterface |
||
319 | */ |
||
320 | protected $formContractor; |
||
321 | |||
322 | /** |
||
323 | * The related list builder. |
||
324 | * |
||
325 | * @var ListBuilderInterface |
||
326 | */ |
||
327 | protected $listBuilder; |
||
328 | |||
329 | /** |
||
330 | * The related view builder. |
||
331 | * |
||
332 | * @var ShowBuilderInterface |
||
333 | */ |
||
334 | protected $showBuilder; |
||
335 | |||
336 | /** |
||
337 | * The related datagrid builder. |
||
338 | * |
||
339 | * @var DatagridBuilderInterface |
||
340 | */ |
||
341 | protected $datagridBuilder; |
||
342 | |||
343 | /** |
||
344 | * @var RouteBuilderInterface |
||
345 | */ |
||
346 | protected $routeBuilder; |
||
347 | |||
348 | /** |
||
349 | * The datagrid instance. |
||
350 | * |
||
351 | * @var DatagridInterface|null |
||
352 | */ |
||
353 | protected $datagrid; |
||
354 | |||
355 | /** |
||
356 | * The router instance. |
||
357 | * |
||
358 | * @var RouteGeneratorInterface|null |
||
359 | */ |
||
360 | protected $routeGenerator; |
||
361 | |||
362 | /** |
||
363 | * The generated breadcrumbs. |
||
364 | * |
||
365 | * NEXT_MAJOR : remove this property |
||
366 | * |
||
367 | * @var array |
||
368 | */ |
||
369 | protected $breadcrumbs = []; |
||
370 | |||
371 | /** |
||
372 | * @var SecurityHandlerInterface |
||
373 | */ |
||
374 | protected $securityHandler; |
||
375 | |||
376 | /** |
||
377 | * @var ValidatorInterface |
||
378 | */ |
||
379 | protected $validator; |
||
380 | |||
381 | /** |
||
382 | * The configuration pool. |
||
383 | * |
||
384 | * @var Pool |
||
385 | */ |
||
386 | protected $configurationPool; |
||
387 | |||
388 | /** |
||
389 | * @var ItemInterface |
||
390 | */ |
||
391 | protected $menu; |
||
392 | |||
393 | /** |
||
394 | * @var FactoryInterface |
||
395 | */ |
||
396 | protected $menuFactory; |
||
397 | |||
398 | /** |
||
399 | * @var array<string, bool> |
||
400 | */ |
||
401 | protected $loaded = [ |
||
402 | 'view_fields' => false, // NEXT_MAJOR: Remove this unused value. |
||
403 | 'view_groups' => false, // NEXT_MAJOR: Remove this unused value. |
||
404 | 'routes' => false, |
||
405 | 'tab_menu' => false, |
||
406 | 'show' => false, |
||
407 | 'list' => false, |
||
408 | 'form' => false, |
||
409 | 'datagrid' => false, |
||
410 | ]; |
||
411 | |||
412 | /** |
||
413 | * @var string[] |
||
414 | */ |
||
415 | protected $formTheme = []; |
||
416 | |||
417 | /** |
||
418 | * @var string[] |
||
419 | */ |
||
420 | protected $filterTheme = []; |
||
421 | |||
422 | /** |
||
423 | * @var array<string, string> |
||
424 | * |
||
425 | * @deprecated since sonata-project/admin-bundle 3.34, will be dropped in 4.0. Use TemplateRegistry services instead |
||
426 | */ |
||
427 | protected $templates = []; |
||
428 | |||
429 | /** |
||
430 | * @var AdminExtensionInterface[] |
||
431 | */ |
||
432 | protected $extensions = []; |
||
433 | |||
434 | /** |
||
435 | * @var LabelTranslatorStrategyInterface |
||
436 | */ |
||
437 | protected $labelTranslatorStrategy; |
||
438 | |||
439 | /** |
||
440 | * Setting to true will enable preview mode for |
||
441 | * the entity and show a preview button in the |
||
442 | * edit/create forms. |
||
443 | * |
||
444 | * @var bool |
||
445 | */ |
||
446 | protected $supportsPreviewMode = false; |
||
447 | |||
448 | /** |
||
449 | * Roles and permissions per role. |
||
450 | * |
||
451 | * @var array 'role' => ['permission', 'permission'] |
||
452 | */ |
||
453 | protected $securityInformation = []; |
||
454 | |||
455 | protected $cacheIsGranted = []; |
||
456 | |||
457 | /** |
||
458 | * Action list for the search result. |
||
459 | * |
||
460 | * @var string[] |
||
461 | */ |
||
462 | protected $searchResultActions = ['edit', 'show']; |
||
463 | |||
464 | protected $listModes = [ |
||
465 | 'list' => [ |
||
466 | 'class' => 'fa fa-list fa-fw', |
||
467 | ], |
||
468 | 'mosaic' => [ |
||
469 | 'class' => self::MOSAIC_ICON_CLASS, |
||
470 | ], |
||
471 | ]; |
||
472 | |||
473 | /** |
||
474 | * The Access mapping. |
||
475 | * |
||
476 | * @var array [action1 => requiredRole1, action2 => [requiredRole2, requiredRole3]] |
||
477 | */ |
||
478 | protected $accessMapping = []; |
||
479 | |||
480 | /** |
||
481 | * @var MutableTemplateRegistryInterface |
||
482 | */ |
||
483 | private $templateRegistry; |
||
484 | |||
485 | /** |
||
486 | * The class name managed by the admin class. |
||
487 | * |
||
488 | * @var string |
||
489 | */ |
||
490 | private $class; |
||
491 | |||
492 | /** |
||
493 | * The subclasses supported by the admin class. |
||
494 | * |
||
495 | * @var array<string, string> |
||
496 | */ |
||
497 | private $subClasses = []; |
||
498 | |||
499 | /** |
||
500 | * The list collection. |
||
501 | * |
||
502 | * @var FieldDescriptionCollection|null |
||
503 | */ |
||
504 | private $list; |
||
505 | |||
506 | /** |
||
507 | * @var FieldDescriptionCollection|null |
||
508 | */ |
||
509 | private $show; |
||
510 | |||
511 | /** |
||
512 | * @var Form|null |
||
513 | */ |
||
514 | private $form; |
||
515 | |||
516 | /** |
||
517 | * The cached base route name. |
||
518 | * |
||
519 | * @var string |
||
520 | */ |
||
521 | private $cachedBaseRouteName; |
||
522 | |||
523 | /** |
||
524 | * The cached base route pattern. |
||
525 | * |
||
526 | * @var string |
||
527 | */ |
||
528 | private $cachedBaseRoutePattern; |
||
529 | |||
530 | /** |
||
531 | * The form group disposition. |
||
532 | * |
||
533 | * NEXT_MAJOR: must have `[]` as default value and remove the possibility to |
||
534 | * hold boolean values. |
||
535 | * |
||
536 | * @var array|bool |
||
537 | */ |
||
538 | private $formGroups = false; |
||
539 | |||
540 | /** |
||
541 | * The form tabs disposition. |
||
542 | * |
||
543 | * NEXT_MAJOR: must have `[]` as default value and remove the possibility to |
||
544 | * hold boolean values. |
||
545 | * |
||
546 | * @var array|bool |
||
547 | */ |
||
548 | private $formTabs = false; |
||
549 | |||
550 | /** |
||
551 | * The view group disposition. |
||
552 | * |
||
553 | * NEXT_MAJOR: must have `[]` as default value and remove the possibility to |
||
554 | * hold boolean values. |
||
555 | * |
||
556 | * @var array|bool |
||
557 | */ |
||
558 | private $showGroups = false; |
||
559 | |||
560 | /** |
||
561 | * The view tab disposition. |
||
562 | * |
||
563 | * NEXT_MAJOR: must have `[]` as default value and remove the possibility to |
||
564 | * hold boolean values. |
||
565 | * |
||
566 | * @var array|bool |
||
567 | */ |
||
568 | private $showTabs = false; |
||
569 | |||
570 | /** |
||
571 | * The manager type to use for the admin. |
||
572 | * |
||
573 | * @var string |
||
574 | */ |
||
575 | private $managerType; |
||
576 | |||
577 | /** |
||
578 | * The breadcrumbsBuilder component. |
||
579 | * |
||
580 | * @var BreadcrumbsBuilderInterface |
||
581 | */ |
||
582 | private $breadcrumbsBuilder; |
||
583 | |||
584 | /** |
||
585 | * Component responsible for persisting filters. |
||
586 | * |
||
587 | * @var FilterPersisterInterface|null |
||
588 | */ |
||
589 | private $filterPersister; |
||
590 | |||
591 | /** |
||
592 | * @param string $code |
||
593 | * @param string $class |
||
594 | * @param string|null $baseControllerName |
||
595 | */ |
||
596 | public function __construct($code, $class, $baseControllerName = null) |
||
626 | |||
627 | /** |
||
628 | * {@inheritdoc} |
||
629 | */ |
||
630 | public function getExportFormats() |
||
636 | |||
637 | /** |
||
638 | * @return array |
||
639 | */ |
||
640 | public function getExportFields() |
||
652 | |||
653 | public function getDataSourceIterator() |
||
675 | |||
676 | public function validate(ErrorElement $errorElement, $object) |
||
679 | |||
680 | /** |
||
681 | * define custom variable. |
||
682 | */ |
||
683 | public function initialize() |
||
699 | |||
700 | public function configure() |
||
703 | |||
704 | public function update($object) |
||
724 | |||
725 | public function create($object) |
||
747 | |||
748 | public function delete($object) |
||
763 | |||
764 | /** |
||
765 | * @param object $object |
||
766 | */ |
||
767 | public function preValidate($object) |
||
770 | |||
771 | public function preUpdate($object) |
||
774 | |||
775 | public function postUpdate($object) |
||
778 | |||
779 | public function prePersist($object) |
||
782 | |||
783 | public function postPersist($object) |
||
786 | |||
787 | public function preRemove($object) |
||
790 | |||
791 | public function postRemove($object) |
||
794 | |||
795 | public function preBatchAction($actionName, ProxyQueryInterface $query, array &$idx, $allElements) |
||
798 | |||
799 | public function getFilterParameters() |
||
851 | |||
852 | /** |
||
853 | * NEXT_MAJOR: Change the visibility to protected (similar to buildShow, buildForm, ...). |
||
854 | */ |
||
855 | public function buildDatagrid() |
||
909 | |||
910 | /** |
||
911 | * Returns the name of the parent related field, so the field can be use to set the default |
||
912 | * value (ie the parent object) or to filter the object. |
||
913 | * |
||
914 | * @throws \InvalidArgumentException |
||
915 | * |
||
916 | * @return string|null |
||
917 | */ |
||
918 | public function getParentAssociationMapping() |
||
938 | |||
939 | /** |
||
940 | * @param string $code |
||
941 | * @param string $value |
||
942 | */ |
||
943 | final public function addParentAssociationMapping($code, $value) |
||
947 | |||
948 | /** |
||
949 | * Returns the baseRoutePattern used to generate the routing information. |
||
950 | * |
||
951 | * @throws \RuntimeException |
||
952 | * |
||
953 | * @return string the baseRoutePattern used to generate the routing information |
||
954 | */ |
||
955 | public function getBaseRoutePattern() |
||
997 | |||
998 | /** |
||
999 | * Returns the baseRouteName used to generate the routing information. |
||
1000 | * |
||
1001 | * @throws \RuntimeException |
||
1002 | * |
||
1003 | * @return string the baseRouteName used to generate the routing information |
||
1004 | */ |
||
1005 | public function getBaseRouteName() |
||
1046 | |||
1047 | /** |
||
1048 | * urlize the given word. |
||
1049 | * |
||
1050 | * @param string $word |
||
1051 | * @param string $sep the separator |
||
1052 | * |
||
1053 | * @return string |
||
1054 | */ |
||
1055 | public function urlize($word, $sep = '_') |
||
1059 | |||
1060 | public function getClass() |
||
1083 | |||
1084 | public function getSubClasses() |
||
1088 | |||
1089 | /** |
||
1090 | * NEXT_MAJOR: remove this method. |
||
1091 | */ |
||
1092 | public function addSubClass($subClass) |
||
1103 | |||
1104 | public function setSubClasses(array $subClasses) |
||
1108 | |||
1109 | public function hasSubClass($name) |
||
1113 | |||
1114 | public function hasActiveSubClass() |
||
1122 | |||
1123 | public function getActiveSubClass() |
||
1143 | |||
1144 | public function getActiveSubclassCode() |
||
1182 | |||
1183 | public function getBatchActions() |
||
1216 | |||
1217 | public function getRoutes() |
||
1223 | |||
1224 | public function getRouterIdParameter() |
||
1228 | |||
1229 | public function getIdParameter() |
||
1239 | |||
1240 | public function hasRoute($name) |
||
1248 | |||
1249 | /** |
||
1250 | * @param string $name |
||
1251 | * @param string|null $adminCode |
||
1252 | * |
||
1253 | * @return bool |
||
1254 | */ |
||
1255 | public function isCurrentRoute($name, $adminCode = null) |
||
1276 | |||
1277 | public function generateObjectUrl($name, $object, array $parameters = [], $referenceType = RoutingUrlGeneratorInterface::ABSOLUTE_PATH) |
||
1283 | |||
1284 | public function generateUrl($name, array $parameters = [], $referenceType = RoutingUrlGeneratorInterface::ABSOLUTE_PATH) |
||
1288 | |||
1289 | public function generateMenuUrl($name, array $parameters = [], $referenceType = RoutingUrlGeneratorInterface::ABSOLUTE_PATH) |
||
1293 | |||
1294 | final public function setTemplateRegistry(MutableTemplateRegistryInterface $templateRegistry) |
||
1298 | |||
1299 | /** |
||
1300 | * @param array<string, string> $templates |
||
1301 | */ |
||
1302 | public function setTemplates(array $templates) |
||
1309 | |||
1310 | /** |
||
1311 | * @param string $name |
||
1312 | * @param string $template |
||
1313 | */ |
||
1314 | public function setTemplate($name, $template) |
||
1321 | |||
1322 | /** |
||
1323 | * @deprecated since sonata-project/admin-bundle 3.34, will be dropped in 4.0. Use TemplateRegistry services instead |
||
1324 | * |
||
1325 | * @return array<string, string> |
||
1326 | */ |
||
1327 | public function getTemplates() |
||
1331 | |||
1332 | /** |
||
1333 | * @deprecated since sonata-project/admin-bundle 3.34, will be dropped in 4.0. Use TemplateRegistry services instead |
||
1334 | * |
||
1335 | * @param string $name |
||
1336 | * |
||
1337 | * @return string|null |
||
1338 | */ |
||
1339 | public function getTemplate($name) |
||
1343 | |||
1344 | public function getNewInstance() |
||
1345 | { |
||
1346 | $object = $this->getModelManager()->getModelInstance($this->getClass()); |
||
1347 | |||
1348 | // Append parent object if any |
||
1349 | if ($this->isChild() && $this->getParentAssociationMapping()) { |
||
1350 | $parentAdmin = $this->getParent(); |
||
1351 | $parent = $parentAdmin->getObject($this->request->get($parentAdmin->getIdParameter())); |
||
1352 | |||
1353 | if (null !== $parent) { |
||
1354 | $propertyAccessor = $this->getConfigurationPool()->getPropertyAccessor(); |
||
1355 | $propertyPath = new PropertyPath($this->getParentAssociationMapping()); |
||
1356 | |||
1357 | $value = $propertyAccessor->getValue($object, $propertyPath); |
||
1358 | |||
1359 | if (\is_array($value) || $value instanceof \ArrayAccess) { |
||
1360 | $value[] = $parent; |
||
1361 | $propertyAccessor->setValue($object, $propertyPath, $value); |
||
1362 | } else { |
||
1363 | $propertyAccessor->setValue($object, $propertyPath, $parent); |
||
1364 | } |
||
1365 | } |
||
1366 | } elseif ($this->hasParentFieldDescription()) { |
||
1367 | $parentAdmin = $this->getParentFieldDescription()->getAdmin(); |
||
1368 | $parent = $parentAdmin->getObject($this->request->get($parentAdmin->getIdParameter())); |
||
1369 | |||
1370 | if (null !== $parent) { |
||
1371 | AdminHelper::addInstance($parent, $this->getParentFieldDescription(), $object); |
||
1372 | } |
||
1373 | } |
||
1374 | |||
1375 | foreach ($this->getExtensions() as $extension) { |
||
1376 | $extension->alterNewInstance($this, $object); |
||
1377 | } |
||
1378 | |||
1379 | return $object; |
||
1380 | } |
||
1381 | |||
1382 | public function getFormBuilder() |
||
1383 | { |
||
1384 | $this->formOptions['data_class'] = $this->getClass(); |
||
1385 | |||
1386 | $formBuilder = $this->getFormContractor()->getFormBuilder( |
||
1387 | $this->getUniqid(), |
||
1388 | $this->formOptions |
||
1389 | ); |
||
1390 | |||
1391 | $this->defineFormBuilder($formBuilder); |
||
1392 | |||
1393 | return $formBuilder; |
||
1394 | } |
||
1395 | |||
1396 | /** |
||
1397 | * This method is being called by the main admin class and the child class, |
||
1398 | * the getFormBuilder is only call by the main admin class. |
||
1399 | */ |
||
1400 | public function defineFormBuilder(FormBuilderInterface $formBuilder) |
||
1401 | { |
||
1402 | if (!$this->hasSubject()) { |
||
1403 | @trigger_error(sprintf( |
||
1404 | 'Calling %s() when there is no subject is deprecated since sonata-project/admin-bundle 3.65 and will throw an exception in 4.0. '. |
||
1405 | 'Use %s::setSubject() to set the subject.', |
||
1406 | __METHOD__, |
||
1407 | __CLASS__ |
||
1408 | ), E_USER_DEPRECATED); |
||
1409 | // NEXT_MAJOR : remove the previous `trigger_error()` call and uncomment the following exception |
||
1410 | // throw new \LogicException(sprintf( |
||
1411 | // 'Admin "%s" has no subject.', |
||
1412 | // static::class |
||
1413 | // )); |
||
1414 | } |
||
1415 | |||
1416 | $mapper = new FormMapper($this->getFormContractor(), $formBuilder, $this); |
||
1417 | |||
1418 | $this->configureFormFields($mapper); |
||
1419 | |||
1420 | foreach ($this->getExtensions() as $extension) { |
||
1421 | $extension->configureFormFields($mapper); |
||
1422 | } |
||
1423 | |||
1424 | $this->attachInlineValidator(); |
||
1425 | } |
||
1426 | |||
1427 | public function attachAdminClass(FieldDescriptionInterface $fieldDescription) |
||
1428 | { |
||
1429 | $pool = $this->getConfigurationPool(); |
||
1430 | |||
1431 | $adminCode = $fieldDescription->getOption('admin_code'); |
||
1432 | |||
1433 | if (null !== $adminCode) { |
||
1434 | if (!$pool->hasAdminByAdminCode($adminCode)) { |
||
1435 | return; |
||
1436 | } |
||
1437 | |||
1438 | $admin = $pool->getAdminByAdminCode($adminCode); |
||
1439 | } else { |
||
1440 | if (!$pool->hasAdminByClass($fieldDescription->getTargetEntity())) { |
||
1441 | return; |
||
1442 | } |
||
1443 | |||
1444 | $admin = $pool->getAdminByClass($fieldDescription->getTargetEntity()); |
||
1445 | } |
||
1446 | |||
1447 | if ($this->hasRequest()) { |
||
1448 | $admin->setRequest($this->getRequest()); |
||
1449 | } |
||
1450 | |||
1451 | $fieldDescription->setAssociationAdmin($admin); |
||
1452 | } |
||
1453 | |||
1454 | public function getObject($id) |
||
1455 | { |
||
1456 | $object = $this->getModelManager()->find($this->getClass(), $id); |
||
1457 | foreach ($this->getExtensions() as $extension) { |
||
1458 | $extension->alterObject($this, $object); |
||
1459 | } |
||
1460 | |||
1461 | return $object; |
||
1462 | } |
||
1463 | |||
1464 | public function getForm() |
||
1465 | { |
||
1466 | $this->buildForm(); |
||
1467 | |||
1468 | return $this->form; |
||
1469 | } |
||
1470 | |||
1471 | public function getList() |
||
1472 | { |
||
1473 | $this->buildList(); |
||
1474 | |||
1475 | return $this->list; |
||
1476 | } |
||
1477 | |||
1478 | /** |
||
1479 | * @final since sonata-project/admin-bundle 3.63.0 |
||
1480 | */ |
||
1481 | public function createQuery($context = 'list') |
||
1482 | { |
||
1483 | if (\func_num_args() > 0) { |
||
1484 | @trigger_error( |
||
1485 | 'The $context argument of '.__METHOD__.' is deprecated since 3.3, to be removed in 4.0.', |
||
1486 | E_USER_DEPRECATED |
||
1487 | ); |
||
1488 | } |
||
1489 | |||
1490 | $query = $this->getModelManager()->createQuery($this->getClass()); |
||
1491 | |||
1492 | $query = $this->configureQuery($query); |
||
1493 | foreach ($this->extensions as $extension) { |
||
1494 | $extension->configureQuery($this, $query, $context); |
||
1495 | } |
||
1496 | |||
1497 | return $query; |
||
1498 | } |
||
1499 | |||
1500 | public function getDatagrid() |
||
1501 | { |
||
1502 | $this->buildDatagrid(); |
||
1503 | |||
1504 | return $this->datagrid; |
||
1505 | } |
||
1506 | |||
1507 | public function buildTabMenu($action, ?AdminInterface $childAdmin = null) |
||
1508 | { |
||
1509 | if ($this->loaded['tab_menu']) { |
||
1510 | return $this->menu; |
||
1511 | } |
||
1512 | |||
1513 | $this->loaded['tab_menu'] = true; |
||
1514 | |||
1515 | $menu = $this->menuFactory->createItem('root'); |
||
1516 | $menu->setChildrenAttribute('class', 'nav navbar-nav'); |
||
1517 | $menu->setExtra('translation_domain', $this->translationDomain); |
||
1518 | |||
1519 | // Prevents BC break with KnpMenuBundle v1.x |
||
1520 | if (method_exists($menu, 'setCurrentUri')) { |
||
1521 | $menu->setCurrentUri($this->getRequest()->getBaseUrl().$this->getRequest()->getPathInfo()); |
||
1522 | } |
||
1523 | |||
1524 | $this->configureTabMenu($menu, $action, $childAdmin); |
||
1525 | |||
1526 | foreach ($this->getExtensions() as $extension) { |
||
1527 | $extension->configureTabMenu($this, $menu, $action, $childAdmin); |
||
1528 | } |
||
1529 | |||
1530 | $this->menu = $menu; |
||
1531 | |||
1532 | return $this->menu; |
||
1533 | } |
||
1534 | |||
1535 | public function buildSideMenu($action, ?AdminInterface $childAdmin = null) |
||
1536 | { |
||
1537 | return $this->buildTabMenu($action, $childAdmin); |
||
1538 | } |
||
1539 | |||
1540 | /** |
||
1541 | * @param string $action |
||
1542 | * |
||
1543 | * @return ItemInterface |
||
1544 | */ |
||
1545 | public function getSideMenu($action, ?AdminInterface $childAdmin = null) |
||
1546 | { |
||
1547 | if ($this->isChild()) { |
||
1548 | return $this->getParent()->getSideMenu($action, $this); |
||
1549 | } |
||
1550 | |||
1551 | $this->buildSideMenu($action, $childAdmin); |
||
1552 | |||
1553 | return $this->menu; |
||
1554 | } |
||
1555 | |||
1556 | /** |
||
1557 | * Returns the root code. |
||
1558 | * |
||
1559 | * @return string the root code |
||
1560 | */ |
||
1561 | public function getRootCode() |
||
1562 | { |
||
1563 | return $this->getRoot()->getCode(); |
||
1564 | } |
||
1565 | |||
1566 | /** |
||
1567 | * Returns the master admin. |
||
1568 | * |
||
1569 | * @return AbstractAdmin the root admin class |
||
1570 | */ |
||
1571 | public function getRoot() |
||
1572 | { |
||
1573 | if (!$this->hasParentFieldDescription()) { |
||
1574 | return $this; |
||
1575 | } |
||
1576 | |||
1577 | return $this->getParentFieldDescription()->getAdmin()->getRoot(); |
||
1578 | } |
||
1579 | |||
1580 | public function setBaseControllerName($baseControllerName) |
||
1581 | { |
||
1582 | $this->baseControllerName = $baseControllerName; |
||
1583 | } |
||
1584 | |||
1585 | public function getBaseControllerName() |
||
1586 | { |
||
1587 | return $this->baseControllerName; |
||
1588 | } |
||
1589 | |||
1590 | /** |
||
1591 | * @param string $label |
||
1592 | */ |
||
1593 | public function setLabel($label) |
||
1594 | { |
||
1595 | $this->label = $label; |
||
1596 | } |
||
1597 | |||
1598 | public function getLabel() |
||
1599 | { |
||
1600 | return $this->label; |
||
1601 | } |
||
1602 | |||
1603 | /** |
||
1604 | * @param bool $persist |
||
1605 | * |
||
1606 | * NEXT_MAJOR: remove this method |
||
1607 | * |
||
1608 | * @deprecated since sonata-project/admin-bundle 3.34, to be removed in 4.0. |
||
1609 | */ |
||
1610 | public function setPersistFilters($persist) |
||
1611 | { |
||
1612 | @trigger_error( |
||
1613 | 'The '.__METHOD__.' method is deprecated since version 3.34 and will be removed in 4.0.', |
||
1614 | E_USER_DEPRECATED |
||
1615 | ); |
||
1616 | |||
1617 | $this->persistFilters = $persist; |
||
1618 | } |
||
1619 | |||
1620 | public function setFilterPersister(?FilterPersisterInterface $filterPersister = null) |
||
1621 | { |
||
1622 | $this->filterPersister = $filterPersister; |
||
1623 | // NEXT_MAJOR remove the deprecated property will be removed. Needed for persisted filter condition. |
||
1624 | $this->persistFilters = true; |
||
1625 | } |
||
1626 | |||
1627 | /** |
||
1628 | * NEXT_MAJOR: Remove this method. |
||
1629 | * |
||
1630 | * @deprecated since sonata-project/admin-bundle 3.67, to be removed in 4.0. |
||
1631 | * |
||
1632 | * @param int $maxPerPage |
||
1633 | */ |
||
1634 | public function setMaxPerPage($maxPerPage) |
||
1635 | { |
||
1636 | @trigger_error(sprintf( |
||
1637 | 'The method %s is deprecated since sonata-project/admin-bundle 3.67 and will be removed in 4.0.', |
||
1638 | __METHOD__ |
||
1639 | ), E_USER_DEPRECATED); |
||
1640 | |||
1641 | $this->maxPerPage = $maxPerPage; |
||
1642 | } |
||
1643 | |||
1644 | /** |
||
1645 | * @return int |
||
1646 | */ |
||
1647 | public function getMaxPerPage() |
||
1648 | { |
||
1649 | // NEXT_MAJOR: Remove this line and uncomment the following. |
||
1650 | return $this->maxPerPage; |
||
1651 | // $sortValues = $this->getModelManager()->getDefaultSortValues($this->class); |
||
1652 | |||
1653 | // return $sortValues['_per_page'] ?? 25; |
||
1654 | } |
||
1655 | |||
1656 | /** |
||
1657 | * @param int $maxPageLinks |
||
1658 | */ |
||
1659 | public function setMaxPageLinks($maxPageLinks) |
||
1660 | { |
||
1661 | $this->maxPageLinks = $maxPageLinks; |
||
1662 | } |
||
1663 | |||
1664 | /** |
||
1665 | * @return int |
||
1666 | */ |
||
1667 | public function getMaxPageLinks() |
||
1668 | { |
||
1669 | return $this->maxPageLinks; |
||
1670 | } |
||
1671 | |||
1672 | public function getFormGroups() |
||
1673 | { |
||
1674 | if (!\is_array($this->formGroups) && 'sonata_deprecation_mute' !== (\func_get_args()[0] ?? null)) { |
||
1675 | @trigger_error(sprintf( |
||
1676 | 'Returning other type than array in method %s() is deprecated since sonata-project/admin-bundle 3.65. It will return only array in version 4.0.', |
||
1677 | __METHOD__ |
||
1678 | ), E_USER_DEPRECATED); |
||
1679 | } |
||
1680 | |||
1681 | return $this->formGroups; |
||
1682 | } |
||
1683 | |||
1684 | public function setFormGroups(array $formGroups) |
||
1685 | { |
||
1686 | $this->formGroups = $formGroups; |
||
1687 | } |
||
1688 | |||
1689 | public function removeFieldFromFormGroup($key) |
||
1690 | { |
||
1691 | foreach ($this->formGroups as $name => $formGroup) { |
||
1692 | unset($this->formGroups[$name]['fields'][$key]); |
||
1693 | |||
1694 | if (empty($this->formGroups[$name]['fields'])) { |
||
1695 | unset($this->formGroups[$name]); |
||
1696 | } |
||
1697 | } |
||
1698 | } |
||
1699 | |||
1700 | /** |
||
1701 | * @param string $group |
||
1702 | */ |
||
1703 | public function reorderFormGroup($group, array $keys) |
||
1704 | { |
||
1705 | // NEXT_MAJOR: Remove the argument "sonata_deprecation_mute" in the following call. |
||
1706 | $formGroups = $this->getFormGroups('sonata_deprecation_mute'); |
||
1707 | $formGroups[$group]['fields'] = array_merge(array_flip($keys), $formGroups[$group]['fields']); |
||
1708 | $this->setFormGroups($formGroups); |
||
1709 | } |
||
1710 | |||
1711 | public function getFormTabs() |
||
1712 | { |
||
1713 | if (!\is_array($this->formTabs) && 'sonata_deprecation_mute' !== (\func_get_args()[0] ?? null)) { |
||
1714 | @trigger_error(sprintf( |
||
1715 | 'Returning other type than array in method %s() is deprecated since sonata-project/admin-bundle 3.65. It will return only array in version 4.0.', |
||
1716 | __METHOD__ |
||
1717 | ), E_USER_DEPRECATED); |
||
1718 | } |
||
1719 | |||
1720 | return $this->formTabs; |
||
1721 | } |
||
1722 | |||
1723 | public function setFormTabs(array $formTabs) |
||
1724 | { |
||
1725 | $this->formTabs = $formTabs; |
||
1726 | } |
||
1727 | |||
1728 | public function getShowTabs() |
||
1729 | { |
||
1730 | if (!\is_array($this->showTabs) && 'sonata_deprecation_mute' !== (\func_get_args()[0] ?? null)) { |
||
1731 | @trigger_error(sprintf( |
||
1732 | 'Returning other type than array in method %s() is deprecated since sonata-project/admin-bundle 3.65. It will return only array in version 4.0.', |
||
1733 | __METHOD__ |
||
1734 | ), E_USER_DEPRECATED); |
||
1735 | } |
||
1736 | |||
1737 | return $this->showTabs; |
||
1738 | } |
||
1739 | |||
1740 | public function setShowTabs(array $showTabs) |
||
1741 | { |
||
1742 | $this->showTabs = $showTabs; |
||
1743 | } |
||
1744 | |||
1745 | public function getShowGroups() |
||
1746 | { |
||
1747 | if (!\is_array($this->showGroups) && 'sonata_deprecation_mute' !== (\func_get_args()[0] ?? null)) { |
||
1748 | @trigger_error(sprintf( |
||
1749 | 'Returning other type than array in method %s() is deprecated since sonata-project/admin-bundle 3.65. It will return only array in version 4.0.', |
||
1750 | __METHOD__ |
||
1751 | ), E_USER_DEPRECATED); |
||
1752 | } |
||
1753 | |||
1754 | return $this->showGroups; |
||
1755 | } |
||
1756 | |||
1757 | public function setShowGroups(array $showGroups) |
||
1758 | { |
||
1759 | $this->showGroups = $showGroups; |
||
1760 | } |
||
1761 | |||
1762 | public function reorderShowGroup($group, array $keys) |
||
1763 | { |
||
1764 | // NEXT_MAJOR: Remove the argument "sonata_deprecation_mute" in the following call. |
||
1765 | $showGroups = $this->getShowGroups('sonata_deprecation_mute'); |
||
1766 | $showGroups[$group]['fields'] = array_merge(array_flip($keys), $showGroups[$group]['fields']); |
||
1767 | $this->setShowGroups($showGroups); |
||
1768 | } |
||
1769 | |||
1770 | public function setParentFieldDescription(FieldDescriptionInterface $parentFieldDescription) |
||
1771 | { |
||
1772 | $this->parentFieldDescription = $parentFieldDescription; |
||
1773 | } |
||
1774 | |||
1775 | public function getParentFieldDescription() |
||
1776 | { |
||
1777 | if (!$this->hasParentFieldDescription()) { |
||
1778 | @trigger_error(sprintf( |
||
1779 | 'Calling %s() when there is no parent field description is deprecated since sonata-project/admin-bundle 3.66 and will throw an exception in 4.0. '. |
||
1780 | 'Use %s::hasParentFieldDescription() to know if there is a parent field description.', |
||
1781 | __METHOD__, |
||
1782 | __CLASS__ |
||
1783 | ), E_USER_DEPRECATED); |
||
1784 | // NEXT_MAJOR : remove the previous `trigger_error()` call, the `return null` statement, uncomment the following exception and declare FieldDescriptionInterface as return type |
||
1785 | // throw new \LogicException(sprintf( |
||
1786 | // 'Admin "%s" has no parent field description.', |
||
1787 | // static::class |
||
1788 | // )); |
||
1789 | |||
1790 | return null; |
||
1791 | } |
||
1792 | |||
1793 | return $this->parentFieldDescription; |
||
1794 | } |
||
1795 | |||
1796 | public function hasParentFieldDescription() |
||
1797 | { |
||
1798 | return $this->parentFieldDescription instanceof FieldDescriptionInterface; |
||
1799 | } |
||
1800 | |||
1801 | public function setSubject($subject) |
||
1802 | { |
||
1803 | if (\is_object($subject) && !is_a($subject, $this->getClass(), true)) { |
||
1804 | $message = <<<'EOT' |
||
1805 | You are trying to set entity an instance of "%s", |
||
1806 | which is not the one registered with this admin class ("%s"). |
||
1807 | This is deprecated since 3.5 and will no longer be supported in 4.0. |
||
1808 | EOT; |
||
1809 | |||
1810 | @trigger_error( |
||
1811 | sprintf($message, \get_class($subject), $this->getClass()), |
||
1812 | E_USER_DEPRECATED |
||
1813 | ); // NEXT_MAJOR : throw an exception instead |
||
1814 | } |
||
1815 | |||
1816 | $this->subject = $subject; |
||
1817 | } |
||
1818 | |||
1819 | public function getSubject() |
||
1820 | { |
||
1821 | if (!$this->hasSubject()) { |
||
1822 | @trigger_error(sprintf( |
||
1823 | 'Calling %s() when there is no subject is deprecated since sonata-project/admin-bundle 3.66 and will throw an exception in 4.0. '. |
||
1824 | 'Use %s::hasSubject() to know if there is a subject.', |
||
1825 | __METHOD__, |
||
1826 | __CLASS__ |
||
1827 | ), E_USER_DEPRECATED); |
||
1828 | // NEXT_MAJOR : remove the previous `trigger_error()` call, the `return null` statement, uncomment the following exception and update the return type |
||
1829 | // throw new \LogicException(sprintf( |
||
1830 | // 'Admin "%s" has no subject.', |
||
1831 | // static::class |
||
1832 | // )); |
||
1833 | |||
1834 | return null; |
||
1835 | } |
||
1836 | |||
1837 | return $this->subject; |
||
1838 | } |
||
1839 | |||
1840 | public function hasSubject() |
||
1841 | { |
||
1842 | if (null === $this->subject && $this->hasRequest() && !$this->hasParentFieldDescription()) { |
||
1843 | $id = $this->request->get($this->getIdParameter()); |
||
1844 | |||
1845 | if (null !== $id) { |
||
1846 | $this->subject = $this->getObject($id); |
||
1847 | } |
||
1848 | } |
||
1849 | |||
1850 | return null !== $this->subject; |
||
1851 | } |
||
1852 | |||
1853 | public function getFormFieldDescriptions() |
||
1854 | { |
||
1855 | $this->buildForm(); |
||
1856 | |||
1857 | return $this->formFieldDescriptions; |
||
1858 | } |
||
1859 | |||
1860 | public function getFormFieldDescription($name) |
||
1861 | { |
||
1862 | $this->buildForm(); |
||
1863 | |||
1864 | if (!$this->hasFormFieldDescription($name)) { |
||
1865 | @trigger_error(sprintf( |
||
1866 | 'Calling %s() when there is no form field description is deprecated since sonata-project/admin-bundle 3.69 and will throw an exception in 4.0. '. |
||
1867 | 'Use %s::hasFormFieldDescription() to know if there is a form field description.', |
||
1868 | __METHOD__, |
||
1869 | __CLASS__ |
||
1870 | ), E_USER_DEPRECATED); |
||
1871 | // NEXT_MAJOR : remove the previous `trigger_error()` call, the `return null` statement, uncomment the following exception and declare FieldDescriptionInterface as return type |
||
1872 | // throw new \LogicException(sprintf( |
||
1873 | // 'Admin "%s" has no form field description for the field %s.', |
||
1874 | // static::class, |
||
1875 | // $name |
||
1876 | // )); |
||
1877 | |||
1878 | return null; |
||
1879 | } |
||
1880 | |||
1881 | return $this->formFieldDescriptions[$name]; |
||
1882 | } |
||
1883 | |||
1884 | /** |
||
1885 | * Returns true if the admin has a FieldDescription with the given $name. |
||
1886 | * |
||
1887 | * @param string $name |
||
1888 | * |
||
1889 | * @return bool |
||
1890 | */ |
||
1891 | public function hasFormFieldDescription($name) |
||
1892 | { |
||
1893 | $this->buildForm(); |
||
1894 | |||
1895 | return \array_key_exists($name, $this->formFieldDescriptions) ? true : false; |
||
1896 | } |
||
1897 | |||
1898 | public function addFormFieldDescription($name, FieldDescriptionInterface $fieldDescription) |
||
1899 | { |
||
1900 | $this->formFieldDescriptions[$name] = $fieldDescription; |
||
1901 | } |
||
1902 | |||
1903 | /** |
||
1904 | * remove a FieldDescription. |
||
1905 | * |
||
1906 | * @param string $name |
||
1907 | */ |
||
1908 | public function removeFormFieldDescription($name) |
||
1909 | { |
||
1910 | unset($this->formFieldDescriptions[$name]); |
||
1911 | } |
||
1912 | |||
1913 | /** |
||
1914 | * build and return the collection of form FieldDescription. |
||
1915 | * |
||
1916 | * @return FieldDescriptionInterface[] collection of form FieldDescription |
||
1917 | */ |
||
1918 | public function getShowFieldDescriptions() |
||
1919 | { |
||
1920 | $this->buildShow(); |
||
1921 | |||
1922 | return $this->showFieldDescriptions; |
||
1923 | } |
||
1924 | |||
1925 | /** |
||
1926 | * Returns the form FieldDescription with the given $name. |
||
1927 | * |
||
1928 | * @param string $name |
||
1929 | * |
||
1930 | * @return FieldDescriptionInterface |
||
1931 | */ |
||
1932 | public function getShowFieldDescription($name) |
||
1933 | { |
||
1934 | $this->buildShow(); |
||
1935 | |||
1936 | if (!$this->hasShowFieldDescription($name)) { |
||
1937 | @trigger_error(sprintf( |
||
1938 | 'Calling %s() when there is no show field description is deprecated since sonata-project/admin-bundle 3.69 and will throw an exception in 4.0. '. |
||
1939 | 'Use %s::hasFormFieldDescription() to know if there is a show field description.', |
||
1940 | __METHOD__, |
||
1941 | __CLASS__ |
||
1942 | ), E_USER_DEPRECATED); |
||
1943 | // NEXT_MAJOR : remove the previous `trigger_error()` call, the `return null` statement, uncomment the following exception and declare FieldDescriptionInterface as return type |
||
1944 | // throw new \LogicException(sprintf( |
||
1945 | // 'Admin "%s" has no show field description for the field %s.', |
||
1946 | // static::class, |
||
1947 | // $name |
||
1948 | // )); |
||
1949 | |||
1950 | return null; |
||
1951 | } |
||
1952 | |||
1953 | return $this->showFieldDescriptions[$name]; |
||
1954 | } |
||
1955 | |||
1956 | public function hasShowFieldDescription($name) |
||
1957 | { |
||
1958 | $this->buildShow(); |
||
1959 | |||
1960 | return \array_key_exists($name, $this->showFieldDescriptions); |
||
1961 | } |
||
1962 | |||
1963 | public function addShowFieldDescription($name, FieldDescriptionInterface $fieldDescription) |
||
1964 | { |
||
1965 | $this->showFieldDescriptions[$name] = $fieldDescription; |
||
1966 | } |
||
1967 | |||
1968 | public function removeShowFieldDescription($name) |
||
1969 | { |
||
1970 | unset($this->showFieldDescriptions[$name]); |
||
1971 | } |
||
1972 | |||
1973 | public function getListFieldDescriptions() |
||
1974 | { |
||
1975 | $this->buildList(); |
||
1976 | |||
1977 | return $this->listFieldDescriptions; |
||
1978 | } |
||
1979 | |||
1980 | public function getListFieldDescription($name) |
||
1981 | { |
||
1982 | $this->buildList(); |
||
1983 | |||
1984 | if (!$this->hasListFieldDescription($name)) { |
||
1985 | @trigger_error(sprintf( |
||
1986 | 'Calling %s() when there is no list field description is deprecated since sonata-project/admin-bundle 3.66 and will throw an exception in 4.0. '. |
||
1987 | 'Use %s::hasListFieldDescription(\'%s\') to know if there is a list field description.', |
||
1988 | __METHOD__, |
||
1989 | __CLASS__, |
||
1990 | $name |
||
1991 | ), E_USER_DEPRECATED); |
||
1992 | // NEXT_MAJOR : remove the previous `trigger_error()` call, the `return null` statement, uncomment the following exception and declare FieldDescriptionInterface as return type |
||
1993 | // throw new \LogicException(sprintf( |
||
1994 | // 'Admin "%s" has no list field description for %s.', |
||
1995 | // static::class, |
||
1996 | // $name |
||
1997 | // )); |
||
1998 | |||
1999 | return null; |
||
2000 | } |
||
2001 | |||
2002 | return $this->listFieldDescriptions[$name]; |
||
2003 | } |
||
2004 | |||
2005 | public function hasListFieldDescription($name) |
||
2011 | |||
2012 | public function addListFieldDescription($name, FieldDescriptionInterface $fieldDescription) |
||
2016 | |||
2017 | public function removeListFieldDescription($name) |
||
2021 | |||
2022 | public function getFilterFieldDescription($name) |
||
2023 | { |
||
2024 | $this->buildDatagrid(); |
||
2025 | |||
2026 | if (!$this->hasFilterFieldDescription($name)) { |
||
2027 | @trigger_error(sprintf( |
||
2028 | 'Calling %s() when there is no filter field description is deprecated since sonata-project/admin-bundle 3.69 and will throw an exception in 4.0. '. |
||
2029 | 'Use %s::hasFilterFieldDescription() to know if there is a filter field description.', |
||
2030 | __METHOD__, |
||
2031 | __CLASS__ |
||
2032 | ), E_USER_DEPRECATED); |
||
2033 | // NEXT_MAJOR : remove the previous `trigger_error()` call, the `return null` statement, uncomment the following exception and declare FieldDescriptionInterface as return type |
||
2034 | // throw new \LogicException(sprintf( |
||
2035 | // 'Admin "%s" has no filter field description for the field %s.', |
||
2036 | // static::class, |
||
2037 | // $name |
||
2038 | // )); |
||
2039 | |||
2040 | return null; |
||
2041 | } |
||
2042 | |||
2043 | return $this->filterFieldDescriptions[$name]; |
||
2044 | } |
||
2045 | |||
2046 | public function hasFilterFieldDescription($name) |
||
2047 | { |
||
2048 | $this->buildDatagrid(); |
||
2049 | |||
2050 | return \array_key_exists($name, $this->filterFieldDescriptions) ? true : false; |
||
2051 | } |
||
2052 | |||
2053 | public function addFilterFieldDescription($name, FieldDescriptionInterface $fieldDescription) |
||
2054 | { |
||
2055 | $this->filterFieldDescriptions[$name] = $fieldDescription; |
||
2056 | } |
||
2057 | |||
2058 | public function removeFilterFieldDescription($name) |
||
2059 | { |
||
2060 | unset($this->filterFieldDescriptions[$name]); |
||
2061 | } |
||
2062 | |||
2063 | public function getFilterFieldDescriptions() |
||
2064 | { |
||
2065 | $this->buildDatagrid(); |
||
2066 | |||
2067 | return $this->filterFieldDescriptions; |
||
2068 | } |
||
2069 | |||
2070 | public function addChild(AdminInterface $child) |
||
2071 | { |
||
2072 | $parentAdmin = $this; |
||
2073 | while ($parentAdmin->isChild() && $parentAdmin->getCode() !== $child->getCode()) { |
||
2074 | $parentAdmin = $parentAdmin->getParent(); |
||
2075 | } |
||
2076 | |||
2077 | if ($parentAdmin->getCode() === $child->getCode()) { |
||
2078 | throw new \RuntimeException(sprintf( |
||
2079 | 'Circular reference detected! The child admin `%s` is already in the parent tree of the `%s` admin.', |
||
2080 | $child->getCode(), |
||
2081 | $this->getCode() |
||
2082 | )); |
||
2083 | } |
||
2084 | |||
2085 | $this->children[$child->getCode()] = $child; |
||
2086 | |||
2087 | $child->setParent($this); |
||
2088 | |||
2089 | // NEXT_MAJOR: remove $args and add $field parameter to this function on next Major |
||
2090 | |||
2091 | $args = \func_get_args(); |
||
2092 | |||
2093 | if (isset($args[1])) { |
||
2094 | $child->addParentAssociationMapping($this->getCode(), $args[1]); |
||
2095 | } else { |
||
2096 | @trigger_error( |
||
2097 | 'Calling "addChild" without second argument is deprecated since' |
||
2098 | .' sonata-project/admin-bundle 3.35 and will not be allowed in 4.0.', |
||
2099 | E_USER_DEPRECATED |
||
2100 | ); |
||
2101 | } |
||
2102 | } |
||
2103 | |||
2104 | public function hasChild($code) |
||
2108 | |||
2109 | public function getChildren() |
||
2113 | |||
2114 | public function getChild($code) |
||
2135 | |||
2136 | public function setParent(AdminInterface $parent) |
||
2140 | |||
2141 | public function getParent() |
||
2161 | |||
2162 | final public function getRootAncestor() |
||
2172 | |||
2173 | final public function getChildDepth() |
||
2185 | |||
2186 | final public function getCurrentLeafChildAdmin() |
||
2200 | |||
2201 | public function isChild() |
||
2205 | |||
2206 | /** |
||
2207 | * Returns true if the admin has children, false otherwise. |
||
2208 | * |
||
2209 | * @return bool if the admin has children |
||
2210 | */ |
||
2211 | public function hasChildren() |
||
2215 | |||
2216 | public function setUniqid($uniqid) |
||
2220 | |||
2221 | public function getUniqid() |
||
2229 | |||
2230 | /** |
||
2231 | * Returns the classname label. |
||
2232 | * |
||
2233 | * @return string the classname label |
||
2234 | */ |
||
2235 | public function getClassnameLabel() |
||
2239 | |||
2240 | public function getPersistentParameters() |
||
2241 | { |
||
2242 | $parameters = []; |
||
2243 | |||
2244 | foreach ($this->getExtensions() as $extension) { |
||
2245 | $params = $extension->getPersistentParameters($this); |
||
2246 | |||
2247 | if (!\is_array($params)) { |
||
2248 | throw new \RuntimeException(sprintf('The %s::getPersistentParameters must return an array', \get_class($extension))); |
||
2249 | } |
||
2250 | |||
2251 | $parameters = array_merge($parameters, $params); |
||
2252 | } |
||
2253 | |||
2254 | return $parameters; |
||
2255 | } |
||
2256 | |||
2257 | /** |
||
2258 | * @param string $name |
||
2259 | * |
||
2260 | * @return mixed|null |
||
2261 | */ |
||
2262 | public function getPersistentParameter($name) |
||
2263 | { |
||
2264 | $parameters = $this->getPersistentParameters(); |
||
2265 | |||
2266 | return $parameters[$name] ?? null; |
||
2267 | } |
||
2268 | |||
2269 | public function getBreadcrumbs($action) |
||
2270 | { |
||
2271 | @trigger_error( |
||
2272 | 'The '.__METHOD__.' method is deprecated since version 3.2 and will be removed in 4.0.'. |
||
2273 | ' Use Sonata\AdminBundle\Admin\BreadcrumbsBuilder::getBreadcrumbs instead.', |
||
2274 | E_USER_DEPRECATED |
||
2275 | ); |
||
2276 | |||
2277 | return $this->getBreadcrumbsBuilder()->getBreadcrumbs($this, $action); |
||
2278 | } |
||
2279 | |||
2280 | /** |
||
2281 | * Generates the breadcrumbs array. |
||
2282 | * |
||
2283 | * Note: the method will be called by the top admin instance (parent => child) |
||
2284 | * |
||
2285 | * @param string $action |
||
2286 | * |
||
2287 | * @return array |
||
2288 | */ |
||
2289 | public function buildBreadcrumbs($action, ?ItemInterface $menu = null) |
||
2290 | { |
||
2291 | @trigger_error( |
||
2292 | 'The '.__METHOD__.' method is deprecated since version 3.2 and will be removed in 4.0.', |
||
2293 | E_USER_DEPRECATED |
||
2294 | ); |
||
2295 | |||
2296 | if (isset($this->breadcrumbs[$action])) { |
||
2297 | return $this->breadcrumbs[$action]; |
||
2298 | } |
||
2299 | |||
2300 | return $this->breadcrumbs[$action] = $this->getBreadcrumbsBuilder() |
||
2301 | ->buildBreadcrumbs($this, $action, $menu); |
||
2303 | |||
2304 | /** |
||
2305 | * NEXT_MAJOR : remove this method. |
||
2306 | * |
||
2307 | * @return BreadcrumbsBuilderInterface |
||
2308 | */ |
||
2309 | final public function getBreadcrumbsBuilder() |
||
2324 | |||
2325 | /** |
||
2326 | * NEXT_MAJOR : remove this method. |
||
2327 | * |
||
2328 | * @return AbstractAdmin |
||
2329 | */ |
||
2330 | final public function setBreadcrumbsBuilder(BreadcrumbsBuilderInterface $value) |
||
2341 | |||
2342 | public function setCurrentChild($currentChild) |
||
2346 | |||
2347 | /** |
||
2348 | * NEXT_MAJOR: Remove this method. |
||
2349 | * |
||
2350 | * @deprecated since sonata-project/admin-bundle 3.65, to be removed in 4.0 |
||
2351 | */ |
||
2352 | public function getCurrentChild() |
||
2365 | |||
2366 | public function isCurrentChild(): bool |
||
2370 | |||
2371 | /** |
||
2372 | * Returns the current child admin instance. |
||
2373 | * |
||
2374 | * @return AdminInterface|null the current child admin instance |
||
2375 | */ |
||
2376 | public function getCurrentChildAdmin() |
||
2386 | |||
2387 | public function trans($id, array $parameters = [], $domain = null, $locale = null) |
||
2398 | |||
2399 | /** |
||
2400 | * Translate a message id. |
||
2401 | * |
||
2402 | * NEXT_MAJOR: remove this method |
||
2403 | * |
||
2404 | * @param string $id |
||
2405 | * @param int $count |
||
2406 | * @param string|null $domain |
||
2407 | * @param string|null $locale |
||
2408 | * |
||
2409 | * @return string the translated string |
||
2410 | * |
||
2411 | * @deprecated since sonata-project/admin-bundle 3.9, to be removed with 4.0 |
||
2412 | */ |
||
2413 | public function transChoice($id, $count, array $parameters = [], $domain = null, $locale = null) |
||
2424 | |||
2425 | public function setTranslationDomain($translationDomain) |
||
2429 | |||
2430 | public function getTranslationDomain() |
||
2434 | |||
2435 | /** |
||
2436 | * {@inheritdoc} |
||
2437 | * |
||
2438 | * NEXT_MAJOR: remove this method |
||
2439 | * |
||
2440 | * @deprecated since sonata-project/admin-bundle 3.9, to be removed with 4.0 |
||
2441 | */ |
||
2442 | public function setTranslator(TranslatorInterface $translator) |
||
2454 | |||
2455 | /** |
||
2456 | * {@inheritdoc} |
||
2457 | * |
||
2458 | * NEXT_MAJOR: remove this method |
||
2459 | * |
||
2460 | * @deprecated since sonata-project/admin-bundle 3.9, to be removed with 4.0 |
||
2461 | */ |
||
2462 | public function getTranslator() |
||
2471 | |||
2472 | public function getTranslationLabel($label, $context = '', $type = '') |
||
2476 | |||
2477 | public function setRequest(Request $request) |
||
2485 | |||
2486 | public function getRequest() |
||
2495 | |||
2496 | public function hasRequest() |
||
2500 | |||
2501 | public function setFormContractor(FormContractorInterface $formBuilder) |
||
2505 | |||
2506 | /** |
||
2507 | * @return FormContractorInterface |
||
2508 | */ |
||
2509 | public function getFormContractor() |
||
2513 | |||
2514 | public function setDatagridBuilder(DatagridBuilderInterface $datagridBuilder) |
||
2518 | |||
2519 | public function getDatagridBuilder() |
||
2523 | |||
2524 | public function setListBuilder(ListBuilderInterface $listBuilder) |
||
2528 | |||
2529 | public function getListBuilder() |
||
2533 | |||
2534 | public function setShowBuilder(ShowBuilderInterface $showBuilder) |
||
2538 | |||
2539 | /** |
||
2540 | * @return ShowBuilderInterface |
||
2541 | */ |
||
2542 | public function getShowBuilder() |
||
2546 | |||
2547 | public function setConfigurationPool(Pool $configurationPool) |
||
2551 | |||
2552 | /** |
||
2553 | * @return Pool |
||
2554 | */ |
||
2555 | public function getConfigurationPool() |
||
2559 | |||
2560 | public function setRouteGenerator(RouteGeneratorInterface $routeGenerator) |
||
2564 | |||
2565 | /** |
||
2566 | * @return RouteGeneratorInterface |
||
2567 | */ |
||
2568 | public function getRouteGenerator() |
||
2572 | |||
2573 | public function getCode() |
||
2577 | |||
2578 | /** |
||
2579 | * NEXT_MAJOR: Remove this function. |
||
2580 | * |
||
2581 | * @deprecated This method is deprecated since sonata-project/admin-bundle 3.24 and will be removed in 4.0 |
||
2582 | * |
||
2583 | * @param string $baseCodeRoute |
||
2584 | */ |
||
2585 | public function setBaseCodeRoute($baseCodeRoute) |
||
2594 | |||
2595 | public function getBaseCodeRoute() |
||
2617 | |||
2618 | public function getModelManager() |
||
2622 | |||
2623 | public function setModelManager(ModelManagerInterface $modelManager) |
||
2627 | |||
2628 | public function getManagerType() |
||
2632 | |||
2633 | /** |
||
2634 | * @param string $type |
||
2635 | */ |
||
2636 | public function setManagerType($type) |
||
2640 | |||
2641 | public function getObjectIdentifier() |
||
2645 | |||
2646 | /** |
||
2647 | * Set the roles and permissions per role. |
||
2648 | */ |
||
2649 | public function setSecurityInformation(array $information) |
||
2653 | |||
2654 | public function getSecurityInformation() |
||
2658 | |||
2659 | /** |
||
2660 | * Return the list of permissions the user should have in order to display the admin. |
||
2661 | * |
||
2662 | * @param string $context |
||
2663 | * |
||
2664 | * @return array |
||
2665 | */ |
||
2666 | public function getPermissionsShow($context) |
||
2675 | |||
2676 | public function showIn($context) |
||
2685 | |||
2686 | public function createObjectSecurity($object) |
||
2690 | |||
2691 | public function setSecurityHandler(SecurityHandlerInterface $securityHandler) |
||
2695 | |||
2696 | public function getSecurityHandler() |
||
2700 | |||
2701 | public function isGranted($name, $object = null) |
||
2712 | |||
2713 | public function getUrlSafeIdentifier($model) |
||
2717 | |||
2718 | public function getNormalizedIdentifier($model) |
||
2722 | |||
2723 | public function id($model) |
||
2727 | |||
2728 | public function setValidator($validator) |
||
2739 | |||
2740 | public function getValidator() |
||
2744 | |||
2745 | public function getShow() |
||
2751 | |||
2752 | public function setFormTheme(array $formTheme) |
||
2756 | |||
2757 | public function getFormTheme() |
||
2761 | |||
2762 | public function setFilterTheme(array $filterTheme) |
||
2766 | |||
2767 | public function getFilterTheme() |
||
2771 | |||
2772 | public function addExtension(AdminExtensionInterface $extension) |
||
2776 | |||
2777 | public function getExtensions() |
||
2781 | |||
2782 | public function setMenuFactory(FactoryInterface $menuFactory) |
||
2786 | |||
2787 | public function getMenuFactory() |
||
2791 | |||
2792 | public function setRouteBuilder(RouteBuilderInterface $routeBuilder) |
||
2796 | |||
2797 | public function getRouteBuilder() |
||
2801 | |||
2802 | public function toString($object) |
||
2814 | |||
2815 | public function setLabelTranslatorStrategy(LabelTranslatorStrategyInterface $labelTranslatorStrategy) |
||
2819 | |||
2820 | public function getLabelTranslatorStrategy() |
||
2824 | |||
2825 | public function supportsPreviewMode() |
||
2829 | |||
2830 | /** |
||
2831 | * NEXT_MAJOR: Remove this. |
||
2832 | * |
||
2833 | * @deprecated since sonata-project/admin-bundle 3.67, to be removed in 4.0. |
||
2834 | * |
||
2835 | * Set custom per page options. |
||
2836 | */ |
||
2837 | public function setPerPageOptions(array $options) |
||
2846 | |||
2847 | /** |
||
2848 | * Returns predefined per page options. |
||
2849 | * |
||
2850 | * @return array |
||
2851 | */ |
||
2852 | public function getPerPageOptions() |
||
2864 | |||
2865 | /** |
||
2866 | * Set pager type. |
||
2867 | * |
||
2868 | * @param string $pagerType |
||
2869 | */ |
||
2870 | public function setPagerType($pagerType) |
||
2874 | |||
2875 | /** |
||
2876 | * Get pager type. |
||
2877 | * |
||
2878 | * @return string |
||
2879 | */ |
||
2880 | public function getPagerType() |
||
2884 | |||
2885 | /** |
||
2886 | * Returns true if the per page value is allowed, false otherwise. |
||
2887 | * |
||
2888 | * @param int $perPage |
||
2889 | * |
||
2890 | * @return bool |
||
2891 | */ |
||
2892 | public function determinedPerPageValue($perPage) |
||
2896 | |||
2897 | public function isAclEnabled() |
||
2901 | |||
2902 | public function getObjectMetadata($object) |
||
2906 | |||
2907 | public function getListModes() |
||
2911 | |||
2912 | public function setListMode($mode) |
||
2920 | |||
2921 | public function getListMode() |
||
2929 | |||
2930 | public function getAccessMapping() |
||
2934 | |||
2935 | public function checkAccess($action, $object = null) |
||
2957 | |||
2958 | /** |
||
2959 | * Hook to handle access authorization, without throw Exception. |
||
2960 | * |
||
2961 | * @param string $action |
||
2962 | * @param object $object |
||
2963 | * |
||
2964 | * @return bool |
||
2965 | */ |
||
2966 | public function hasAccess($action, $object = null) |
||
2986 | |||
2987 | /** |
||
2988 | * @param string $action |
||
2989 | * @param object|null $object |
||
2990 | * |
||
2991 | * @return array |
||
2992 | */ |
||
2993 | public function configureActionButtons($action, $object = null) |
||
3067 | |||
3068 | /** |
||
3069 | * @param string $action |
||
3070 | * @param object $object |
||
3071 | * |
||
3072 | * @return array |
||
3073 | */ |
||
3074 | public function getActionButtons($action, $object = null) |
||
3087 | |||
3088 | /** |
||
3089 | * Get the list of actions that can be accessed directly from the dashboard. |
||
3090 | * |
||
3091 | * @return array |
||
3092 | */ |
||
3093 | public function getDashboardActions() |
||
3120 | |||
3121 | /** |
||
3122 | * Setting to true will enable mosaic button for the admin screen. |
||
3123 | * Setting to false will hide mosaic button for the admin screen. |
||
3124 | * |
||
3125 | * @param bool $isShown |
||
3126 | */ |
||
3127 | final public function showMosaicButton($isShown) |
||
3135 | |||
3136 | /** |
||
3137 | * @param object $object |
||
3138 | */ |
||
3139 | final public function getSearchResultLink($object) |
||
3149 | |||
3150 | /** |
||
3151 | * Checks if a filter type is set to a default value. |
||
3152 | * |
||
3153 | * @param string $name |
||
3154 | * |
||
3155 | * @return bool |
||
3156 | */ |
||
3157 | final public function isDefaultFilter($name) |
||
3168 | |||
3169 | /** |
||
3170 | * Check object existence and access, without throw Exception. |
||
3171 | * |
||
3172 | * @param string $action |
||
3173 | * @param object $object |
||
3174 | * |
||
3175 | * @return bool |
||
3176 | */ |
||
3177 | public function canAccessObject($action, $object) |
||
3181 | |||
3182 | protected function configureQuery(ProxyQueryInterface $query): ProxyQueryInterface |
||
3186 | |||
3187 | /** |
||
3188 | * @return MutableTemplateRegistryInterface |
||
3189 | */ |
||
3190 | final protected function getTemplateRegistry() |
||
3194 | |||
3195 | /** |
||
3196 | * Returns a list of default sort values. |
||
3197 | * |
||
3198 | * @return array{_page?: int, _per_page?: int, _sort_by?: string, _sort_order?: string} |
||
3199 | */ |
||
3200 | final protected function getDefaultSortValues(): array |
||
3215 | |||
3216 | /** |
||
3217 | * Returns a list of default filters. |
||
3218 | * |
||
3219 | * @return array |
||
3220 | */ |
||
3221 | final protected function getDefaultFilterValues() |
||
3236 | |||
3237 | protected function configureFormFields(FormMapper $form) |
||
3240 | |||
3241 | protected function configureListFields(ListMapper $list) |
||
3244 | |||
3245 | protected function configureDatagridFilters(DatagridMapper $filter) |
||
3248 | |||
3249 | protected function configureShowFields(ShowMapper $show) |
||
3252 | |||
3253 | protected function configureRoutes(RouteCollection $collection) |
||
3256 | |||
3257 | /** |
||
3258 | * Allows you to customize batch actions. |
||
3259 | * |
||
3260 | * @param array $actions List of actions |
||
3261 | * |
||
3262 | * @return array |
||
3263 | */ |
||
3264 | protected function configureBatchActions($actions) |
||
3268 | |||
3269 | /** |
||
3270 | * NEXT_MAJOR: remove this method. |
||
3271 | * |
||
3272 | * @deprecated Use configureTabMenu instead |
||
3273 | */ |
||
3274 | protected function configureSideMenu(ItemInterface $menu, $action, ?AdminInterface $childAdmin = null) |
||
3277 | |||
3278 | /** |
||
3279 | * Configures the tab menu in your admin. |
||
3280 | * |
||
3281 | * @param string $action |
||
3282 | */ |
||
3283 | protected function configureTabMenu(ItemInterface $menu, $action, ?AdminInterface $childAdmin = null) |
||
3289 | |||
3290 | /** |
||
3291 | * build the view FieldDescription array. |
||
3292 | */ |
||
3293 | protected function buildShow() |
||
3310 | |||
3311 | /** |
||
3312 | * build the list FieldDescription array. |
||
3313 | */ |
||
3314 | protected function buildList() |
||
3371 | |||
3372 | /** |
||
3373 | * Build the form FieldDescription collection. |
||
3374 | */ |
||
3375 | protected function buildForm() |
||
3390 | |||
3391 | /** |
||
3392 | * Gets the subclass corresponding to the given name. |
||
3393 | * |
||
3394 | * @param string $name The name of the sub class |
||
3395 | * |
||
3396 | * @return string the subclass |
||
3397 | */ |
||
3398 | protected function getSubClass($name) |
||
3411 | |||
3412 | /** |
||
3413 | * Attach the inline validator to the model metadata, this must be done once per admin. |
||
3414 | */ |
||
3415 | protected function attachInlineValidator() |
||
3442 | |||
3443 | /** |
||
3444 | * NEXT_MAJOR: Remove this function. |
||
3445 | * |
||
3446 | * @deprecated since sonata-project/admin-bundle 3.67, to be removed in 4.0. |
||
3447 | * |
||
3448 | * Predefine per page options. |
||
3449 | */ |
||
3450 | protected function predefinePerPageOptions() |
||
3456 | |||
3457 | /** |
||
3458 | * Return list routes with permissions name. |
||
3459 | * |
||
3460 | * @return array<string, string> |
||
3461 | */ |
||
3462 | protected function getAccess() |
||
3487 | |||
3488 | /** |
||
3489 | * Configures a list of default filters. |
||
3490 | */ |
||
3491 | protected function configureDefaultFilterValues(array &$filterValues) |
||
3494 | |||
3495 | /** |
||
3496 | * Configures a list of default sort values. |
||
3497 | * |
||
3498 | * Example: |
||
3499 | * $sortValues['_sort_by'] = 'foo' |
||
3500 | * $sortValues['_sort_order'] = 'DESC' |
||
3501 | */ |
||
3502 | protected function configureDefaultSortValues(array &$sortValues) |
||
3505 | |||
3506 | /** |
||
3507 | * Build all the related urls to the current admin. |
||
3508 | */ |
||
3509 | private function buildRoutes(): void |
||
3532 | } |
||
3533 | |||
3535 |
If you suppress an error, we recommend checking for the error condition explicitly: