class LingotekContentMetadataViewsData in Lingotek Translation 3.0.x
Same name and namespace in other branches
- 8.2 src/Views/LingotekContentMetadataViewsData.php \Drupal\lingotek\Views\LingotekContentMetadataViewsData
- 4.0.x src/Views/LingotekContentMetadataViewsData.php \Drupal\lingotek\Views\LingotekContentMetadataViewsData
- 3.1.x src/Views/LingotekContentMetadataViewsData.php \Drupal\lingotek\Views\LingotekContentMetadataViewsData
- 3.2.x src/Views/LingotekContentMetadataViewsData.php \Drupal\lingotek\Views\LingotekContentMetadataViewsData
- 3.3.x src/Views/LingotekContentMetadataViewsData.php \Drupal\lingotek\Views\LingotekContentMetadataViewsData
- 3.4.x src/Views/LingotekContentMetadataViewsData.php \Drupal\lingotek\Views\LingotekContentMetadataViewsData
- 3.5.x src/Views/LingotekContentMetadataViewsData.php \Drupal\lingotek\Views\LingotekContentMetadataViewsData
- 3.6.x src/Views/LingotekContentMetadataViewsData.php \Drupal\lingotek\Views\LingotekContentMetadataViewsData
- 3.7.x src/Views/LingotekContentMetadataViewsData.php \Drupal\lingotek\Views\LingotekContentMetadataViewsData
- 3.8.x src/Views/LingotekContentMetadataViewsData.php \Drupal\lingotek\Views\LingotekContentMetadataViewsData
Provides the lingotek views integration.
@internal
Hierarchy
- class \Drupal\views\EntityViewsData implements EntityHandlerInterface, EntityViewsDataInterface uses StringTranslationTrait
- class \Drupal\lingotek\Views\LingotekContentMetadataViewsData
Expanded class hierarchy of LingotekContentMetadataViewsData
File
- src/
Views/ LingotekContentMetadataViewsData.php, line 20
Namespace
Drupal\lingotek\ViewsView source
class LingotekContentMetadataViewsData extends EntityViewsData {
/**
* The lingotek configuration service.
*
* @var \Drupal\lingotek\LingotekConfigurationServiceInterface
*/
protected $lingotekConfigService;
/**
* Constructs an EntityViewsData object.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type to provide views integration for.
* @param \Drupal\Core\Entity\Sql\SqlEntityStorageInterface $storage_controller
* The storage handler used for this entity type.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity manager.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
* @param \Drupal\Core\StringTranslation\TranslationInterface $translation_manager
* The translation manager.
* @param \Drupal\lingotek\LingotekConfigurationServiceInterface $lingotek_configuration
* The lingotek configuration service.
*/
public function __construct(EntityTypeInterface $entity_type, SqlEntityStorageInterface $storage_controller, EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, TranslationInterface $translation_manager, LingotekConfigurationServiceInterface $lingotek_configuration, EntityFieldManagerInterface $entity_field_manager = NULL) {
parent::__construct($entity_type, $storage_controller, $entity_type_manager, $module_handler, $translation_manager, $entity_field_manager);
$this->lingotekConfigService = $lingotek_configuration;
}
/**
* {@inheritdoc}
*/
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static($entity_type, $container
->get('entity_type.manager')
->getStorage($entity_type
->id()), $container
->get('entity_type.manager'), $container
->get('module_handler'), $container
->get('string_translation'), $container
->get('lingotek.configuration'), $container
->get('entity_field.manager'));
}
/**
* Returns the views data.
*
* @return array
* The views data.
*/
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityViewsData:: |
protected | property | The entity field manager. | |
EntityViewsData:: |
protected | property | Entity type for this views data handler instance. | |
EntityViewsData:: |
protected | property | The entity type manager. | |
EntityViewsData:: |
protected | property | The field storage definitions for all base fields of the entity type. | |
EntityViewsData:: |
protected | property | The module handler. | |
EntityViewsData:: |
protected | property | The storage used for this entity type. | |
EntityViewsData:: |
protected | property | The translation manager. | |
EntityViewsData:: |
protected | function | Sets the entity links in case corresponding link templates exist. | |
EntityViewsData:: |
protected | function | Gets the field storage definitions. | |
EntityViewsData:: |
public | function |
Gets the table of an entity type to be used as base table in views. Overrides EntityViewsDataInterface:: |
|
EntityViewsData:: |
protected | function | Puts the views data for a single field onto the views data. | |
EntityViewsData:: |
protected | function | Provides the views data for a given data type and schema field. | |
EntityViewsData:: |
protected | function | Processes the views data for an entity reference field. | |
EntityViewsData:: |
protected | function | Processes the views data for a language field. | |
EntityViewsData:: |
protected | function | Processes the views data for a text field with formatting. | |
EntityViewsData:: |
protected | function | Processes the views data for a UUID field. | |
LingotekContentMetadataViewsData:: |
protected | property | The lingotek configuration service. | |
LingotekContentMetadataViewsData:: |
public static | function |
Instantiates a new instance of this entity handler. Overrides EntityViewsData:: |
|
LingotekContentMetadataViewsData:: |
public | function |
Returns the views data. Overrides EntityViewsData:: |
|
LingotekContentMetadataViewsData:: |
public | function |
Constructs an EntityViewsData object. Overrides EntityViewsData:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 4 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |