You are here

class RegistrationAccessEvent in RNG - Events and Registrations 8.2

Same name and namespace in other branches
  1. 3.x src/Event/RegistrationAccessEvent.php \Drupal\rng\Event\RegistrationAccessEvent

Registration event to influence access.

Hierarchy

Expanded class hierarchy of RegistrationAccessEvent

2 files declare their use of RegistrationAccessEvent
RegistrationAccessControlHandler.php in src/AccessControl/RegistrationAccessControlHandler.php
RngRegistrationCreationSubscriber.php in src/EventSubscriber/RngRegistrationCreationSubscriber.php

File

src/Event/RegistrationAccessEvent.php, line 11

Namespace

Drupal\rng\Event
View source
class RegistrationAccessEvent extends Event {

  /**
   * The entity bundle.
   *
   * @var null|string
   */
  protected $entityBundle;

  /**
   * The account.
   *
   * @var \Drupal\Core\Session\AccountInterface
   */
  protected $account;

  /**
   * The context.
   *
   * @var array
   */
  protected $context;

  /**
   * Allow access.
   *
   * @var bool
   */
  protected $accessAllowed = TRUE;

  /**
   * RegistrationAccessEvent constructor.
   *
   * @param string $entity_bundle
   *   (optional) The bundle of the entity. Required if the entity supports
   *   bundles, defaults to NULL otherwise.
   * @param \Drupal\Core\Session\AccountInterface $account
   *   (optional) The user session for which to check access, or NULL to check
   *   access for the current user. Defaults to NULL.
   * @param array $context
   *   (optional) An array of key-value pairs to pass additional context when
   *   needed.
   */
  public function __construct($entity_bundle = NULL, AccountInterface $account = NULL, array $context = []) {
    $this->entityBundle = $entity_bundle;
    $this->account = $account;
    $this->context = $context;
  }

  /**
   * Get the entity bundle.
   *
   * @return string|null
   *   The entity bundle or NULL.
   */
  public function getEntityBundle() {
    return $this->entityBundle;
  }

  /**
   * Get the user session for which to check access.
   *
   * @return \Drupal\Core\Session\AccountInterface|null
   *   Gets the user session or NULL.
   */
  public function getAccount() {
    return $this->account;
  }

  /**
   * Get the context.
   *
   * @return array
   *   The context.
   */
  public function getContext() {
    return $this->context;
  }

  /**
   * Get if access is allowed.
   *
   * @return bool
   *   True if access is not denied, otherwise FALSE.
   */
  public function isAccessAllowed() {
    return $this->accessAllowed;
  }

  /**
   * Set access.
   *
   * @param bool $access
   *   Boolean if access is allowed.
   */
  public function setAccess($access) {
    $this->accessAllowed = $access;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RegistrationAccessEvent::$accessAllowed protected property Allow access.
RegistrationAccessEvent::$account protected property The account.
RegistrationAccessEvent::$context protected property The context.
RegistrationAccessEvent::$entityBundle protected property The entity bundle.
RegistrationAccessEvent::getAccount public function Get the user session for which to check access.
RegistrationAccessEvent::getContext public function Get the context.
RegistrationAccessEvent::getEntityBundle public function Get the entity bundle.
RegistrationAccessEvent::isAccessAllowed public function Get if access is allowed.
RegistrationAccessEvent::setAccess public function Set access.
RegistrationAccessEvent::__construct public function RegistrationAccessEvent constructor.