2 * Implements hook_views_pre_execute().
4 function {{ machine_name }}_views_pre_execute(ViewExecutable $view) {
5 // Whenever a view queries more than two tables, show a message that notifies
6 // view administrators that the query might be heavy.
7 // (This action could be performed later in the execution process, but not
9 $account = \Drupal::currentUser();
11 if (count($view->query->tables) > 2 && $account->hasPermission('administer views')) {
12 drupal_set_message(t('The view %view may be heavy to execute.', ['%view' => $view->id()]), 'warning');