class ViewsTestDataViewsExecutionHooks
Hook implementations for views_test_data.
Hierarchy
- class \Drupal\views_test_data\Hook\ViewsTestDataViewsExecutionHooks
Expanded class hierarchy of ViewsTestDataViewsExecutionHooks
File
-
core/
modules/ views/ tests/ modules/ views_test_data/ src/ Hook/ ViewsTestDataViewsExecutionHooks.php, line 15
Namespace
Drupal\views_test_data\HookView source
class ViewsTestDataViewsExecutionHooks {
/**
* Implements hook_views_query_substitutions().
*/
public function viewsQuerySubstitutions(ViewExecutable $view) {
\Drupal::state()->set('views_hook_test_views_query_substitutions', TRUE);
}
/**
* Implements hook_views_form_substitutions().
*/
public function viewsFormSubstitutions() {
\Drupal::state()->set('views_hook_test_views_form_substitutions', TRUE);
$render = [
'#markup' => '<em>unescaped</em>',
];
return [
'<!--will-be-escaped-->' => '<em>escaped</em>',
'<!--will-be-not-escaped-->' => \Drupal::service('renderer')->renderInIsolation($render),
];
}
/**
* Implements hook_field_views_data().
*/
public function fieldViewsData(FieldStorageConfigInterface $field_storage) : array {
\Drupal::state()->set('views_hook_test_field_views_data', TRUE);
return [];
}
/**
* Implements hook_field_views_data_alter().
*/
public function fieldViewsDataAlter(&$data, FieldStorageConfigInterface $field_storage, $module) : void {
\Drupal::state()->set('views_hook_test_field_views_data_alter', TRUE);
}
/**
* Implements hook_views_pre_render().
*
* @see \Drupal\views\Tests\Plugin\CacheTest
* @see \Drupal\views\Tests\Plugin\RenderTest
*/
public function viewsPreRender(ViewExecutable $view) {
\Drupal::state()->set('views_hook_test_views_pre_render', TRUE);
if (isset($view) && $view->storage
->id() == 'test_cache_header_storage') {
$view->element['#attached']['library'][] = 'views_test_data/test';
$view->element['#attached']['drupalSettings']['foo'] = 'bar';
$view->element['#attached']['placeholders']['non-existing-placeholder-just-for-testing-purposes']['#lazy_builder'] = [
'Drupal\\views_test_data\\Controller\\ViewsTestDataController::placeholderLazyBuilder',
[
'bar',
],
];
$view->element['#cache']['tags'][] = 'views_test_data:1';
$view->build_info['pre_render_called'] = TRUE;
}
}
/**
* Implements hook_views_post_render().
*/
public function viewsPostRender(ViewExecutable $view, &$output, CachePluginBase $cache) {
\Drupal::state()->set('views_hook_test_views_post_render', TRUE);
if ($view->storage
->id() === 'test_page_display' && $view->current_display === 'empty_row') {
for ($i = 0; $i < 5; $i++) {
$output['#rows'][0]['#rows'][] = [];
}
}
}
/**
* Implements hook_views_pre_build().
*/
public function viewsPreBuild(ViewExecutable $view) {
\Drupal::state()->set('views_hook_test_views_pre_build', TRUE);
}
/**
* Implements hook_views_post_build().
*/
public function viewsPostBuild(ViewExecutable $view) {
\Drupal::state()->set('views_hook_test_views_post_build', TRUE);
if (isset($view) && $view->storage
->id() == 'test_page_display') {
if ($view->current_display == 'page_1') {
$view->build_info['denied'] = TRUE;
}
elseif ($view->current_display == 'page_2') {
$view->build_info['fail'] = TRUE;
}
}
}
/**
* Implements hook_views_pre_view().
*/
public function viewsPreView(ViewExecutable $view) {
\Drupal::state()->set('views_hook_test_views_pre_view', TRUE);
}
/**
* Implements hook_views_pre_execute().
*/
public function viewsPreExecute(ViewExecutable $view) {
\Drupal::state()->set('views_hook_test_views_pre_execute', TRUE);
}
/**
* Implements hook_views_post_execute().
*/
public function viewsPostExecute(ViewExecutable $view) {
\Drupal::state()->set('views_hook_test_views_post_execute', TRUE);
}
/**
* Implements hook_views_query_alter().
*/
public function viewsQueryAlter(ViewExecutable $view) : void {
\Drupal::state()->set('views_hook_test_views_query_alter', TRUE);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
ViewsTestDataViewsExecutionHooks::fieldViewsData | public | function | Implements hook_field_views_data(). |
ViewsTestDataViewsExecutionHooks::fieldViewsDataAlter | public | function | Implements hook_field_views_data_alter(). |
ViewsTestDataViewsExecutionHooks::viewsFormSubstitutions | public | function | Implements hook_views_form_substitutions(). |
ViewsTestDataViewsExecutionHooks::viewsPostBuild | public | function | Implements hook_views_post_build(). |
ViewsTestDataViewsExecutionHooks::viewsPostExecute | public | function | Implements hook_views_post_execute(). |
ViewsTestDataViewsExecutionHooks::viewsPostRender | public | function | Implements hook_views_post_render(). |
ViewsTestDataViewsExecutionHooks::viewsPreBuild | public | function | Implements hook_views_pre_build(). |
ViewsTestDataViewsExecutionHooks::viewsPreExecute | public | function | Implements hook_views_pre_execute(). |
ViewsTestDataViewsExecutionHooks::viewsPreRender | public | function | Implements hook_views_pre_render(). |
ViewsTestDataViewsExecutionHooks::viewsPreView | public | function | Implements hook_views_pre_view(). |
ViewsTestDataViewsExecutionHooks::viewsQueryAlter | public | function | Implements hook_views_query_alter(). |
ViewsTestDataViewsExecutionHooks::viewsQuerySubstitutions | public | function | Implements hook_views_query_substitutions(). |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.