public function LingotekContentMetadataViewsData::getViewsData in Lingotek Translation 4.0.x
Same name and namespace in other branches
- 8.2 src/Views/LingotekContentMetadataViewsData.php \Drupal\lingotek\Views\LingotekContentMetadataViewsData::getViewsData()
- 3.0.x src/Views/LingotekContentMetadataViewsData.php \Drupal\lingotek\Views\LingotekContentMetadataViewsData::getViewsData()
- 3.1.x src/Views/LingotekContentMetadataViewsData.php \Drupal\lingotek\Views\LingotekContentMetadataViewsData::getViewsData()
- 3.2.x src/Views/LingotekContentMetadataViewsData.php \Drupal\lingotek\Views\LingotekContentMetadataViewsData::getViewsData()
- 3.3.x src/Views/LingotekContentMetadataViewsData.php \Drupal\lingotek\Views\LingotekContentMetadataViewsData::getViewsData()
- 3.4.x src/Views/LingotekContentMetadataViewsData.php \Drupal\lingotek\Views\LingotekContentMetadataViewsData::getViewsData()
- 3.5.x src/Views/LingotekContentMetadataViewsData.php \Drupal\lingotek\Views\LingotekContentMetadataViewsData::getViewsData()
- 3.6.x src/Views/LingotekContentMetadataViewsData.php \Drupal\lingotek\Views\LingotekContentMetadataViewsData::getViewsData()
- 3.7.x src/Views/LingotekContentMetadataViewsData.php \Drupal\lingotek\Views\LingotekContentMetadataViewsData::getViewsData()
- 3.8.x src/Views/LingotekContentMetadataViewsData.php \Drupal\lingotek\Views\LingotekContentMetadataViewsData::getViewsData()
Returns the views data.
Return value
array The views data.
Overrides EntityViewsData::getViewsData
File
- src/
Views/ LingotekContentMetadataViewsData.php, line 71
Class
- LingotekContentMetadataViewsData
- Provides the lingotek views integration.
Namespace
Drupal\lingotek\ViewsCode
public function getViewsData() {
$data = parent::getViewsData();
$data['lingotek_metadata']['translation_source'] = [
'title' => $this
->t('Lingotek translation source'),
'description' => $this
->t('The source language from which this translation was created.'),
'field' => [
'id' => 'field',
'default_formatter' => 'lingotek_translation_status',
'field_name' => 'translation_source',
],
];
$enabled_entity_types = array_filter($this->entityTypeManager
->getDefinitions(), function (EntityTypeInterface $type) {
return $this->lingotekConfigService
->isEnabled($type
->id());
});
// Provides a relationship from the entity to its lingotek status metadata
// entity.
$lingotek_state_entity_type = $this->entityTypeManager
->getDefinition('lingotek_content_metadata');
$lingotek_state_entity_base_table = $lingotek_state_entity_type
->getDataTable() ?: $lingotek_state_entity_type
->getBaseTable();
foreach ($enabled_entity_types as $entity_type_id => $entity_type) {
$table = $entity_type
->getDataTable() ?: $entity_type
->getBaseTable();
$data[$table]['lingotek_translation_status'] = [
'title' => t('Lingotek translation status'),
'relationship' => [
'id' => 'standard',
'label' => $this
->t('@label Lingotek translation status', [
'@label' => $entity_type
->getLabel(),
]),
'base' => $lingotek_state_entity_base_table,
'base field' => 'content_entity_id',
'relationship field' => $entity_type
->getKey('id'),
'extra' => [
[
'field' => 'content_entity_type_id',
'value' => $entity_type_id,
],
],
],
'field' => [
'id' => 'field',
'default_formatter' => 'lingotek_translation_status',
'field_name' => 'lingotek_translation_status',
],
'filter' => [
'id' => 'lingotek_translation_status',
'allow empty' => TRUE,
],
];
}
return $data;
}