function ViewsData::getData
Same name and namespace in other branches
- 11.x core/modules/views/src/ViewsData.php \Drupal\views\ViewsData::getData()
- 10 core/modules/views/src/ViewsData.php \Drupal\views\ViewsData::getData()
- 9 core/modules/views/src/ViewsData.php \Drupal\views\ViewsData::getData()
- 8.9.x core/modules/views/src/ViewsData.php \Drupal\views\ViewsData::getData()
Gets all data invoked by hook_views_data().
This is requested from the cache before being rebuilt.
Return value
array An array of all data.
2 calls to ViewsData::getData()
- ViewsData::get in core/
modules/ views/ src/ ViewsData.php - Gets data for a particular table.
- ViewsData::getAll in core/
modules/ views/ src/ ViewsData.php - Gets all table data.
File
-
core/
modules/ views/ src/ ViewsData.php, line 232
Class
- ViewsData
- Class to manage and lazy load cached views data.
Namespace
Drupal\viewsCode
protected function getData() {
if ($cache = $this->cacheGet($this->baseCid)) {
$data = $cache->data;
}
else {
// Set the loading flag in case this is running in a fiber and gets
// suspended before the views data is fully loaded. Other code that calls
// this method and runs in a separate fiber can check the loading flag
// and suspend its fiber once to allow the original fiber a chance to
// finish loading.
$this->loading = TRUE;
$data = [];
$this->moduleHandler
->invokeAllWith('views_data', function (callable $hook, string $module) use (&$data) {
$views_data = $hook();
// Set the provider key for each base table.
foreach ($views_data as &$table) {
if (isset($table['table']) && !isset($table['table']['provider'])) {
$table['table']['provider'] = $module;
}
}
$data = NestedArray::mergeDeep($data, $views_data);
});
$this->moduleHandler
->alter('views_data', $data);
$this->processEntityTypes($data);
// Keep a record with all data.
$this->cacheSet($this->baseCid, $data);
}
$this->fullyLoaded = TRUE;
$this->loading = FALSE;
return $data;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.