You are here

final class ViewsQuerySubstitutionsEvent in Hook Event Dispatcher 3.x

Same name and namespace in other branches
  1. 8.2 modules/views_event_dispatcher/src/Event/Views/ViewsQuerySubstitutionsEvent.php \Drupal\views_event_dispatcher\Event\Views\ViewsQuerySubstitutionsEvent

Class ViewsQuerySubstitutionEvent.

Hierarchy

Expanded class hierarchy of ViewsQuerySubstitutionsEvent

3 files declare their use of ViewsQuerySubstitutionsEvent
ExampleViewsEventSubscribers.php in examples/ExampleViewsEventSubscribers.php
ViewEventTest.php in modules/views_event_dispatcher/tests/src/Unit/Views/ViewEventTest.php
views_event_dispatcher.module in modules/views_event_dispatcher/views_event_dispatcher.module
Views event dispatcher submodule.

File

modules/views_event_dispatcher/src/Event/Views/ViewsQuerySubstitutionsEvent.php, line 10

Namespace

Drupal\views_event_dispatcher\Event\Views
View source
final class ViewsQuerySubstitutionsEvent extends AbstractViewsEvent {

  /**
   * Views query substitutions.
   *
   * @var array
   */
  private $substitutions = [];

  /**
   * Get the query substitutions.
   *
   * @return array
   *   An associative array where each key is a string to be replaced, and the
   *   corresponding value is its replacement. The strings to replace are often
   *   surrounded with '***', as illustrated in the example implementation, to
   *   avoid collisions with other values in the query.
   */
  public function &getSubstitutions() : array {
    return $this->substitutions;
  }

  /**
   * Add a substitution.
   *
   * @param string $target
   *   String target to be replaced.
   * @param string $replacement
   *   The replacement of the given target.
   */
  public function addSubstitution(string $target, string $replacement) : void {
    $this->substitutions[$target] = $replacement;
  }

  /**
   * Get the dispatcher type.
   *
   * @return string
   *   The dispatcher type.
   */
  public function getDispatcherType() : string {
    return HookEventDispatcherInterface::VIEWS_QUERY_SUBSTITUTIONS;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AbstractViewsEvent::$view private property The view.
AbstractViewsEvent::getView public function Get the view.
AbstractViewsEvent::__construct public function AbstractViewsEvent constructor. 3
ViewsQuerySubstitutionsEvent::$substitutions private property Views query substitutions.
ViewsQuerySubstitutionsEvent::addSubstitution public function Add a substitution.
ViewsQuerySubstitutionsEvent::getDispatcherType public function Get the dispatcher type. Overrides EventInterface::getDispatcherType
ViewsQuerySubstitutionsEvent::getSubstitutions public function Get the query substitutions.