You are here

class WebformNodeElementPreRender in Webform Node Element 8

Event dispatched prior to each webform_node_element being rendered.

This gives other modules a chance to dynamically set the nid and display mode of the node being rendered.

Hierarchy

Expanded class hierarchy of WebformNodeElementPreRender

2 files declare their use of WebformNodeElementPreRender
ExampleEventSubscriber.php in modules/webform_node_element_example/src/EventSubscriber/ExampleEventSubscriber.php
WebformNodeElement.php in src/Element/WebformNodeElement.php

File

src/Event/WebformNodeElementPreRender.php, line 13

Namespace

Drupal\webform_node_element\Event
View source
class WebformNodeElementPreRender extends Event {
  const PRERENDER = 'webform_node_element.pre_render';
  protected $elementID = NULL;
  protected $nid = NULL;
  protected $displayMode = NULL;

  /**
   * Constructor.
   */
  public function __construct($element_id, $nid, $display_mode) {
    $this
      ->setNid($nid);
    $this->elementID = $element_id;
    $this
      ->setDisplayMode($display_mode);
  }

  /**
   * Set the nid of the node to display.
   *
   * @param int $nid
   *   The nid of the node to display.
   */
  public function setNid($nid) {
    $this->nid = $nid;
  }

  /**
   * Get the nid of the node to display.
   *
   * @return int
   *   The nid of the node to display.
   */
  public function getNid() {
    return $this->nid;
  }

  /**
   * Set the display mode to use to render the node.
   *
   * @param string $display_mode
   *   The machine name of the display mode to use.
   */
  public function setDisplayMode($display_mode) {
    $this->displayMode = $display_mode;
  }

  /**
   * Get the display mode to use to render the node.
   *
   * @return string
   *   The machine name of the display mode to use.
   */
  public function getDisplayMode() {
    return $this->displayMode;
  }

  /**
   * Get the element id that is being rendered.
   *
   * @return string
   *   The id of the element being rendered.
   */
  public function getElementId() {
    return $this->elementId;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
WebformNodeElementPreRender::$displayMode protected property
WebformNodeElementPreRender::$elementID protected property
WebformNodeElementPreRender::$nid protected property
WebformNodeElementPreRender::getDisplayMode public function Get the display mode to use to render the node.
WebformNodeElementPreRender::getElementId public function Get the element id that is being rendered.
WebformNodeElementPreRender::getNid public function Get the nid of the node to display.
WebformNodeElementPreRender::PRERENDER constant
WebformNodeElementPreRender::setDisplayMode public function Set the display mode to use to render the node.
WebformNodeElementPreRender::setNid public function Set the nid of the node to display.
WebformNodeElementPreRender::__construct public function Constructor.