function ViewsTestDataViewsHooks::viewsData
Implements hook_views_data().
File
-
core/
modules/ views/ tests/ modules/ views_test_data/ src/ Hook/ ViewsTestDataViewsHooks.php, line 19
Class
- ViewsTestDataViewsHooks
- Hook implementations for views_test_data.
Namespace
Drupal\views_test_data\HookCode
public function viewsData() : array {
$state = \Drupal::service('state');
$state->set('views_hook_test_views_data', TRUE);
// We use a state variable to keep track of how many times this function is
// called so we can assert that calls to
// \Drupal\views\ViewsData::delete() trigger a rebuild of views data.
if (!($count = $state->get('views_test_data_views_data_count'))) {
$count = 0;
}
$count++;
$state->set('views_test_data_views_data_count', $count);
return $state->get('views_test_data_views_data', []);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.