Completed
Push — 3.x ( 3e834f...38b337 )
by Grégoire
03:36
created

src/Admin/AdminInterface.php (1 issue)

Check for PhpDoc comments which do parse

Documentation Minor

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Sonata Project package.
7
 *
8
 * (c) Thomas Rabaix <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Sonata\AdminBundle\Admin;
15
16
use Knp\Menu\FactoryInterface as MenuFactoryInterface;
17
use Sonata\AdminBundle\Builder\DatagridBuilderInterface;
18
use Sonata\AdminBundle\Builder\FormContractorInterface;
19
use Sonata\AdminBundle\Builder\ListBuilderInterface;
20
use Sonata\AdminBundle\Builder\RouteBuilderInterface;
21
use Sonata\AdminBundle\Datagrid\ProxyQueryInterface;
22
use Sonata\AdminBundle\Object\MetadataInterface;
23
use Sonata\AdminBundle\Security\Handler\SecurityHandlerInterface;
24
use Sonata\AdminBundle\Translator\LabelTranslatorStrategyInterface;
25
use Sonata\Exporter\Source\SourceIteratorInterface;
26
use Sonata\Form\Validator\ErrorElement;
27
use Symfony\Component\Form\FormBuilderInterface;
28
use Symfony\Component\Form\FormInterface;
29
use Symfony\Component\HttpFoundation\Request;
30
use Symfony\Component\Translation\TranslatorInterface;
31
use Symfony\Component\Validator\Validator\ValidatorInterface;
32
33
/**
34
 * @author Thomas Rabaix <[email protected]>
35
 *
36
 * @method array                           configureActionButtons(string $action, ?object $object = null)
37
 * @method string                          getSearchResultLink(object $object)
38
 * @method void                            showMosaicButton(bool $isShown)
39
 * @method bool                            isDefaultFilter(string $name)
40
 * @method bool                            isCurrentRoute(string $name, ?string $adminCode)
41
 * @method bool                            canAccessObject(string $action, object $object)
42
 * @method mixed                           getPersistentParameter(string $name)
43
 * @method array                           getExportFields()
44
 * @method array                           getSubClasses()
45
 * @method AdminInterface                  getRoot()
46
 * @method string                          getRootCode()
47
 * @method array                           getActionButtons(string $action, ?object $object)
48
 * @method FieldDescriptionCollection|null getList()
49
 */
50
interface AdminInterface extends AccessRegistryInterface, FieldDescriptionRegistryInterface, LifecycleHookProviderInterface, MenuBuilderInterface, ParentAdminInterface, UrlGeneratorInterface
51
{
52
    public function setMenuFactory(MenuFactoryInterface $menuFactory);
53
54
    /**
55
     * @return MenuFactoryInterface
56
     */
57
    public function getMenuFactory();
58
59
    public function setFormContractor(FormContractorInterface $formContractor);
60
61
    public function setListBuilder(ListBuilderInterface $listBuilder);
62
63
    /**
64
     * @return ListBuilderInterface
65
     */
66
    public function getListBuilder();
67
68
    public function setDatagridBuilder(DatagridBuilderInterface $datagridBuilder);
69
70
    /**
71
     * @return DatagridBuilderInterface
72
     */
73
    public function getDatagridBuilder();
74
75
    public function setTranslator(TranslatorInterface $translator);
76
77
    /**
78
     * @return TranslatorInterface
79
     */
80
    public function getTranslator();
81
82
    public function setRequest(Request $request);
83
84
    public function setConfigurationPool(Pool $pool);
85
86
    /**
87
     * Returns subjectClass/class/subclass name managed
88
     * - subclass name if subclass parameter is defined
89
     * - subject class name if subject is defined
90
     * - class name if not.
91
     *
92
     * @return string
93
     */
94
    public function getClass();
95
96
    public function attachAdminClass(FieldDescriptionInterface $fieldDescription);
97
98
    /**
99
     * @return \Sonata\AdminBundle\Datagrid\DatagridInterface
100
     */
101
    public function getDatagrid();
102
103
    /**
104
     * Set base controller name.
105
     *
106
     * @param string $baseControllerName
107
     */
108
    public function setBaseControllerName($baseControllerName);
109
110
    /**
111
     * Get base controller name.
112
     *
113
     * @return string
114
     */
115
    public function getBaseControllerName();
116
117
    /**
118
     * @return \Sonata\AdminBundle\Model\ModelManagerInterface
119
     */
120
    public function getModelManager();
121
122
    /**
123
     * @return string the manager type of the admin
124
     */
125
    public function getManagerType();
126
127
    /**
128
     * @param string $context NEXT_MAJOR: remove this argument
129
     *
130
     * @return ProxyQueryInterface
131
     */
132
    public function createQuery($context = 'list');
133
134
    /**
135
     * @return FormBuilderInterface the form builder
136
     */
137
    public function getFormBuilder();
138
139
    /**
140
     * Returns a form depend on the given $object.
141
     *
142
     * @return FormInterface
143
     */
144
    public function getForm();
145
146
    /**
147
     * NEXT MAJOR: Remove the throws tag.
148
     *
149
     * @throws \RuntimeException if no request is set
150
     *
151
     * @return Request
152
     */
153
    public function getRequest();
154
155
    /**
156
     * @return bool true if a request object is linked to this Admin, false
157
     *              otherwise
158
     */
159
    public function hasRequest();
160
161
    /**
162
     * @return string
163
     */
164
    public function getCode();
165
166
    /**
167
     * @return string
168
     */
169
    public function getBaseCodeRoute();
170
171
    /**
172
     * Return the roles and permissions per role
173
     * - different permissions per role for the acl handler
174
     * - one permission that has the same name as the role for the role handler
175
     * This should be used by experimented users.
176
     *
177
     * @return array 'role' => ['permission', 'permission']
178
     */
179
    public function getSecurityInformation();
180
181
    public function setParentFieldDescription(FieldDescriptionInterface $parentFieldDescription);
182
183
    /**
184
     * Get parent field description.
185
     *
186
     * @return FieldDescriptionInterface The parent field description
187
     */
188
    public function getParentFieldDescription();
189
190
    /**
191
     * Returns true if the Admin is linked to a parent FieldDescription.
192
     *
193
     * @return bool
194
     */
195
    public function hasParentFieldDescription();
196
197
    /**
198
     * translate a message id.
199
     *
200
     * NEXT_MAJOR: remove this method
201
     *
202
     * @param string      $id
203
     * @param string|null $domain
204
     * @param string|null $locale
205
     *
206
     * @return string the translated string
207
     *
208
     * @deprecated since sonata-project/admin-bundle 3.9, to be removed in 4.0
209
     */
210
    public function trans($id, array $parameters = [], $domain = null, $locale = null);
211
212
    /**
213
     * Returns the parameter representing request id, ie: id or childId.
214
     *
215
     * @return string
216
     */
217
    public function getIdParameter();
218
219
    /**
220
     * Returns true if the route $name is available.
221
     *
222
     * @param string $name
223
     *
224
     * @return bool
225
     */
226
    public function hasRoute($name);
227
228
    public function setSecurityHandler(SecurityHandlerInterface $securityHandler);
229
230
    /**
231
     * @return SecurityHandlerInterface|null
232
     */
233
    public function getSecurityHandler();
234
235
    /**
236
     * @param string      $name
237
     * @param object|null $object
238
     *
239
     * @return bool
240
     */
241
    public function isGranted($name, $object = null);
242
243
    /**
244
     * @param mixed $model
245
     *
246
     * @return string a string representation of the identifiers for this instance
247
     */
248
    public function getNormalizedIdentifier($model);
249
250
    /**
251
     * Shorthand method for templating.
252
     *
253
     * @param object $model
254
     *
255
     * @return mixed
256
     */
257
    public function id($model);
258
259
    /**
260
     * @param ValidatorInterface $validator
261
     */
262
    public function setValidator($validator);
263
264
    /**
265
     * @return ValidatorInterface
266
     */
267
    public function getValidator();
268
269
    /**
270
     * @return FieldDescriptionCollection|null
271
     */
272
    public function getShow();
273
274
//    NEXT_MAJOR: uncomment this method in 4.0
275
//    public function getList(): ?FieldDescriptionCollection;
276
277
    public function setFormTheme(array $formTheme);
278
279
    /**
280
     * @return string[]
281
     */
282
    public function getFormTheme();
283
284
    public function setFilterTheme(array $filterTheme);
285
286
    /**
287
     * @return string[]
288
     */
289
    public function getFilterTheme();
290
291
    public function addExtension(AdminExtensionInterface $extension);
292
293
    /**
294
     * Returns an array of extension related to the current Admin.
295
     *
296
     * @return AdminExtensionInterface[]
297
     */
298
    public function getExtensions();
299
300
    public function setRouteBuilder(RouteBuilderInterface $routeBuilder);
301
302
    /**
303
     * @return RouteBuilderInterface
304
     */
305
    public function getRouteBuilder();
306
307
    /**
308
     * @param object $object
309
     *
310
     * @return string
311
     */
312
    public function toString($object);
313
314
    public function setLabelTranslatorStrategy(LabelTranslatorStrategyInterface $labelTranslatorStrategy);
315
316
    /**
317
     * @return LabelTranslatorStrategyInterface
318
     */
319
    public function getLabelTranslatorStrategy();
320
321
    /**
322
     * Returning true will enable preview mode for
323
     * the target entity and show a preview button
324
     * when editing/creating an entity.
325
     *
326
     * @return bool
327
     */
328
    public function supportsPreviewMode();
329
330
    /**
331
     * @return object a new object instance
332
     */
333
    public function getNewInstance();
334
335
    /**
336
     * @param string $uniqId
337
     */
338
    public function setUniqid($uniqId);
339
340
    /**
341
     * Returns the uniqid.
342
     *
343
     * @return string
344
     */
345
    public function getUniqid();
346
347
    /**
348
     * @param mixed $id
349
     *
350
     * @return object|null
351
     */
352
    public function getObject($id);
353
354
    /**
355
     * @param object|null $subject
356
     */
357
    public function setSubject($subject);
358
359
    /**
360
     * NEXT MAJOR: return object.
361
     *
362
     * @return object|null
363
     */
364
    public function getSubject();
365
366
    /**
367
     * NEXT_MAJOR: Remove this method, since it's already in FieldDescriptionRegistryInterface.
368
     *
369
     * Returns a list FieldDescription.
370
     *
371
     * @param string $name
372
     *
373
     * @return FieldDescriptionInterface
374
     */
375
    public function getListFieldDescription($name);
376
377
    /**
378
     * NEXT_MAJOR: Remove this method, since it's already in FieldDescriptionRegistryInterface.
379
     *
380
     * Returns true if the list FieldDescription exists.
381
     *
382
     * @param string $name
383
     *
384
     * @return bool
385
     */
386
    public function hasListFieldDescription($name);
387
388
    /**
389
     * NEXT_MAJOR: Remove this method, since it's already in FieldDescriptionRegistryInterface.
390
     *
391
     * Returns the collection of list FieldDescriptions.
392
     *
393
     * @return array
394
     */
395
    public function getListFieldDescriptions();
396
397
    /**
398
     * Returns the array of allowed export formats.
399
     *
400
     * @return string[]
401
     */
402
    public function getExportFormats();
403
404
    /**
405
     * Returns SourceIterator.
406
     *
407
     * @return SourceIteratorInterface
408
     */
409
    public function getDataSourceIterator();
410
411
    public function configure();
412
413
    /**
414
     * Call before the batch action, allow you to alter the query and the idx.
415
     *
416
     * @param string $actionName
417
     * @param bool   $allElements
418
     */
419
    public function preBatchAction($actionName, ProxyQueryInterface $query, array &$idx, $allElements);
420
421
    /**
422
     * Return array of filter parameters.
423
     *
424
     * @return array<string, mixed>
425
     */
426
    public function getFilterParameters();
427
428
    /**
429
     * Return true if the Admin is related to a subject.
430
     *
431
     * @return bool
432
     */
433
    public function hasSubject();
434
435
    /**
436
     * NEXT_MAJOR: remove this method.
437
     *
438
     * @param object $object
439
     *
440
     * @deprecated this feature cannot be stable, use a custom validator,
441
     *             the feature will be removed with Symfony 2.2
442
     */
443
    public function validate(ErrorElement $errorElement, $object);
444
445
    /**
446
     * @param string $context
447
     *
448
     * @return bool
449
     */
450
    public function showIn($context);
451
452
    /**
453
     * Add object security, fe. make the current user owner of the object.
454
     *
455
     * @param object $object
456
     */
457
    public function createObjectSecurity($object);
458
459
    /**
460
     * @return AdminInterface|null NEXT_MAJOR: return AdminInterface
461
     */
462
    public function getParent();
463
464
    public function setParent(self $admin);
465
466
    /**
467
     * Returns true if the Admin class has an Parent Admin defined.
468
     *
469
     * @return bool
470
     */
471
    public function isChild();
472
473
    /**
474
     * Returns template.
475
     *
476
     * @deprecated since sonata-project/admin-bundle 3.35. To be removed in 4.0. Use TemplateRegistry services instead
477
     *
478
     * @param string $name
479
     *
480
     * @return string|null
481
     */
482
    public function getTemplate($name);
483
484
    /**
485
     * Set the translation domain.
486
     *
487
     * @param string $translationDomain the translation domain
488
     */
489
    public function setTranslationDomain($translationDomain);
490
491
    /**
492
     * Returns the translation domain.
493
     *
494
     * @return string the translation domain
495
     */
496
    public function getTranslationDomain();
497
498
    /**
499
     * Return the form groups.
500
     *
501
     * NEXT_MAJOR: must return only `array<string, mixed>`.
502
     *
503
     * @return array<string, mixed>|false (false if the groups have not been initialized)
504
     */
505
    public function getFormGroups();
506
507
    /**
508
     * Set the form groups.
509
     */
510
    public function setFormGroups(array $formGroups);
511
512
    /**
513
     * NEXT_MAJOR: must return only `array<string, mixed>`.
514
     */
515
    public function getFormTabs();
516
517
    public function setFormTabs(array $formTabs);
518
519
    /**
520
     * NEXT_MAJOR: must return only `array<string, mixed>`.
521
     */
522
    public function getShowTabs();
523
524
    public function setShowTabs(array $showTabs);
525
526
    /**
527
     * Remove a form group field.
528
     *
529
     * @param string $key
530
     */
531
    public function removeFieldFromFormGroup($key);
532
533
    /**
534
     * Returns the show groups.
535
     *
536
     * NEXT_MAJOR: must return only `array<string, mixed>`.
537
     *
538
     * @return array<string, mixed>|false (false if the groups have not been initialized)
539
     */
540
    public function getShowGroups();
541
542
    /**
543
     * Set the show groups.
544
     */
545
    public function setShowGroups(array $showGroups);
546
547
    /**
548
     * Reorder items in showGroup.
549
     *
550
     * @param string $group
551
     */
552
    public function reorderShowGroup($group, array $keys);
553
554
    /**
555
     * NEXT_MAJOR: Remove this method, since it's already in FieldDescriptionRegistryInterface.
556
     *
557
     * add a FieldDescription.
558
     *
559
     * @param string $name
560
     */
561
    public function addFormFieldDescription($name, FieldDescriptionInterface $fieldDescription);
562
563
    /**
564
     * NEXT_MAJOR: Remove this method, since it's already in FieldDescriptionRegistryInterface.
565
     *
566
     * Remove a FieldDescription.
567
     *
568
     * @param string $name
569
     */
570
    public function removeFormFieldDescription($name);
571
572
    /**
573
     * Returns true if this admin uses ACL.
574
     *
575
     * @return bool
576
     */
577
    public function isAclEnabled();
578
579
    /**
580
     * Sets the list of supported sub classes.
581
     */
582
    public function setSubClasses(array $subClasses);
583
584
    /**
585
     * Returns true if the admin has the sub classes.
586
     *
587
     * @param string $name The name of the sub class
588
     *
589
     * @return bool
590
     */
591
    public function hasSubClass($name);
592
593
    /**
594
     * Returns true if a subclass is currently active.
595
     *
596
     * @return bool
597
     */
598
    public function hasActiveSubClass();
599
600
    /**
601
     * Returns the currently active sub class.
602
     *
603
     * @return string the active sub class
604
     */
605
    public function getActiveSubClass();
606
607
    /**
608
     * Returns the currently active sub class code.
609
     *
610
     * @return string the code for active sub class
611
     */
612
    public function getActiveSubclassCode();
613
614
    /**
615
     * Returns the list of batchs actions.
616
     *
617
     * @return array<string, mixed> the list of batchs actions
618
     */
619
    public function getBatchActions();
620
621
    /**
622
     * Returns Admin`s label.
623
     *
624
     * @return string
625
     */
626
    public function getLabel();
627
628
    /**
629
     * Returns an array of persistent parameters.
630
     *
631
     * @return array<string, mixed>
0 ignored issues
show
The doc-type array<string, could not be parsed: Expected ">" at position 5, but found "end of type". (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
632
     */
633
    public function getPersistentParameters();
634
635
    /**
636
     * NEXT_MAJOR: remove this signature
637
     * Get breadcrumbs for $action.
638
     *
639
     * @param string $action
640
     *
641
     * @return iterable
642
     */
643
    public function getBreadcrumbs($action);
644
645
    /**
646
     * Set the current child status.
647
     *
648
     * @param bool $currentChild
649
     */
650
    public function setCurrentChild($currentChild);
651
652
    /**
653
     * Returns the current child status.
654
     *
655
     * NEXT_MAJOR: Rename the function isCurrentChild()
656
     *
657
     * @return bool
658
     */
659
    public function getCurrentChild();
660
661
    /**
662
     * Get translation label using the current TranslationStrategy.
663
     *
664
     * @param string $label
665
     * @param string $context
666
     * @param string $type
667
     *
668
     * @return string
669
     */
670
    public function getTranslationLabel($label, $context = '', $type = '');
671
672
    /**
673
     * @param object $object
674
     *
675
     * @return MetadataInterface
676
     */
677
    public function getObjectMetadata($object);
678
679
    /**
680
     * @return array<string, array<string, mixed>>
681
     */
682
    public function getListModes();
683
684
    /**
685
     * Check the current request is given route or not.
686
     *
687
     * NEXT_MAJOR: uncomment this method
688
     *
689
     * ```
690
     * $this->isCurrentRoute('create'); // is create page?
691
     * $this->isCurrentRoute('edit', 'some.admin.code'); // is some.admin.code admin's edit page?
692
     * ```
693
     */
694
    // public function isCurrentRoute(string $name, ?string $adminCode = null): bool;
695
696
    /**
697
     * @param string $mode
698
     */
699
    public function setListMode($mode);
700
701
    /**
702
     * @return string
703
     */
704
    public function getListMode();
705
706
    /*
707
     * Configure buttons for an action
708
     */
709
    // public function configureActionButtons(string $action, ?object $object = null): array;
710
711
    // NEXT_MAJOR: uncomment this method for 4.0
712
    /*
713
     * Returns the result link for an object.
714
     */
715
    //public function getSearchResultLink(object $object): ?string
716
717
//    NEXT_MAJOR: uncomment this method in 4.0
718
//    /**
719
//     * Setting to true will enable mosaic button for the admin screen.
720
//     * Setting to false will hide mosaic button for the admin screen.
721
//     */
722
//    public function showMosaicButton(bool $isShown): void;
723
724
    /*
725
     * Checks if a filter type is set to a default value
726
     */
727
//    NEXT_MAJOR: uncomment this method in 4.0
728
    // public function isDefaultFilter(string $name): bool;
729
}
730
731
class_exists(\Sonata\Form\Validator\ErrorElement::class);
732