Skip to content

Commit

Permalink
Restrict visibility of getAccessMapping and make it configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Sep 1, 2021
1 parent f412ccc commit 8851f31
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
20 changes: 8 additions & 12 deletions src/Admin/AbstractAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,6 @@ abstract class AbstractAdmin extends AbstractTaggedAdmin implements AdminInterfa
*/
protected $searchResultActions = ['edit', 'show'];

/**
* The Access mapping.
*
* @var array<string, string|string[]> [action1 => requiredRole1, action2 => [requiredRole2, requiredRole3]]
*/
protected $accessMapping = [];

/**
* The list FieldDescription constructed from the configureListField method.
*
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -2224,6 +2212,14 @@ final protected function getAccess(): array
return $access;
}

/**
* @return array<string, string|string[]> [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.
*
Expand Down
7 changes: 0 additions & 7 deletions src/Admin/AccessRegistryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@
*/
interface AccessRegistryInterface
{
/**
* Return the controller access mapping.
*
* @return array<string, string[]|string>
*/
public function getAccessMapping(): array;

/**
* Hook to handle access authorization.
*
Expand Down
1 change: 0 additions & 1 deletion tests/Controller/CRUDControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8851f31

Please sign in to comment.