You are here

class EntityOperationEvent in Hook Event Dispatcher 3.x

Same name and namespace in other branches
  1. 8.2 modules/core_event_dispatcher/src/Event/Entity/EntityOperationEvent.php \Drupal\core_event_dispatcher\Event\Entity\EntityOperationEvent

Class EntityLoadEvent.

Hierarchy

Expanded class hierarchy of EntityOperationEvent

2 files declare their use of EntityOperationEvent
core_event_dispatcher.module in modules/core_event_dispatcher/core_event_dispatcher.module
Core event dispatcher submodule.
EntityOperationsTest.php in modules/core_event_dispatcher/tests/src/Unit/Entity/EntityOperationsTest.php

File

modules/core_event_dispatcher/src/Event/Entity/EntityOperationEvent.php, line 13

Namespace

Drupal\core_event_dispatcher\Event\Entity
View source
class EntityOperationEvent extends Event implements EventInterface {

  /**
   * The operations.
   *
   * @var array
   */
  private $operations = [];

  /**
   * The entity.
   *
   * @var \Drupal\Core\Entity\EntityInterface
   */
  private $entity;

  /**
   * EntityOperationEvent constructor.
   *
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   The entity.
   */
  public function __construct(EntityInterface $entity) {
    $this->entity = $entity;
  }

  /**
   * Get the entity.
   *
   * @return \Drupal\Core\Entity\EntityInterface
   *   The entity.
   */
  public function getEntity() : EntityInterface {
    return $this->entity;
  }

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

  /**
   * Set the operations.
   *
   * @param array $operations
   *   An array of operations.
   */
  public function setOperations(array $operations) : void {
    $this->operations = $operations;
  }

  /**
   * Add an operation.
   *
   * @param string $name
   *   Operation name.
   * @param array $operation
   *   Operation definition.
   */
  public function addOperation(string $name, array $operation) : void {
    $this->operations[$name] = $operation;
  }

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

}

Members

Namesort descending Modifiers Type Description Overrides
EntityOperationEvent::$entity private property The entity.
EntityOperationEvent::$operations private property The operations.
EntityOperationEvent::addOperation public function Add an operation.
EntityOperationEvent::getDispatcherType public function Get the dispatcher type. Overrides EventInterface::getDispatcherType
EntityOperationEvent::getEntity public function Get the entity.
EntityOperationEvent::getOperations public function Get the operations.
EntityOperationEvent::setOperations public function Set the operations.
EntityOperationEvent::__construct public function EntityOperationEvent constructor.