Skip to content
Snippets Groups Projects
Commit 0e35c129 authored by Jess's avatar Jess Committed by Tim Plunkett
Browse files

Issue #1808756 by xjm: Update docs for a couple alter hooks.

parent 4c379097
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -504,20 +504,17 @@ function hook_views_post_render(ViewExecutable &$view, &$output, CacheBackendInt ...@@ -504,20 +504,17 @@ function hook_views_post_render(ViewExecutable &$view, &$output, CacheBackendInt
} }
/** /**
* Alter the query before executing the query. * Alter the query before it is executed.
* *
* This hook should be placed in MODULENAME.views.inc and it will be * @param Drupal\views\ViewExecutable $view
* auto-loaded. MODULENAME.views.inc must be in the directory specified by the
* 'path' key returned by MODULENAME_views_api(), or the same directory as the
* .module file, if 'path' is unspecified.
*
* @param $view
* The view object about to be processed. * The view object about to be processed.
* @param $query * @param QueryPluginBase $query
* An object describing the query. * The query plugin object for the query.
*
* @see hook_views_query_substitutions() * @see hook_views_query_substitutions()
* @see Drupal\views\Plugin\views\query\Sql
*/ */
function hook_views_query_alter(&$view, &$query) { function hook_views_query_alter(ViewExecutable &$view, QueryPluginBase &$query) {
// (Example assuming a view with an exposed filter on node title.) // (Example assuming a view with an exposed filter on node title.)
// If the input for the title filter is a positive integer, filter against // If the input for the title filter is a positive integer, filter against
// node ID instead of node title. // node ID instead of node title.
...@@ -543,25 +540,19 @@ function hook_views_query_alter(&$view, &$query) { ...@@ -543,25 +540,19 @@ function hook_views_query_alter(&$view, &$query) {
* Alter the information box that (optionally) appears with a view preview, * Alter the information box that (optionally) appears with a view preview,
* including query and performance statistics. * including query and performance statistics.
* *
* This hook should be placed in MODULENAME.views.inc and it will be * @param array $rows
* auto-loaded. MODULENAME.views.inc must be in the directory specified by the
* 'path' key returned by MODULENAME_views_api(), or the same directory as the
* .module file, if 'path' is unspecified.
*
* Warning: $view is not a reference in PHP4 and cannot be modified here. But it
* IS a reference in PHP5, and can be modified. Please be careful with it.
*
* @param $rows
* An associative array with two keys: * An associative array with two keys:
* - query: An array of rows suitable for theme('table'), containing * - query: An array of rows suitable for theme('table'), containing
* information about the query and the display title and path. * information about the query and the display title and path.
* - statistics: An array of rows suitable for theme('table'), containing * - statistics: An array of rows suitable for theme('table'), containing
* performance statistics. * performance statistics.
* @param $view * @param Drupal\views\ViewExecutable $view
* The view object. * The view object.
*
* @see Drupal\views_ui\ViewUI
* @see theme_table() * @see theme_table()
*/ */
function hook_views_preview_info_alter(&$rows, $view) { function hook_views_preview_info_alter(array &$rows, ViewExecutable $view) {
// Adds information about the tables being queried by the view to the query // Adds information about the tables being queried by the view to the query
// part of the info box. // part of the info box.
$rows['query'][] = array( $rows['query'][] = array(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment