lingotek_visitable_metadata.module in Lingotek Translation 3.3.x
Same filename and directory in other branches
- 8.2 tests/modules/lingotek_visitable_metadata/lingotek_visitable_metadata.module
- 4.0.x tests/modules/lingotek_visitable_metadata/lingotek_visitable_metadata.module
- 3.0.x tests/modules/lingotek_visitable_metadata/lingotek_visitable_metadata.module
- 3.1.x tests/modules/lingotek_visitable_metadata/lingotek_visitable_metadata.module
- 3.2.x tests/modules/lingotek_visitable_metadata/lingotek_visitable_metadata.module
- 3.4.x tests/modules/lingotek_visitable_metadata/lingotek_visitable_metadata.module
- 3.5.x tests/modules/lingotek_visitable_metadata/lingotek_visitable_metadata.module
- 3.6.x tests/modules/lingotek_visitable_metadata/lingotek_visitable_metadata.module
- 3.7.x tests/modules/lingotek_visitable_metadata/lingotek_visitable_metadata.module
- 3.8.x tests/modules/lingotek_visitable_metadata/lingotek_visitable_metadata.module
Alters the LingotekContentMetadata entity for making it visitable.
File
tests/modules/lingotek_visitable_metadata/lingotek_visitable_metadata.moduleView source
<?php
/**
* @file
* Alters the LingotekContentMetadata entity for making it visitable.
*/
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider;
/**
* Implements hook_entity_type_alter().
*
* @param \Drupal\Core\Entity\EntityTypeInterface[] $entity_types
*/
function lingotek_visitable_metadata_entity_type_alter(array &$entity_types) {
$metadata_entity = $entity_types['lingotek_content_metadata'];
$metadata_entity
->set('admin_permission', 'manage lingotek translations');
$metadata_entity
->setLinkTemplate('canonical', '/metadata/{lingotek_content_metadata}');
$metadata_entity
->setHandlerClass('route_provider', [
'html' => DefaultHtmlRouteProvider::class,
]);
}
/**
* Implements hook_entity_base_field_info_alter().
*
* @param \Drupal\Core\Field\FieldDefinitionInterface[] $fields
* The array of base field definitions for the entity type.
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type definition.
*/
function lingotek_visitable_metadata_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity_type) {
if ($entity_type
->id() == 'lingotek_content_metadata' && !empty($fields['translation_source'])) {
$fields['translation_source']
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'lingotek_source_status',
'weight' => -5,
]);
}
if ($entity_type
->id() == 'lingotek_content_metadata' && !empty($fields['translation_status'])) {
$fields['translation_status']
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'lingotek_translation_status',
'weight' => -5,
]);
}
}
Functions
Name | Description |
---|---|
lingotek_visitable_metadata_entity_base_field_info_alter | Implements hook_entity_base_field_info_alter(). |
lingotek_visitable_metadata_entity_type_alter | Implements hook_entity_type_alter(). |