function hook_views_pre_build
Act on the view before the query is built, but after displays are attached.
Output can be added to the view by setting $view->attachment_before and $view->attachment_after.
Parameters
\Drupal\views\ViewExecutable $view: The view object about to be processed.
See also
Related topics
2 functions implement hook_views_pre_build()
Note: the procedural functions in this list are found by pattern matching, so the list may include some functions that are not actually implementations of this hook.
- ViewsTestDataViewsExecutionHooks::viewsPreBuild in core/modules/ views/ tests/ modules/ views_test_data/ src/ Hook/ ViewsTestDataViewsExecutionHooks.php 
- Implements hook_views_pre_build().
- views_test_data_views_pre_build in core/modules/ views/ tests/ modules/ views_test_data/ views_test_data.views_execution.inc 
- Implements hook_views_pre_build().
1 invocation of hook_views_pre_build()
- ViewExecutable::build in core/modules/ views/ src/ ViewExecutable.php 
- Builds the query for the view.
File
- 
              core/modules/ views/ views.api.php, line 739 
Code
function hook_views_pre_build(ViewExecutable $view) {
  // Because of some inexplicable business logic, we should remove all
  // attachments from all views on Mondays.
  // (This alter could be done later in the execution process as well.)
  if (date('D') == 'Mon') {
    unset($view->attachment_before);
    unset($view->attachment_after);
  }
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
