You are here

class EntityFieldAccessEvent in Hook Event Dispatcher 8

Class EntityInsertEvent.

Hierarchy

Expanded class hierarchy of EntityFieldAccessEvent

2 files declare their use of EntityFieldAccessEvent
EntityFieldAccessEventTest.php in tests/src/Unit/EntityField/EntityFieldAccessEventTest.php
hook_event_dispatcher.module in ./hook_event_dispatcher.module
Hook event dispatcher module.

File

src/Event/EntityField/EntityFieldAccessEvent.php, line 17

Namespace

Drupal\hook_event_dispatcher\Event\EntityField
View source
class EntityFieldAccessEvent extends Event implements EventInterface {

  /**
   * The operation.
   *
   * @var string
   */
  private $operation;

  /**
   * The field definition.
   *
   * @var \Drupal\Core\Field\FieldDefinitionInterface
   */
  private $fieldDefinition;

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

  /**
   * The field item list.
   *
   * @var \Drupal\Core\Field\FieldItemListInterface
   */
  private $items;

  /**
   * Get the access result.
   *
   * @var \Drupal\Core\Access\AccessResultInterface
   */
  private $accessResult;

  /**
   * EntityFieldAccessEvent constructor.
   *
   * @param string $operation
   *   The operation.
   * @param \Drupal\Core\Field\FieldDefinitionInterface $fieldDefinition
   *   The field definition.
   * @param \Drupal\Core\Session\AccountInterface $account
   *   The account interface.
   * @param \Drupal\Core\Field\FieldItemListInterface|null $items
   *   The field item list interface.
   */
  public function __construct($operation, FieldDefinitionInterface $fieldDefinition, AccountInterface $account, FieldItemListInterface $items = NULL) {
    $this->operation = $operation;
    $this->fieldDefinition = $fieldDefinition;
    $this->account = $account;
    $this->items = $items;
  }

  /**
   * {@inheritdoc}
   */
  public function getDispatcherType() {
    return HookEventDispatcherInterface::ENTITY_FIELD_ACCESS;
  }

  /**
   * Get the operation.
   *
   * @return string
   *   The operation.
   */
  public function getOperation() {
    return $this->operation;
  }

  /**
   * Get the field definition.
   *
   * @return \Drupal\Core\Field\FieldDefinitionInterface
   *   The field definition.
   */
  public function getFieldDefinition() {
    return $this->fieldDefinition;
  }

  /**
   * Get the account interface.
   *
   * @return \Drupal\Core\Session\AccountInterface
   *   Account interface.
   */
  public function getAccount() {
    return $this->account;
  }

  /**
   * Get the items.
   *
   * @return \Drupal\Core\Field\FieldItemListInterface
   *   The items.
   */
  public function getItems() {
    return $this->items;
  }

  /**
   * Get the access result.
   *
   * @return \Drupal\Core\Access\AccessResultInterface
   *   The access result.
   */
  public function getAccessResult() {
    return $this->accessResult ?: AccessResultNeutral::neutral();
  }

  /**
   * Set the access result.
   *
   * @param \Drupal\Core\Access\AccessResultInterface $accessResult
   *   The access result.
   */
  public function setAccessResult(AccessResultInterface $accessResult) {
    $this->accessResult = $accessResult;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityFieldAccessEvent::$accessResult private property Get the access result.
EntityFieldAccessEvent::$account private property The account.
EntityFieldAccessEvent::$fieldDefinition private property The field definition.
EntityFieldAccessEvent::$items private property The field item list.
EntityFieldAccessEvent::$operation private property The operation.
EntityFieldAccessEvent::getAccessResult public function Get the access result.
EntityFieldAccessEvent::getAccount public function Get the account interface.
EntityFieldAccessEvent::getDispatcherType public function Get the dispatcher type. Overrides EventInterface::getDispatcherType
EntityFieldAccessEvent::getFieldDefinition public function Get the field definition.
EntityFieldAccessEvent::getItems public function Get the items.
EntityFieldAccessEvent::getOperation public function Get the operation.
EntityFieldAccessEvent::setAccessResult public function Set the access result.
EntityFieldAccessEvent::__construct public function EntityFieldAccessEvent constructor.