forked from openeuropa/rdf_skos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrdf_skos.module
59 lines (50 loc) · 1.61 KB
/
rdf_skos.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/**
* @file
* The RDF Skos module.
*/
declare(strict_types = 1);
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\field\FieldStorageConfigInterface;
/**
* Implements hook_field_views_data_alter().
*
* Ensure that the Views filters based on the SKOS entity reference field type
* use the SkosConceptReferenceId filter plugin.
*/
function rdf_skos_field_views_data_alter(array &$data, FieldStorageConfigInterface $field_storage) {
if ($field_storage->getType() !== 'skos_concept_entity_reference') {
return;
}
foreach ($data as $table_name => $table_data) {
foreach ($table_data as $field_name => $field_data) {
if (isset($field_data['filter']) && $field_name != 'delta') {
$data[$table_name][$field_name]['filter']['id'] = 'skos_concept_reference_id';
}
}
}
}
/**
* Implements hook_entity_base_field_info().
*
* Provide the base field definitions of all the predicate mapping concept
* subset plugins.
*/
function rdf_skos_entity_base_field_info(EntityTypeInterface $entity_type) {
if ($entity_type->id() !== 'skos_concept') {
return [];
}
$fields = [];
/** @var \Drupal\rdf_skos\ConceptSubsetPluginManagerInterface $manager */
$manager = \Drupal::service('plugin.manager.concept_subset');
$definitions = $manager->getPredicateMappingDefinitions();
foreach ($definitions as $id => $definition) {
/** @var \Drupal\rdf_skos\Plugin\PredicateMapperInterface $plugin */
$plugin = $manager->createInstance($id);
$base_fields = $plugin->getBaseFieldDefinitions();
if ($base_fields) {
$fields += $base_fields;
}
}
return $fields;
}