diff --git a/src/Admin/AbstractAdmin.php b/src/Admin/AbstractAdmin.php index 2840161c79..3a64254972 100644 --- a/src/Admin/AbstractAdmin.php +++ b/src/Admin/AbstractAdmin.php @@ -581,6 +581,13 @@ public function initialize() $this->baseCodeRoute = $this->getCode(); $this->configure(); + + foreach ($this->getExtensions() as $extension) { + // NEXT_MAJOR: remove method_exists check + if (method_exists($extension, 'configure')) { + $extension->configure($this); + } + } } /** diff --git a/src/Admin/AbstractAdminExtension.php b/src/Admin/AbstractAdminExtension.php index bdf04ec7d3..179fa3d3a8 100644 --- a/src/Admin/AbstractAdminExtension.php +++ b/src/Admin/AbstractAdminExtension.php @@ -110,6 +110,13 @@ public function getAccessMapping(AdminInterface $admin) return []; } + /** + * @phpstan-param AdminInterface $admin + */ + public function configure(AdminInterface $admin): void + { + } + /** * @phpstan-param AdminInterface $admin */ diff --git a/src/Admin/AdminExtensionInterface.php b/src/Admin/AdminExtensionInterface.php index e24f134cd2..121614aac0 100644 --- a/src/Admin/AdminExtensionInterface.php +++ b/src/Admin/AdminExtensionInterface.php @@ -26,6 +26,7 @@ * @author Thomas Rabaix * * @method array getAccessMapping(AdminInterface $admin) + * @method void configure(AdminInterface $admin) * @method array configureBatchActions(AdminInterface $admin, array $actions) * @method array configureExportFields(AdminInterface $admin, array $fields) * @method array configureActionButtons(AdminInterface $admin, array $list, string $action, object $object) @@ -165,6 +166,13 @@ public function alterObject(AdminInterface $admin, $object); */ public function getPersistentParameters(AdminInterface $admin); + /** + * Get a chance to configure admin before used. + * + * @phpstan-param AdminInterface $admin + */ +// public function configure(AdminInterface $admin): void; + /** * Get a chance to add persistent parameters. *