class EntityViewEvent in Hook Event Dispatcher 3.x
Same name and namespace in other branches
- 8.2 modules/core_event_dispatcher/src/Event/Entity/EntityViewEvent.php \Drupal\core_event_dispatcher\Event\Entity\EntityViewEvent
 
Class EntityViewEvent.
Hierarchy
- class \Drupal\core_event_dispatcher\Event\Entity\AbstractEntityEvent extends \Symfony\Component\EventDispatcher\Event implements EventInterface
- class \Drupal\core_event_dispatcher\Event\Entity\EntityViewEvent
 
 
Expanded class hierarchy of EntityViewEvent
3 files declare their use of EntityViewEvent
- 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  - ExampleEntityEventSubscribers.php in examples/
ExampleEntityEventSubscribers.php  
File
- modules/
core_event_dispatcher/ src/ Event/ Entity/ EntityViewEvent.php, line 12  
Namespace
Drupal\core_event_dispatcher\Event\EntityView source
class EntityViewEvent 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;
  /**
   * The view mode.
   *
   * @var string
   */
  private $viewMode;
  /**
   * EntityViewEvent 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.
   * @param string $viewMode
   *   The view mode the entity is rendered in.
   */
  public function __construct(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, string $viewMode) {
    parent::__construct($entity);
    $this->build =& $build;
    $this->display = $display;
    $this->viewMode = $viewMode;
  }
  /**
   * 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;
  }
  /**
   * Get the view mode.
   *
   * @return string
   *   The view mode.
   */
  public function getViewMode() : string {
    return $this->viewMode;
  }
  /**
   * {@inheritdoc}
   */
  public function getDispatcherType() : string {
    return HookEventDispatcherInterface::ENTITY_VIEW;
  }
}Members
| 
            Name | 
                  Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| 
            AbstractEntityEvent:: | 
                  protected | property | The Entity. | |
| 
            AbstractEntityEvent:: | 
                  public | function | Get the Entity. | |
| 
            EntityViewEvent:: | 
                  private | property | A renderable array representing the entity content. | |
| 
            EntityViewEvent:: | 
                  private | property | The entity view display. | |
| 
            EntityViewEvent:: | 
                  private | property | The view mode. | |
| 
            EntityViewEvent:: | 
                  public | function | Get the build. | |
| 
            EntityViewEvent:: | 
                  public | function | 
            Get the dispatcher type. Overrides EventInterface:: | 
                  |
| 
            EntityViewEvent:: | 
                  public | function | Get the display. | |
| 
            EntityViewEvent:: | 
                  public | function | Get the view mode. | |
| 
            EntityViewEvent:: | 
                  public | function | 
            EntityViewEvent constructor. Overrides AbstractEntityEvent:: |