Skip to content
Snippets Groups Projects

Issue #3361975: Rename AuthorizationController

Files
5
@@ -2,17 +2,18 @@
declare(strict_types=1);
namespace Drupal\authorization;
namespace Drupal\authorization\Service;
use Drupal\authorization\AuthorizationServiceInterface;
use Drupal\authorization\Entity\AuthorizationProfile;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\user\UserInterface;
use Psr\Log\LoggerInterface;
/**
* Authorization controller.
* Authorization service.
*/
class AuthorizationController {
class AuthorizationService implements AuthorizationServiceInterface {
/**
* Entity type manager.
@@ -46,7 +47,7 @@ class AuthorizationController {
protected $processedAuthorizations = [];
/**
* Constructs a new AuthorizationController object.
* Constructs a new AuthorizationService object.
*/
public function __construct(
EntityTypeManagerInterface $entity_type_manager,
@@ -57,25 +58,21 @@ class AuthorizationController {
}
/**
* Set the user.
*
* We pass in the user by hand so we can act on the provisional Drupal
* user object we have available during login and other operations.
*
* @param \Drupal\user\UserInterface $user
* The user to act upon.
* {@inheritdoc}
*/
public function setUser(UserInterface $user) {
public function setUser(UserInterface $user): void {
$this->user = $user;
}
/**
* Process a specific profile.
*
* Saves the user account.
*
* @param string|int $profile_id
* Authorization profile to act upon.
* {@inheritdoc}
*/
public function getUser(): UserInterface {
return $this->user;
}
/**
* {@inheritdoc}
*/
public function setIndividualProfile($profile_id): void {
/** @var \Drupal\authorization\Entity\AuthorizationProfile $profile */
@@ -89,9 +86,7 @@ class AuthorizationController {
}
/**
* Fetch and process all available profiles.
*
* Saves the user account.
* {@inheritdoc}
*/
public function setAllProfiles(): void {
$queryResults = $this->entityTypeManager
@@ -105,14 +100,7 @@ class AuthorizationController {
}
/**
* Query a specific profile.
*
* This does *not* save the user account. We need this to simulate granting
* to know that in some modes we want to abort any further actions
* (e.g. no valid proposals in exclusive mode and deny access set).
*
* @param string $profile_id
* Authorization profile to act upon.
* {@inheritdoc}
*/
public function queryIndividualProfile(string $profile_id): void {
/** @var \Drupal\authorization\Entity\AuthorizationProfile $profile */
@@ -127,11 +115,7 @@ class AuthorizationController {
}
/**
* Fetch and query all available profiles.
*
* This does *not* save the user account.
*
* @see queryIndividualProfile()
* {@inheritdoc}
*/
public function queryAllProfiles(): void {
$queryResults = $this->entityTypeManager->getStorage('authorization_profile')
@@ -143,6 +127,20 @@ class AuthorizationController {
}
}
/**
* {@inheritdoc}
*/
public function getProcessedAuthorizations(): array {
return $this->processedAuthorizations;
}
/**
* {@inheritdoc}
*/
public function clearAuthorizations(): void {
$this->processedAuthorizations = [];
}
/**
* Process Authorizations.
*
@@ -157,25 +155,4 @@ class AuthorizationController {
}
}
/**
* Returns list of all authorizations, which were processed.
*
* @return AuthorizationResponse[]
* Authorizations by human-readable label.
*/
public function getProcessedAuthorizations(): array {
return $this->processedAuthorizations;
}
/**
* Clear processed authorizations.
*
* If the service is called multiple times (e.g. for testing with query(),
* instead of set()) this allows one to clear the list of processed
* authorizations.
*/
public function clearAuthorizations(): void {
$this->processedAuthorizations = [];
}
}
Loading