You are here

class EntityBuildDefaultsAlterEvent in Hook Event Dispatcher 8

Class EntityBuildDefaultsAlterEvent.

Hierarchy

Expanded class hierarchy of EntityBuildDefaultsAlterEvent

2 files declare their use of EntityBuildDefaultsAlterEvent
EntityViewEventTest.php in tests/src/Unit/Entity/EntityViewEventTest.php
hook_event_dispatcher.module in ./hook_event_dispatcher.module
Hook event dispatcher module.

File

src/Event/Entity/EntityBuildDefaultsAlterEvent.php, line 11

Namespace

Drupal\hook_event_dispatcher\Event\Entity
View source
class EntityBuildDefaultsAlterEvent extends BaseEntityEvent {

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

  /**
   * The view mode.
   *
   * @var string
   */
  private $viewMode;

  /**
   * EntityBuildDefaultsAlterEvent constructor.
   *
   * @param array &$build
   *   A renderable array representing the entity content. It will not have
   *   other elements aside from the entity and a #cache parameter. The
   *   structure of $build is a renderable array as expected by drupal_render().
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   The entity object.
   * @param string $viewMode
   *   The view mode the entity is rendered in.
   */
  public function __construct(array &$build, EntityInterface $entity, string $viewMode) {
    parent::__construct($entity);
    $this->build =& $build;
    $this->viewMode = $viewMode;
  }

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

  /**
   * Get the view mode.
   *
   * @return string
   *   The view mode.
   */
  public function getViewMode() {
    return $this->viewMode;
  }

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

}

Members

Namesort descending Modifiers Type Description Overrides
BaseEntityEvent::$entity protected property The Entity.
BaseEntityEvent::getEntity public function Get the Entity.
BaseEntityEvent::setEntity Deprecated public function Set the Entity.
EntityBuildDefaultsAlterEvent::$build private property A renderable array representing the entity content.
EntityBuildDefaultsAlterEvent::$viewMode private property The view mode.
EntityBuildDefaultsAlterEvent::getBuild public function Get the build.
EntityBuildDefaultsAlterEvent::getDispatcherType public function Get the dispatcher type. Overrides EventInterface::getDispatcherType
EntityBuildDefaultsAlterEvent::getViewMode public function Get the view mode.
EntityBuildDefaultsAlterEvent::__construct public function EntityBuildDefaultsAlterEvent constructor. Overrides BaseEntityEvent::__construct