W3cubDocs

/Drupal 8

function hook_views_analyze

hook_views_analyze(Drupal\views\ViewExecutable $view)

Analyze a view to provide warnings about its configuration.

Parameters

\Drupal\views\ViewExecutable $view: The view being executed.

Return value

array Array of warning messages built by Analyzer::formatMessage to be displayed to the user following analysis of the view.

Related topics

Hooks
Define functions that alter the behavior of Drupal core.

File

core/modules/views/views.api.php, line 95
Describes hooks and plugins provided by the Views module.

Code

function hook_views_analyze(Drupal\views\ViewExecutable $view) {
  $messages = array();

  if ($view->display_handler->options['pager']['type'] == 'none') {
    $messages[] = Drupal\views\Analyzer::formatMessage(t('This view has no pager. This could cause performance issues when the view contains many items.'), 'warning');
  }

  return $messages;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!views!views.api.php/function/hook_views_analyze/8.1.x