From 8851f3140360713b58bb27d7b233b74bcd5842c7 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Tue, 31 Aug 2021 22:43:08 +0200 Subject: [PATCH] Restrict visibility of getAccessMapping and make it configurable --- src/Admin/AbstractAdmin.php | 20 ++++++++------------ src/Admin/AccessRegistryInterface.php | 7 ------- tests/Controller/CRUDControllerTest.php | 1 - 3 files changed, 8 insertions(+), 20 deletions(-) diff --git a/src/Admin/AbstractAdmin.php b/src/Admin/AbstractAdmin.php index e1af33dcdb..ddfd8f206d 100644 --- a/src/Admin/AbstractAdmin.php +++ b/src/Admin/AbstractAdmin.php @@ -137,13 +137,6 @@ abstract class AbstractAdmin extends AbstractTaggedAdmin implements AdminInterfa */ protected $searchResultActions = ['edit', 'show']; - /** - * The Access mapping. - * - * @var array [action1 => requiredRole1, action2 => [requiredRole2, requiredRole3]] - */ - protected $accessMapping = []; - /** * The list FieldDescription constructed from the configureListField method. * @@ -1731,11 +1724,6 @@ final public function getListMode(): string return $this->getRequest()->getSession()->get(sprintf('%s.list_mode', $this->getCode()), 'list'); } - final public function getAccessMapping(): array - { - return $this->accessMapping; - } - final public function checkAccess(string $action, ?object $object = null): void { $access = $this->getAccess(); @@ -2224,6 +2212,14 @@ final protected function getAccess(): array return $access; } + /** + * @return array [action1 => requiredRole1, action2 => [requiredRole2, requiredRole3]] + */ + protected function getAccessMapping(): array + { + return []; + } + /** * Return the list of permissions the user should have in order to display the admin. * diff --git a/src/Admin/AccessRegistryInterface.php b/src/Admin/AccessRegistryInterface.php index b94b350e78..bd1b17eb53 100644 --- a/src/Admin/AccessRegistryInterface.php +++ b/src/Admin/AccessRegistryInterface.php @@ -22,13 +22,6 @@ */ interface AccessRegistryInterface { - /** - * Return the controller access mapping. - * - * @return array - */ - public function getAccessMapping(): array; - /** * Hook to handle access authorization. * diff --git a/tests/Controller/CRUDControllerTest.php b/tests/Controller/CRUDControllerTest.php index e08e2923a5..76d50753da 100644 --- a/tests/Controller/CRUDControllerTest.php +++ b/tests/Controller/CRUDControllerTest.php @@ -255,7 +255,6 @@ protected function setUp(): void ]); $this->admin->method('getIdParameter')->willReturn('id'); - $this->admin->method('getAccessMapping')->willReturn([]); $this->admin->method('getCode')->willReturn('foo.admin'); $this->admin->method('hasTemplateRegistry')->willReturn(true); $this->admin->method('getTemplateRegistry')->willReturn($this->templateRegistry);