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 |
||
82 | abstract class AbstractAdmin implements AdminInterface, DomainObjectInterface, AdminTreeInterface |
||
83 | { |
||
84 | const CONTEXT_MENU = 'menu'; |
||
85 | const CONTEXT_DASHBOARD = 'dashboard'; |
||
86 | |||
87 | const CLASS_REGEX = |
||
88 | '@ |
||
89 | (?:([A-Za-z0-9]*)\\\)? # vendor name / app name |
||
90 | (Bundle\\\)? # optional bundle directory |
||
91 | ([A-Za-z0-9]+?)(?:Bundle)?\\\ # bundle name, with optional suffix |
||
92 | ( |
||
93 | Entity|Document|Model|PHPCR|CouchDocument|Phpcr| |
||
94 | Doctrine\\\Orm|Doctrine\\\Phpcr|Doctrine\\\MongoDB|Doctrine\\\CouchDB |
||
95 | )\\\(.*)@x'; |
||
96 | |||
97 | const MOSAIC_ICON_CLASS = 'fa fa-th-large fa-fw'; |
||
98 | |||
99 | /** |
||
100 | * The list FieldDescription constructed from the configureListField method. |
||
101 | * |
||
102 | * @var array |
||
103 | */ |
||
104 | protected $listFieldDescriptions = []; |
||
105 | |||
106 | /** |
||
107 | * The show FieldDescription constructed from the configureShowFields method. |
||
108 | * |
||
109 | * @var array |
||
110 | */ |
||
111 | protected $showFieldDescriptions = []; |
||
112 | |||
113 | /** |
||
114 | * The list FieldDescription constructed from the configureFormField method. |
||
115 | * |
||
116 | * @var array |
||
117 | */ |
||
118 | protected $formFieldDescriptions = []; |
||
119 | |||
120 | /** |
||
121 | * The filter FieldDescription constructed from the configureFilterField method. |
||
122 | * |
||
123 | * @var array |
||
124 | */ |
||
125 | protected $filterFieldDescriptions = []; |
||
126 | |||
127 | /** |
||
128 | * The number of result to display in the list. |
||
129 | * |
||
130 | * @var int |
||
131 | */ |
||
132 | protected $maxPerPage = 32; |
||
133 | |||
134 | /** |
||
135 | * The maximum number of page numbers to display in the list. |
||
136 | * |
||
137 | * @var int |
||
138 | */ |
||
139 | protected $maxPageLinks = 25; |
||
140 | |||
141 | /** |
||
142 | * The base route name used to generate the routing information. |
||
143 | * |
||
144 | * @var string |
||
145 | */ |
||
146 | protected $baseRouteName; |
||
147 | |||
148 | /** |
||
149 | * The base route pattern used to generate the routing information. |
||
150 | * |
||
151 | * @var string |
||
152 | */ |
||
153 | protected $baseRoutePattern; |
||
154 | |||
155 | /** |
||
156 | * The base name controller used to generate the routing information. |
||
157 | * |
||
158 | * @var string |
||
159 | */ |
||
160 | protected $baseControllerName; |
||
161 | |||
162 | /** |
||
163 | * The label class name (used in the title/breadcrumb ...). |
||
164 | * |
||
165 | * @var string |
||
166 | */ |
||
167 | protected $classnameLabel; |
||
168 | |||
169 | /** |
||
170 | * The translation domain to be used to translate messages. |
||
171 | * |
||
172 | * @var string |
||
173 | */ |
||
174 | protected $translationDomain = 'messages'; |
||
175 | |||
176 | /** |
||
177 | * Options to set to the form (ie, validation_groups). |
||
178 | * |
||
179 | * @var array |
||
180 | */ |
||
181 | protected $formOptions = []; |
||
182 | |||
183 | /** |
||
184 | * Default values to the datagrid. |
||
185 | * |
||
186 | * @var array |
||
187 | */ |
||
188 | protected $datagridValues = [ |
||
189 | '_page' => 1, |
||
190 | '_per_page' => 32, |
||
191 | ]; |
||
192 | |||
193 | /** |
||
194 | * Predefined per page options. |
||
195 | * |
||
196 | * @var array |
||
197 | */ |
||
198 | protected $perPageOptions = [16, 32, 64, 128, 256]; |
||
199 | |||
200 | /** |
||
201 | * Pager type. |
||
202 | * |
||
203 | * @var string |
||
204 | */ |
||
205 | protected $pagerType = Pager::TYPE_DEFAULT; |
||
206 | |||
207 | /** |
||
208 | * The code related to the admin. |
||
209 | * |
||
210 | * @var string |
||
211 | */ |
||
212 | protected $code; |
||
213 | |||
214 | /** |
||
215 | * The label. |
||
216 | * |
||
217 | * @var string |
||
218 | */ |
||
219 | protected $label; |
||
220 | |||
221 | /** |
||
222 | * Whether or not to persist the filters in the session. |
||
223 | * |
||
224 | * NEXT_MAJOR: remove this property |
||
225 | * |
||
226 | * @var bool |
||
227 | * |
||
228 | * @deprecated since 3.34, to be removed in 4.0. |
||
229 | */ |
||
230 | protected $persistFilters = false; |
||
231 | |||
232 | /** |
||
233 | * Array of routes related to this admin. |
||
234 | * |
||
235 | * @var RouteCollection |
||
236 | */ |
||
237 | protected $routes; |
||
238 | |||
239 | /** |
||
240 | * The subject only set in edit/update/create mode. |
||
241 | * |
||
242 | * @var object |
||
243 | */ |
||
244 | protected $subject; |
||
245 | |||
246 | /** |
||
247 | * Define a Collection of child admin, ie /admin/order/{id}/order-element/{childId}. |
||
248 | * |
||
249 | * @var array |
||
250 | */ |
||
251 | protected $children = []; |
||
252 | |||
253 | /** |
||
254 | * Reference the parent collection. |
||
255 | * |
||
256 | * @var AdminInterface|null |
||
257 | */ |
||
258 | protected $parent = null; |
||
259 | |||
260 | /** |
||
261 | * The base code route refer to the prefix used to generate the route name. |
||
262 | * |
||
263 | * NEXT_MAJOR: remove this attribute. |
||
264 | * |
||
265 | * @deprecated This attribute is deprecated since 3.24 and will be removed in 4.0 |
||
266 | * |
||
267 | * @var string |
||
268 | */ |
||
269 | protected $baseCodeRoute = ''; |
||
270 | |||
271 | /** |
||
272 | * NEXT_MAJOR: should be default array and private. |
||
273 | * |
||
274 | * @var string|array |
||
275 | */ |
||
276 | protected $parentAssociationMapping = null; |
||
277 | |||
278 | /** |
||
279 | * Reference the parent FieldDescription related to this admin |
||
280 | * only set for FieldDescription which is associated to an Sub Admin instance. |
||
281 | * |
||
282 | * @var FieldDescriptionInterface |
||
283 | */ |
||
284 | protected $parentFieldDescription; |
||
285 | |||
286 | /** |
||
287 | * If true then the current admin is part of the nested admin set (from the url). |
||
288 | * |
||
289 | * @var bool |
||
290 | */ |
||
291 | protected $currentChild = false; |
||
292 | |||
293 | /** |
||
294 | * The uniqid is used to avoid clashing with 2 admin related to the code |
||
295 | * ie: a Block linked to a Block. |
||
296 | * |
||
297 | * @var string |
||
298 | */ |
||
299 | protected $uniqid; |
||
300 | |||
301 | /** |
||
302 | * The Entity or Document manager. |
||
303 | * |
||
304 | * @var ModelManagerInterface |
||
305 | */ |
||
306 | protected $modelManager; |
||
307 | |||
308 | /** |
||
309 | * The current request object. |
||
310 | * |
||
311 | * @var \Symfony\Component\HttpFoundation\Request |
||
312 | */ |
||
313 | protected $request; |
||
314 | |||
315 | /** |
||
316 | * The translator component. |
||
317 | * |
||
318 | * NEXT_MAJOR: remove this property |
||
319 | * |
||
320 | * @var \Symfony\Component\Translation\TranslatorInterface |
||
321 | * |
||
322 | * @deprecated since 3.9, to be removed with 4.0 |
||
323 | */ |
||
324 | protected $translator; |
||
325 | |||
326 | /** |
||
327 | * The related form contractor. |
||
328 | * |
||
329 | * @var FormContractorInterface |
||
330 | */ |
||
331 | protected $formContractor; |
||
332 | |||
333 | /** |
||
334 | * The related list builder. |
||
335 | * |
||
336 | * @var ListBuilderInterface |
||
337 | */ |
||
338 | protected $listBuilder; |
||
339 | |||
340 | /** |
||
341 | * The related view builder. |
||
342 | * |
||
343 | * @var ShowBuilderInterface |
||
344 | */ |
||
345 | protected $showBuilder; |
||
346 | |||
347 | /** |
||
348 | * The related datagrid builder. |
||
349 | * |
||
350 | * @var DatagridBuilderInterface |
||
351 | */ |
||
352 | protected $datagridBuilder; |
||
353 | |||
354 | /** |
||
355 | * @var RouteBuilderInterface |
||
356 | */ |
||
357 | protected $routeBuilder; |
||
358 | |||
359 | /** |
||
360 | * The datagrid instance. |
||
361 | * |
||
362 | * @var \Sonata\AdminBundle\Datagrid\DatagridInterface |
||
363 | */ |
||
364 | protected $datagrid; |
||
365 | |||
366 | /** |
||
367 | * The router instance. |
||
368 | * |
||
369 | * @var RouteGeneratorInterface |
||
370 | */ |
||
371 | protected $routeGenerator; |
||
372 | |||
373 | /** |
||
374 | * The generated breadcrumbs. |
||
375 | * |
||
376 | * NEXT_MAJOR : remove this property |
||
377 | * |
||
378 | * @var array |
||
379 | */ |
||
380 | protected $breadcrumbs = []; |
||
381 | |||
382 | /** |
||
383 | * @var SecurityHandlerInterface |
||
384 | */ |
||
385 | protected $securityHandler = null; |
||
386 | |||
387 | /** |
||
388 | * @var ValidatorInterface |
||
389 | */ |
||
390 | protected $validator = null; |
||
391 | |||
392 | /** |
||
393 | * The configuration pool. |
||
394 | * |
||
395 | * @var Pool |
||
396 | */ |
||
397 | protected $configurationPool; |
||
398 | |||
399 | /** |
||
400 | * @var MenuItemInterface |
||
401 | */ |
||
402 | protected $menu; |
||
403 | |||
404 | /** |
||
405 | * @var MenuFactoryInterface |
||
406 | */ |
||
407 | protected $menuFactory; |
||
408 | |||
409 | /** |
||
410 | * @var array |
||
411 | */ |
||
412 | protected $loaded = [ |
||
413 | 'view_fields' => false, |
||
414 | 'view_groups' => false, |
||
415 | 'routes' => false, |
||
416 | 'tab_menu' => false, |
||
417 | ]; |
||
418 | |||
419 | /** |
||
420 | * @var array |
||
421 | */ |
||
422 | protected $formTheme = []; |
||
423 | |||
424 | /** |
||
425 | * @var array |
||
426 | */ |
||
427 | protected $filterTheme = []; |
||
428 | |||
429 | /** |
||
430 | * @var array |
||
431 | * |
||
432 | * @deprecated since 3.34, will be dropped in 4.0. Use TemplateRegistry services instead |
||
433 | */ |
||
434 | protected $templates = []; |
||
435 | |||
436 | /** |
||
437 | * @var OldAdminExtensionInterface|NewAdminExtensionInterface[] |
||
438 | */ |
||
439 | protected $extensions = []; |
||
440 | |||
441 | /** |
||
442 | * @var LabelTranslatorStrategyInterface |
||
443 | */ |
||
444 | protected $labelTranslatorStrategy; |
||
445 | |||
446 | /** |
||
447 | * Setting to true will enable preview mode for |
||
448 | * the entity and show a preview button in the |
||
449 | * edit/create forms. |
||
450 | * |
||
451 | * @var bool |
||
452 | */ |
||
453 | protected $supportsPreviewMode = false; |
||
454 | |||
455 | /** |
||
456 | * Roles and permissions per role. |
||
457 | * |
||
458 | * @var array 'role' => ['permission', 'permission'] |
||
459 | */ |
||
460 | protected $securityInformation = []; |
||
461 | |||
462 | protected $cacheIsGranted = []; |
||
463 | |||
464 | /** |
||
465 | * Action list for the search result. |
||
466 | * |
||
467 | * @var string[] |
||
468 | */ |
||
469 | protected $searchResultActions = ['edit', 'show']; |
||
470 | |||
471 | protected $listModes = [ |
||
472 | 'list' => [ |
||
473 | 'class' => 'fa fa-list fa-fw', |
||
474 | ], |
||
475 | 'mosaic' => [ |
||
476 | 'class' => self::MOSAIC_ICON_CLASS, |
||
477 | ], |
||
478 | ]; |
||
479 | |||
480 | /** |
||
481 | * The Access mapping. |
||
482 | * |
||
483 | * @var array [action1 => requiredRole1, action2 => [requiredRole2, requiredRole3]] |
||
484 | */ |
||
485 | protected $accessMapping = []; |
||
486 | |||
487 | /** |
||
488 | * @var MutableTemplateRegistryInterface |
||
489 | */ |
||
490 | private $templateRegistry; |
||
491 | |||
492 | /** |
||
493 | * The class name managed by the admin class. |
||
494 | * |
||
495 | * @var string |
||
496 | */ |
||
497 | private $class; |
||
498 | |||
499 | /** |
||
500 | * The subclasses supported by the admin class. |
||
501 | * |
||
502 | * @var array |
||
503 | */ |
||
504 | private $subClasses = []; |
||
505 | |||
506 | /** |
||
507 | * The list collection. |
||
508 | * |
||
509 | * @var array |
||
510 | */ |
||
511 | private $list; |
||
512 | |||
513 | /** |
||
514 | * @var FieldDescriptionCollection |
||
515 | */ |
||
516 | private $show; |
||
517 | |||
518 | /** |
||
519 | * @var Form |
||
520 | */ |
||
521 | private $form; |
||
522 | |||
523 | /** |
||
524 | * @var DatagridInterface |
||
525 | */ |
||
526 | private $filter; |
||
|
|||
527 | |||
528 | /** |
||
529 | * The cached base route name. |
||
530 | * |
||
531 | * @var string |
||
532 | */ |
||
533 | private $cachedBaseRouteName; |
||
534 | |||
535 | /** |
||
536 | * The cached base route pattern. |
||
537 | * |
||
538 | * @var string |
||
539 | */ |
||
540 | private $cachedBaseRoutePattern; |
||
541 | |||
542 | /** |
||
543 | * The form group disposition. |
||
544 | * |
||
545 | * @var array|bool |
||
546 | */ |
||
547 | private $formGroups = false; |
||
548 | |||
549 | /** |
||
550 | * The form tabs disposition. |
||
551 | * |
||
552 | * @var array|bool |
||
553 | */ |
||
554 | private $formTabs = false; |
||
555 | |||
556 | /** |
||
557 | * The view group disposition. |
||
558 | * |
||
559 | * @var array|bool |
||
560 | */ |
||
561 | private $showGroups = false; |
||
562 | |||
563 | /** |
||
564 | * The view tab disposition. |
||
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 $baseControllerName |
||
595 | */ |
||
596 | public function __construct($code, $class, $baseControllerName) |
||
605 | |||
606 | /** |
||
607 | * {@inheritdoc} |
||
608 | * |
||
609 | * NEXT_MAJOR: return null to indicate no override |
||
610 | */ |
||
611 | public function getExportFormats() |
||
617 | |||
618 | /** |
||
619 | * @return array |
||
620 | */ |
||
621 | public function getExportFields() |
||
642 | |||
643 | public function getDataSourceIterator() |
||
665 | |||
666 | public function validate(ErrorElement $errorElement, $object) |
||
669 | |||
670 | /** |
||
671 | * define custom variable. |
||
672 | */ |
||
673 | public function initialize() |
||
684 | |||
685 | public function configure() |
||
688 | |||
689 | public function update($object) |
||
725 | |||
726 | public function create($object) |
||
764 | |||
765 | public function delete($object) |
||
796 | |||
797 | public function preValidate($object) |
||
800 | |||
801 | public function preUpdate($object) |
||
804 | |||
805 | public function postUpdate($object) |
||
808 | |||
809 | public function prePersist($object) |
||
812 | |||
813 | public function postPersist($object) |
||
816 | |||
817 | public function preRemove($object) |
||
820 | |||
821 | public function postRemove($object) |
||
824 | |||
825 | public function preBatchAction($actionName, ProxyQueryInterface $query, array &$idx, $allElements) |
||
828 | |||
829 | public function getFilterParameters() |
||
874 | |||
875 | public function buildDatagrid() |
||
938 | |||
939 | /** |
||
940 | * Returns the name of the parent related field, so the field can be use to set the default |
||
941 | * value (ie the parent object) or to filter the object. |
||
942 | * |
||
943 | * @throws \InvalidArgumentException |
||
944 | * |
||
945 | * @return null|string |
||
946 | */ |
||
947 | public function getParentAssociationMapping() |
||
967 | |||
968 | /** |
||
969 | * @param string $code |
||
970 | * @param string $value |
||
971 | */ |
||
972 | final public function addParentAssociationMapping($code, $value) |
||
976 | |||
977 | /** |
||
978 | * Returns the baseRoutePattern used to generate the routing information. |
||
979 | * |
||
980 | * @throws \RuntimeException |
||
981 | * |
||
982 | * @return string the baseRoutePattern used to generate the routing information |
||
983 | */ |
||
984 | public function getBaseRoutePattern() |
||
1022 | |||
1023 | /** |
||
1024 | * Returns the baseRouteName used to generate the routing information. |
||
1025 | * |
||
1026 | * @throws \RuntimeException |
||
1027 | * |
||
1028 | * @return string the baseRouteName used to generate the routing information |
||
1029 | */ |
||
1030 | public function getBaseRouteName() |
||
1067 | |||
1068 | /** |
||
1069 | * urlize the given word. |
||
1070 | * |
||
1071 | * @param string $word |
||
1072 | * @param string $sep the separator |
||
1073 | * |
||
1074 | * @return string |
||
1075 | */ |
||
1076 | public function urlize($word, $sep = '_') |
||
1080 | |||
1081 | public function getClass() |
||
1104 | |||
1105 | public function getSubClasses() |
||
1109 | |||
1110 | /** |
||
1111 | * NEXT_MAJOR: remove this method. |
||
1112 | */ |
||
1113 | public function addSubClass($subClass) |
||
1124 | |||
1125 | public function setSubClasses(array $subClasses) |
||
1129 | |||
1130 | public function hasSubClass($name) |
||
1134 | |||
1135 | public function hasActiveSubClass() |
||
1143 | |||
1144 | public function getActiveSubClass() |
||
1152 | |||
1153 | public function getActiveSubclassCode() |
||
1167 | |||
1168 | public function getBatchActions() |
||
1209 | |||
1210 | public function getRoutes() |
||
1216 | |||
1217 | public function getRouterIdParameter() |
||
1221 | |||
1222 | public function getIdParameter() |
||
1232 | |||
1233 | public function hasRoute($name) |
||
1241 | |||
1242 | public function isCurrentRoute($name, $adminCode = null) |
||
1263 | |||
1264 | public function generateObjectUrl($name, $object, array $parameters = [], $absolute = RoutingUrlGeneratorInterface::ABSOLUTE_PATH) |
||
1270 | |||
1271 | public function generateUrl($name, array $parameters = [], $absolute = RoutingUrlGeneratorInterface::ABSOLUTE_PATH) |
||
1275 | |||
1276 | public function generateMenuUrl($name, array $parameters = [], $absolute = RoutingUrlGeneratorInterface::ABSOLUTE_PATH) |
||
1280 | |||
1281 | final public function setTemplateRegistry(MutableTemplateRegistryInterface $templateRegistry) |
||
1285 | |||
1286 | public function setTemplates(array $templates) |
||
1293 | |||
1294 | /** |
||
1295 | * @param string $name |
||
1296 | * @param string $template |
||
1297 | */ |
||
1298 | public function setTemplate($name, $template) |
||
1305 | |||
1306 | /** |
||
1307 | * @deprecated since 3.34, will be dropped in 4.0. Use TemplateRegistry services instead |
||
1308 | * |
||
1309 | * @return array |
||
1310 | */ |
||
1311 | public function getTemplates() |
||
1315 | |||
1316 | /** |
||
1317 | * @deprecated since 3.34, will be dropped in 4.0. Use TemplateRegistry services instead |
||
1318 | * |
||
1319 | * @param string $name |
||
1320 | * |
||
1321 | * @return null|string |
||
1322 | */ |
||
1323 | public function getTemplate($name) |
||
1327 | |||
1328 | public function getNewInstance() |
||
1348 | |||
1349 | public function getFormBuilder() |
||
1362 | |||
1363 | /** |
||
1364 | * This method is being called by the main admin class and the child class, |
||
1365 | * the getFormBuilder is only call by the main admin class. |
||
1366 | */ |
||
1367 | public function defineFormBuilder(FormBuilderInterface $formBuilder) |
||
1390 | |||
1391 | public function attachAdminClass(FieldDescriptionInterface $fieldDescription) |
||
1413 | |||
1414 | public function getObject($id) |
||
1434 | |||
1435 | public function getForm() |
||
1441 | |||
1442 | public function getList() |
||
1448 | |||
1449 | public function createQuery($context = 'list') |
||
1473 | |||
1474 | public function getDatagrid() |
||
1480 | |||
1481 | public function buildTabMenu($action, AdminInterface $childAdmin = null) |
||
1517 | |||
1518 | public function buildSideMenu($action, AdminInterface $childAdmin = null) |
||
1522 | |||
1523 | /** |
||
1524 | * @param string $action |
||
1525 | * |
||
1526 | * @return ItemInterface |
||
1527 | */ |
||
1528 | public function getSideMenu($action, AdminInterface $childAdmin = null) |
||
1538 | |||
1539 | /** |
||
1540 | * Returns the root code. |
||
1541 | * |
||
1542 | * @return string the root code |
||
1543 | */ |
||
1544 | public function getRootCode() |
||
1548 | |||
1549 | /** |
||
1550 | * Returns the master admin. |
||
1551 | * |
||
1552 | * @return AbstractAdmin the root admin class |
||
1553 | */ |
||
1554 | public function getRoot() |
||
1564 | |||
1565 | public function setBaseControllerName($baseControllerName) |
||
1569 | |||
1570 | public function getBaseControllerName() |
||
1574 | |||
1575 | /** |
||
1576 | * @param string $label |
||
1577 | */ |
||
1578 | public function setLabel($label) |
||
1582 | |||
1583 | public function getLabel() |
||
1587 | |||
1588 | /** |
||
1589 | * @param bool $persist |
||
1590 | * |
||
1591 | * NEXT_MAJOR: remove this method |
||
1592 | * |
||
1593 | * @deprecated since 3.34, to be removed in 4.0. |
||
1594 | */ |
||
1595 | public function setPersistFilters($persist) |
||
1604 | |||
1605 | /** |
||
1606 | * @param FilterPersisterInterface|null $filterPersister |
||
1607 | */ |
||
1608 | public function setFilterPersister(FilterPersisterInterface $filterPersister = null) |
||
1614 | |||
1615 | /** |
||
1616 | * @param int $maxPerPage |
||
1617 | */ |
||
1618 | public function setMaxPerPage($maxPerPage) |
||
1622 | |||
1623 | /** |
||
1624 | * @return int |
||
1625 | */ |
||
1626 | public function getMaxPerPage() |
||
1630 | |||
1631 | /** |
||
1632 | * @param int $maxPageLinks |
||
1633 | */ |
||
1634 | public function setMaxPageLinks($maxPageLinks) |
||
1638 | |||
1639 | /** |
||
1640 | * @return int |
||
1641 | */ |
||
1642 | public function getMaxPageLinks() |
||
1646 | |||
1647 | public function getFormGroups() |
||
1651 | |||
1652 | public function setFormGroups(array $formGroups) |
||
1656 | |||
1657 | public function removeFieldFromFormGroup($key) |
||
1667 | |||
1668 | /** |
||
1669 | * @param array $group |
||
1670 | */ |
||
1671 | public function reorderFormGroup($group, array $keys) |
||
1677 | |||
1678 | public function getFormTabs() |
||
1682 | |||
1683 | public function setFormTabs(array $formTabs) |
||
1687 | |||
1688 | public function getShowTabs() |
||
1692 | |||
1693 | public function setShowTabs(array $showTabs) |
||
1697 | |||
1698 | public function getShowGroups() |
||
1702 | |||
1703 | public function setShowGroups(array $showGroups) |
||
1707 | |||
1708 | public function reorderShowGroup($group, array $keys) |
||
1714 | |||
1715 | public function setParentFieldDescription(FieldDescriptionInterface $parentFieldDescription) |
||
1719 | |||
1720 | public function getParentFieldDescription() |
||
1724 | |||
1725 | public function hasParentFieldDescription() |
||
1729 | |||
1730 | public function setSubject($subject) |
||
1747 | |||
1748 | public function getSubject() |
||
1760 | |||
1761 | public function hasSubject() |
||
1765 | |||
1766 | public function getFormFieldDescriptions() |
||
1772 | |||
1773 | public function getFormFieldDescription($name) |
||
1777 | |||
1778 | /** |
||
1779 | * Returns true if the admin has a FieldDescription with the given $name. |
||
1780 | * |
||
1781 | * @param string $name |
||
1782 | * |
||
1783 | * @return bool |
||
1784 | */ |
||
1785 | public function hasFormFieldDescription($name) |
||
1789 | |||
1790 | public function addFormFieldDescription($name, FieldDescriptionInterface $fieldDescription) |
||
1794 | |||
1795 | /** |
||
1796 | * remove a FieldDescription. |
||
1797 | * |
||
1798 | * @param string $name |
||
1799 | */ |
||
1800 | public function removeFormFieldDescription($name) |
||
1804 | |||
1805 | /** |
||
1806 | * build and return the collection of form FieldDescription. |
||
1807 | * |
||
1808 | * @return array collection of form FieldDescription |
||
1809 | */ |
||
1810 | public function getShowFieldDescriptions() |
||
1816 | |||
1817 | /** |
||
1818 | * Returns the form FieldDescription with the given $name. |
||
1819 | * |
||
1820 | * @param string $name |
||
1821 | * |
||
1822 | * @return FieldDescriptionInterface |
||
1823 | */ |
||
1824 | public function getShowFieldDescription($name) |
||
1830 | |||
1831 | public function hasShowFieldDescription($name) |
||
1835 | |||
1836 | public function addShowFieldDescription($name, FieldDescriptionInterface $fieldDescription) |
||
1840 | |||
1841 | public function removeShowFieldDescription($name) |
||
1845 | |||
1846 | public function getListFieldDescriptions() |
||
1852 | |||
1853 | public function getListFieldDescription($name) |
||
1857 | |||
1858 | public function hasListFieldDescription($name) |
||
1864 | |||
1865 | public function addListFieldDescription($name, FieldDescriptionInterface $fieldDescription) |
||
1869 | |||
1870 | public function removeListFieldDescription($name) |
||
1874 | |||
1875 | public function getFilterFieldDescription($name) |
||
1879 | |||
1880 | public function hasFilterFieldDescription($name) |
||
1884 | |||
1885 | public function addFilterFieldDescription($name, FieldDescriptionInterface $fieldDescription) |
||
1889 | |||
1890 | public function removeFilterFieldDescription($name) |
||
1894 | |||
1895 | public function getFilterFieldDescriptions() |
||
1901 | |||
1902 | public function addChild(AdminInterface $child) |
||
1933 | |||
1934 | public function hasChild($code) |
||
1938 | |||
1939 | public function getChildren() |
||
1943 | |||
1944 | public function getChild($code) |
||
1948 | |||
1949 | public function setParent(AdminInterface $parent) |
||
1953 | |||
1954 | public function getParent() |
||
1958 | |||
1959 | final public function getRootAncestor() |
||
1969 | |||
1970 | final public function getChildDepth() |
||
1982 | |||
1983 | final public function getCurrentLeafChildAdmin() |
||
1997 | |||
1998 | public function isChild() |
||
2002 | |||
2003 | /** |
||
2004 | * Returns true if the admin has children, false otherwise. |
||
2005 | * |
||
2006 | * @return bool if the admin has children |
||
2007 | */ |
||
2008 | public function hasChildren() |
||
2012 | |||
2013 | public function setUniqid($uniqid) |
||
2017 | |||
2018 | public function getUniqid() |
||
2026 | |||
2027 | /** |
||
2028 | * Returns the classname label. |
||
2029 | * |
||
2030 | * @return string the classname label |
||
2031 | */ |
||
2032 | public function getClassnameLabel() |
||
2036 | |||
2037 | public function getPersistentParameters() |
||
2066 | |||
2067 | /** |
||
2068 | * @param string $name |
||
2069 | * |
||
2070 | * @return null|mixed |
||
2071 | */ |
||
2072 | public function getPersistentParameter($name) |
||
2078 | |||
2079 | public function getBreadcrumbs($action) |
||
2089 | |||
2090 | /** |
||
2091 | * Generates the breadcrumbs array. |
||
2092 | * |
||
2093 | * Note: the method will be called by the top admin instance (parent => child) |
||
2094 | * |
||
2095 | * @param string $action |
||
2096 | * |
||
2097 | * @return array |
||
2098 | */ |
||
2099 | public function buildBreadcrumbs($action, MenuItemInterface $menu = null) |
||
2113 | |||
2114 | /** |
||
2115 | * NEXT_MAJOR : remove this method. |
||
2116 | * |
||
2117 | * @return BreadcrumbsBuilderInterface |
||
2118 | */ |
||
2119 | final public function getBreadcrumbsBuilder() |
||
2134 | |||
2135 | /** |
||
2136 | * NEXT_MAJOR : remove this method. |
||
2137 | * |
||
2138 | * @return AbstractAdmin |
||
2139 | */ |
||
2140 | final public function setBreadcrumbsBuilder(BreadcrumbsBuilderInterface $value) |
||
2151 | |||
2152 | public function setCurrentChild($currentChild) |
||
2156 | |||
2157 | public function getCurrentChild() |
||
2161 | |||
2162 | /** |
||
2163 | * Returns the current child admin instance. |
||
2164 | * |
||
2165 | * @return AdminInterface|null the current child admin instance |
||
2166 | */ |
||
2167 | public function getCurrentChildAdmin() |
||
2175 | |||
2176 | public function trans($id, array $parameters = [], $domain = null, $locale = null) |
||
2187 | |||
2188 | /** |
||
2189 | * Translate a message id. |
||
2190 | * |
||
2191 | * NEXT_MAJOR: remove this method |
||
2192 | * |
||
2193 | * @param string $id |
||
2194 | * @param int $count |
||
2195 | * @param string|null $domain |
||
2196 | * @param string|null $locale |
||
2197 | * |
||
2198 | * @return string the translated string |
||
2199 | * |
||
2200 | * @deprecated since 3.9, to be removed with 4.0 |
||
2201 | */ |
||
2202 | public function transChoice($id, $count, array $parameters = [], $domain = null, $locale = null) |
||
2213 | |||
2214 | public function setTranslationDomain($translationDomain) |
||
2218 | |||
2219 | public function getTranslationDomain() |
||
2223 | |||
2224 | /** |
||
2225 | * {@inheritdoc} |
||
2226 | * |
||
2227 | * NEXT_MAJOR: remove this method |
||
2228 | * |
||
2229 | * @deprecated since 3.9, to be removed with 4.0 |
||
2230 | */ |
||
2231 | public function setTranslator(TranslatorInterface $translator) |
||
2243 | |||
2244 | /** |
||
2245 | * {@inheritdoc} |
||
2246 | * |
||
2247 | * NEXT_MAJOR: remove this method |
||
2248 | * |
||
2249 | * @deprecated since 3.9, to be removed with 4.0 |
||
2250 | */ |
||
2251 | public function getTranslator() |
||
2260 | |||
2261 | public function getTranslationLabel($label, $context = '', $type = '') |
||
2265 | |||
2266 | public function setRequest(Request $request) |
||
2274 | |||
2275 | public function getRequest() |
||
2283 | |||
2284 | public function hasRequest() |
||
2288 | |||
2289 | public function setFormContractor(FormContractorInterface $formBuilder) |
||
2293 | |||
2294 | /** |
||
2295 | * @return FormContractorInterface |
||
2296 | */ |
||
2297 | public function getFormContractor() |
||
2301 | |||
2302 | public function setDatagridBuilder(DatagridBuilderInterface $datagridBuilder) |
||
2306 | |||
2307 | public function getDatagridBuilder() |
||
2311 | |||
2312 | public function setListBuilder(ListBuilderInterface $listBuilder) |
||
2316 | |||
2317 | public function getListBuilder() |
||
2321 | |||
2322 | public function setShowBuilder(ShowBuilderInterface $showBuilder) |
||
2326 | |||
2327 | /** |
||
2328 | * @return ShowBuilderInterface |
||
2329 | */ |
||
2330 | public function getShowBuilder() |
||
2334 | |||
2335 | public function setConfigurationPool(Pool $configurationPool) |
||
2339 | |||
2340 | /** |
||
2341 | * @return Pool |
||
2342 | */ |
||
2343 | public function getConfigurationPool() |
||
2347 | |||
2348 | public function setRouteGenerator(RouteGeneratorInterface $routeGenerator) |
||
2352 | |||
2353 | /** |
||
2354 | * @return RouteGeneratorInterface |
||
2355 | */ |
||
2356 | public function getRouteGenerator() |
||
2360 | |||
2361 | public function getCode() |
||
2365 | |||
2366 | /** |
||
2367 | * NEXT_MAJOR: Remove this function. |
||
2368 | * |
||
2369 | * @deprecated This method is deprecated since 3.24 and will be removed in 4.0 |
||
2370 | * |
||
2371 | * @param string $baseCodeRoute |
||
2372 | */ |
||
2373 | public function setBaseCodeRoute($baseCodeRoute) |
||
2382 | |||
2383 | public function getBaseCodeRoute() |
||
2405 | |||
2406 | public function getModelManager() |
||
2410 | |||
2411 | public function setModelManager(ModelManagerInterface $modelManager) |
||
2415 | |||
2416 | public function getManagerType() |
||
2420 | |||
2421 | /** |
||
2422 | * @param string $type |
||
2423 | */ |
||
2424 | public function setManagerType($type) |
||
2428 | |||
2429 | public function getObjectIdentifier() |
||
2433 | |||
2434 | /** |
||
2435 | * Set the roles and permissions per role. |
||
2436 | */ |
||
2437 | public function setSecurityInformation(array $information) |
||
2441 | |||
2442 | public function getSecurityInformation() |
||
2446 | |||
2447 | /** |
||
2448 | * Return the list of permissions the user should have in order to display the admin. |
||
2449 | * |
||
2450 | * @param string $context |
||
2451 | * |
||
2452 | * @return array |
||
2453 | */ |
||
2454 | public function getPermissionsShow($context) |
||
2463 | |||
2464 | public function showIn($context) |
||
2473 | |||
2474 | public function createObjectSecurity($object) |
||
2478 | |||
2479 | public function setSecurityHandler(SecurityHandlerInterface $securityHandler) |
||
2483 | |||
2484 | public function getSecurityHandler() |
||
2488 | |||
2489 | public function isGranted($name, $object = null) |
||
2499 | |||
2500 | public function getUrlsafeIdentifier($entity) |
||
2504 | |||
2505 | public function getNormalizedIdentifier($entity) |
||
2509 | |||
2510 | public function id($entity) |
||
2514 | |||
2515 | public function setValidator($validator) |
||
2526 | |||
2527 | public function getValidator() |
||
2531 | |||
2532 | public function getShow() |
||
2538 | |||
2539 | public function setFormTheme(array $formTheme) |
||
2543 | |||
2544 | public function getFormTheme() |
||
2548 | |||
2549 | public function setFilterTheme(array $filterTheme) |
||
2553 | |||
2554 | public function getFilterTheme() |
||
2558 | |||
2559 | public function addExtension(OldAdminExtensionInterface $extension) |
||
2568 | |||
2569 | /** |
||
2570 | * NEXT_MAJOR: remove whole if and add only NewAdminExtensionInterface typehint. |
||
2571 | * |
||
2572 | * @param NewAdminExtensionInterface|OldAdminExtensionInterface $extension |
||
2573 | */ |
||
2574 | public function addAdminExtension($extension) |
||
2590 | |||
2591 | public function getExtensions() |
||
2595 | |||
2596 | public function setMenuFactory(MenuFactoryInterface $menuFactory) |
||
2600 | |||
2601 | public function getMenuFactory() |
||
2605 | |||
2606 | public function setRouteBuilder(RouteBuilderInterface $routeBuilder) |
||
2610 | |||
2611 | public function getRouteBuilder() |
||
2615 | |||
2616 | public function toString($object) |
||
2628 | |||
2629 | public function setLabelTranslatorStrategy(LabelTranslatorStrategyInterface $labelTranslatorStrategy) |
||
2633 | |||
2634 | public function getLabelTranslatorStrategy() |
||
2638 | |||
2639 | public function supportsPreviewMode() |
||
2643 | |||
2644 | /** |
||
2645 | * Set custom per page options. |
||
2646 | */ |
||
2647 | public function setPerPageOptions(array $options) |
||
2651 | |||
2652 | /** |
||
2653 | * Returns predefined per page options. |
||
2654 | * |
||
2655 | * @return array |
||
2656 | */ |
||
2657 | public function getPerPageOptions() |
||
2661 | |||
2662 | /** |
||
2663 | * Set pager type. |
||
2664 | * |
||
2665 | * @param string $pagerType |
||
2666 | */ |
||
2667 | public function setPagerType($pagerType) |
||
2671 | |||
2672 | /** |
||
2673 | * Get pager type. |
||
2674 | * |
||
2675 | * @return string |
||
2676 | */ |
||
2677 | public function getPagerType() |
||
2681 | |||
2682 | /** |
||
2683 | * Returns true if the per page value is allowed, false otherwise. |
||
2684 | * |
||
2685 | * @param int $perPage |
||
2686 | * |
||
2687 | * @return bool |
||
2688 | */ |
||
2689 | public function determinedPerPageValue($perPage) |
||
2693 | |||
2694 | public function isAclEnabled() |
||
2698 | |||
2699 | public function getObjectMetadata($object) |
||
2703 | |||
2704 | public function getListModes() |
||
2708 | |||
2709 | public function setListMode($mode) |
||
2717 | |||
2718 | public function getListMode() |
||
2726 | |||
2727 | public function getAccessMapping() |
||
2731 | |||
2732 | public function checkAccess($action, $object = null) |
||
2754 | |||
2755 | /** |
||
2756 | * Hook to handle access authorization, without throw Exception. |
||
2757 | * |
||
2758 | * @param string $action |
||
2759 | * @param object $object |
||
2760 | * |
||
2761 | * @return bool |
||
2762 | */ |
||
2763 | public function hasAccess($action, $object = null) |
||
2783 | |||
2784 | public function configureActionButtons($action, $object = null) |
||
2858 | |||
2859 | /** |
||
2860 | * @param string $action |
||
2861 | * @param mixed $object |
||
2862 | * |
||
2863 | * @return array |
||
2864 | */ |
||
2865 | public function getActionButtons($action, $object = null) |
||
2886 | |||
2887 | /** |
||
2888 | * Get the list of actions that can be accessed directly from the dashboard. |
||
2889 | * |
||
2890 | * @return array |
||
2891 | */ |
||
2892 | public function getDashboardActions() |
||
2919 | |||
2920 | /** |
||
2921 | * Setting to true will enable mosaic button for the admin screen. |
||
2922 | * Setting to false will hide mosaic button for the admin screen. |
||
2923 | * |
||
2924 | * @param bool $isShown |
||
2925 | */ |
||
2926 | final public function showMosaicButton($isShown) |
||
2934 | |||
2935 | /** |
||
2936 | * @param FormMapper $form |
||
2937 | */ |
||
2938 | final public function getSearchResultLink($object) |
||
2946 | |||
2947 | /** |
||
2948 | * Checks if a filter type is set to a default value. |
||
2949 | * |
||
2950 | * @param string $name |
||
2951 | * |
||
2952 | * @return bool |
||
2953 | */ |
||
2954 | final public function isDefaultFilter($name) |
||
2965 | |||
2966 | /** |
||
2967 | * Check object existence and access, without throw Exception. |
||
2968 | * |
||
2969 | * @param string $action |
||
2970 | * @param object $object |
||
2971 | * |
||
2972 | * @return bool |
||
2973 | */ |
||
2974 | public function canAccessObject($action, $object) |
||
2978 | |||
2979 | /** |
||
2980 | * @return MutableTemplateRegistryInterface |
||
2981 | */ |
||
2982 | final protected function getTemplateRegistry() |
||
2986 | |||
2987 | /** |
||
2988 | * Returns a list of default filters. |
||
2989 | * |
||
2990 | * @return array |
||
2991 | */ |
||
2992 | final protected function getDefaultFilterValues() |
||
3015 | |||
3016 | protected function configureFormFields(FormMapper $form) |
||
3019 | |||
3020 | protected function configureListFields(ListMapper $list) |
||
3023 | |||
3024 | protected function configureDatagridFilters(DatagridMapper $filter) |
||
3027 | |||
3028 | protected function configureShowFields(ShowMapper $show) |
||
3031 | |||
3032 | protected function configureRoutes(RouteCollection $collection) |
||
3035 | |||
3036 | /** |
||
3037 | * Allows you to customize batch actions. |
||
3038 | * |
||
3039 | * @param array $actions List of actions |
||
3040 | * |
||
3041 | * @return array |
||
3042 | */ |
||
3043 | protected function configureBatchActions($actions) |
||
3047 | |||
3048 | /** |
||
3049 | * NEXT_MAJOR: remove this method. |
||
3050 | * |
||
3051 | * @return mixed |
||
3052 | * |
||
3053 | * @deprecated Use configureTabMenu instead |
||
3054 | */ |
||
3055 | protected function configureSideMenu(MenuItemInterface $menu, $action, AdminInterface $childAdmin = null) |
||
3058 | |||
3059 | /** |
||
3060 | * Configures the tab menu in your admin. |
||
3061 | * |
||
3062 | * @param string $action |
||
3063 | * |
||
3064 | * @return mixed |
||
3065 | */ |
||
3066 | protected function configureTabMenu(MenuItemInterface $menu, $action, AdminInterface $childAdmin = null) |
||
3072 | |||
3073 | /** |
||
3074 | * build the view FieldDescription array. |
||
3075 | */ |
||
3076 | protected function buildShow() |
||
3102 | |||
3103 | /** |
||
3104 | * build the list FieldDescription array. |
||
3105 | */ |
||
3106 | protected function buildList() |
||
3173 | |||
3174 | /** |
||
3175 | * Build the form FieldDescription collection. |
||
3176 | */ |
||
3177 | protected function buildForm() |
||
3210 | |||
3211 | /** |
||
3212 | * Gets the subclass corresponding to the given name. |
||
3213 | * |
||
3214 | * @param string $name The name of the sub class |
||
3215 | * |
||
3216 | * @return string the subclass |
||
3217 | */ |
||
3218 | protected function getSubClass($name) |
||
3230 | |||
3231 | /** |
||
3232 | * Attach the inline validator to the model metadata, this must be done once per admin. |
||
3233 | */ |
||
3234 | protected function attachInlineValidator() |
||
3272 | |||
3273 | /** |
||
3274 | * Predefine per page options. |
||
3275 | */ |
||
3276 | protected function predefinePerPageOptions() |
||
3282 | |||
3283 | /** |
||
3284 | * Return list routes with permissions name. |
||
3285 | * |
||
3286 | * @return array |
||
3287 | */ |
||
3288 | protected function getAccess() |
||
3318 | |||
3319 | /** |
||
3320 | * Returns a list of default filters. |
||
3321 | */ |
||
3322 | protected function configureDefaultFilterValues(array &$filterValues) |
||
3325 | |||
3326 | /** |
||
3327 | * NEXT_MAJOR: remove this method. |
||
3328 | * |
||
3329 | * @param string $method |
||
3330 | * @param string $class |
||
3331 | */ |
||
3332 | private function triggerExtensionDeprecationMessage($method, $class) |
||
3340 | |||
3341 | /** |
||
3342 | * Build all the related urls to the current admin. |
||
3343 | */ |
||
3344 | private function buildRoutes() |
||
3378 | } |
||
3379 |
This check marks private properties in classes that are never used. Those properties can be removed.