You are here

class EntityViewAlterEvent in Hook Event Dispatcher 8.2

Same name and namespace in other branches
  1. 3.x modules/core_event_dispatcher/src/Event/Entity/EntityViewAlterEvent.php \Drupal\core_event_dispatcher\Event\Entity\EntityViewAlterEvent

Class EntityViewAlterEventEvent.

Hierarchy

Expanded class hierarchy of EntityViewAlterEvent

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

File

modules/core_event_dispatcher/src/Event/Entity/EntityViewAlterEvent.php, line 12

Namespace

Drupal\core_event_dispatcher\Event\Entity
View source
class EntityViewAlterEvent extends AbstractEntityEvent {

  /**
   * A renderable array representing the entity content.
   *
   * @var array
   */
  private $build;

  /**
   * The entity view display.
   *
   * @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface
   */
  private $display;

  /**
   * EntityViewAlterEventEvent constructor.
   *
   * @param array &$build
   *   A renderable array representing the entity content. The module may add
   *   elements to $build prior to rendering. The structure of $build is a
   *   renderable array as expected by drupal_render().
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   The entity object.
   * @param \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display
   *   The entity view display holding the display options configured for the
   *   entity components.
   */
  public function __construct(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
    parent::__construct($entity);
    $this->build =& $build;
    $this->display = $display;
  }

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

  /**
   * Get the display.
   *
   * @return \Drupal\Core\Entity\Display\EntityViewDisplayInterface
   *   The display.
   */
  public function getDisplay() : EntityViewDisplayInterface {
    return $this->display;
  }

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

}

Members

Namesort descending Modifiers Type Description Overrides
AbstractEntityEvent::$entity protected property The Entity.
AbstractEntityEvent::getEntity public function Get the Entity.
EntityViewAlterEvent::$build private property A renderable array representing the entity content.
EntityViewAlterEvent::$display private property The entity view display.
EntityViewAlterEvent::getBuild public function Get the build.
EntityViewAlterEvent::getDispatcherType public function Get the dispatcher type. Overrides EventInterface::getDispatcherType
EntityViewAlterEvent::getDisplay public function Get the display.
EntityViewAlterEvent::__construct public function EntityViewAlterEventEvent constructor. Overrides AbstractEntityEvent::__construct