admin view for taxo genres and langues, translation for taxo genres and langues, synonyms for genres

This commit is contained in:
Bachir Soussi Chiadmi
2018-04-11 16:23:58 +02:00
parent 1d3a3dd6fd
commit 07a138cfe6
81 changed files with 6114 additions and 67 deletions
@@ -0,0 +1,47 @@
<?php
/**
* @file
* Provide synonyms feature for content entities.
*/
/**
* Implements hook_entity_base_field_info().
*/
function synonyms_entity_base_field_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type) {
if ($entity_type instanceof \Drupal\Core\Entity\ContentEntityTypeInterface) {
$fields = [];
$fields['synonyms'] = \Drupal\Core\Field\BaseFieldDefinition::create('string')
->setLabel(t('Entity synonyms'))
->setDescription(t('A list of known entity synonyms.'))
->setComputed(TRUE)
->setClass('\Drupal\synonyms\Plugin\SynonymsFieldItemList');
return $fields;
}
}
/**
* Implements hook_views_data().
*/
function synonyms_views_data() {
$data = [];
foreach (\Drupal::entityTypeManager()->getDefinitions() as $entity_type) {
if ($entity_type instanceof \Drupal\Core\Entity\ContentEntityTypeInterface && $entity_type->getBaseTable() && $entity_type->getKey('id')) {
$data[$entity_type->getBaseTable()]['synonyms'] = [
'title' => t('Synonyms of @entity_type', [
'@entity_type' => $entity_type->getLowercaseLabel(),
]),
'filter' => [
'id' => 'synonyms_entity',
'real field' => $entity_type->getKey('id'),
'entity_type' => $entity_type->id(),
],
];
}
}
return $data;
}