protected function FieldApiDataTest::getViewsData in Drupal 10
Same name and namespace in other branches
- 8 core/modules/views/tests/src/Kernel/FieldApiDataTest.php \Drupal\Tests\views\Kernel\FieldApiDataTest::getViewsData()
- 9 core/modules/views/tests/src/Kernel/FieldApiDataTest.php \Drupal\Tests\views\Kernel\FieldApiDataTest::getViewsData()
Gets the views data for the field created in setUp().
Parameters
string $field_storage_key: (optional) The optional field name.
Return value
array Views data.
File
- core/
modules/ views/ tests/ src/ Kernel/ FieldApiDataTest.php, line 185
Class
- FieldApiDataTest
- Tests the Field Views data.
Namespace
Drupal\Tests\views\KernelCode
protected function getViewsData($field_storage_key = 'field_string') {
$views_data = $this->container
->get('views.views_data');
$data = [];
// Check the table and the joins of the first field. Attached to node only.
/** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */
$table_mapping = $this->container
->get('entity_type.manager')
->getStorage('node')
->getTableMapping();
$field_storage = FieldStorageConfig::loadByName('node', $field_storage_key);
$current_table = $table_mapping
->getDedicatedDataTableName($field_storage);
$revision_table = $table_mapping
->getDedicatedRevisionTableName($field_storage);
$data[$current_table] = $views_data
->get($current_table);
$data[$revision_table] = $views_data
->get($revision_table);
return $data;
}