You are here

class UnmasqueradeAccessCheck in Masquerade 8.2

Checks access based on the masquerade status of the user.

Hierarchy

Expanded class hierarchy of UnmasqueradeAccessCheck

1 string reference to 'UnmasqueradeAccessCheck'
masquerade.services.yml in ./masquerade.services.yml
masquerade.services.yml
1 service uses UnmasqueradeAccessCheck
access_check.masquerade.unmasquerade in ./masquerade.services.yml
Drupal\masquerade\Access\UnmasqueradeAccessCheck

File

src/Access/UnmasqueradeAccessCheck.php, line 12

Namespace

Drupal\masquerade\Access
View source
class UnmasqueradeAccessCheck implements AccessInterface {

  /**
   * The masquerade service.
   *
   * @var \Drupal\masquerade\Masquerade
   */
  protected $masquerade;

  /**
   * Constructs a new UnmasqueradeAccessCheck object.
   *
   * @param \Drupal\masquerade\Masquerade $masquerade
   *   The masquerade service.
   */
  public function __construct(Masquerade $masquerade) {
    $this->masquerade = $masquerade;
  }

  /**
   * Check to see if user is masquerading.
   *
   * @return \Drupal\Core\Access\AccessResultInterface
   *   The access result.
   */
  public function access() {
    return AccessResult::allowedIf($this->masquerade
      ->isMasquerading())
      ->addCacheContexts([
      'session.is_masquerading',
    ]);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
UnmasqueradeAccessCheck::$masquerade protected property The masquerade service.
UnmasqueradeAccessCheck::access public function Check to see if user is masquerading.
UnmasqueradeAccessCheck::__construct public function Constructs a new UnmasqueradeAccessCheck object.