function hook_views_query_substitutions

Replace special strings in the query before it is executed.

Parameters

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

Return value

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.

Related topics

4 functions implement hook_views_query_substitutions()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

node_views_query_substitutions in drupal/core/modules/node/node.views_execution.inc
Implements hook_views_query_substitutions().
user_views_query_substitutions in drupal/core/modules/user/user.views_execution.inc
Implements hook_views_query_substitutions().
views_test_data_views_query_substitutions in drupal/core/modules/views/tests/views_test_data/views_test_data.views_execution.inc
Implements hook_views_query_substitutions().
views_views_query_substitutions in drupal/core/modules/views/views.views_execution.inc
Implements hook_views_query_substitutions().
2 invocations of hook_views_query_substitutions()
Sql::execute in drupal/core/modules/views/lib/Drupal/views/Plugin/views/query/Sql.php
Executes the query and fills the associated view object with according values.
Sql::query in drupal/core/modules/views/lib/Drupal/views/Plugin/views/query/Sql.php
Generate a query and a countquery from all of the information supplied to the object.

File

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

Code

function hook_views_query_substitutions(ViewExecutable $view) {

  // Example from views_views_query_substitutions().
  return array(
    '***CURRENT_VERSION***' => VERSION,
    '***CURRENT_TIME***' => REQUEST_TIME,
    '***CURRENT_LANGUAGE***' => language(\Drupal\Core\Language\Language::TYPE_CONTENT)->langcode,
    '***DEFAULT_LANGUAGE***' => language_default()->langcode,
  );
}