Finds all AccessControls for the given entity type and id.
public findByTypeAndId ( string $type, integer $id ) : Sulu\Component\Security\Authorization\AccessControl\AccessControlInterface[] | ||
$type | string | The type of the AccessControl |
$id | integer | The id of the AccessControl |
리턴 | Sulu\Component\Security\Authorization\AccessControl\AccessControlInterface[] |
/** * Returns the permissions for all security identities. * * @param string $type The type of the protected object * @param string $identifier The identifier of the protected object * * @return array */ public function getPermissions($type, $identifier) { $accessControls = $this->accessControlRepository->findByTypeAndId($type, $identifier); $permissions = []; foreach ($accessControls as $accessControl) { $permissions[$accessControl->getRole()->getId()] = $this->maskConverter->convertPermissionsToArray($accessControl->getPermissions()); } return $permissions; }
public function testGetPermissionsForNotExistingAccessControl() { $this->accessControlRepository->findByTypeAndId('AcmeBundle\\Example', 1)->willReturn([]); $this->assertEquals($this->doctrineAccessControlProvider->getPermissions('AcmeBundle\\Example', 1), []); }