You are here

public function ExampleViewsEventSubscribers::queryAlter in Hook Event Dispatcher 3.x

Same name and namespace in other branches
  1. 8.2 examples/ExampleViewsEventSubscribers.php \Drupal\hook_event_dispatcher\ExampleViewsEventSubscribers::queryAlter()

Query alter event handler.

Parameters

\Drupal\views_event_dispatcher\Event\Views\ViewsQueryAlterEvent $event: The event.

File

examples/ExampleViewsEventSubscribers.php, line 62

Class

ExampleViewsEventSubscribers
Class ExampleViewsEventSubscribers.

Namespace

Drupal\hook_event_dispatcher

Code

public function queryAlter(ViewsQueryAlterEvent $event) : void {
  $query = $event
    ->getQuery();

  // Do something with the query.
  $query
    ->setLimit(10);
}