-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwmentity_overview.api.php
37 lines (29 loc) · 1.13 KB
/
wmentity_overview.api.php
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
<?php
use Drupal\wmentity_overview\Annotation\OverviewBuilder;
function hook_entity_overview_alter(OverviewBuilder $definition, array &$overview)
{
if (!empty($overview['form'])) {
$overview['form']['#attributes']['class'][] = 'custom-entity-overview__form';
}
$overview['table']['#attributes']['class'][] = 'custom-entity-overview__table';
}
function hook_entity_overview_alternatives_alter(array &$alternatives, OverviewBuilder $definition)
{
$routeMatch = \Drupal::routeMatch();
$overviewBuilders = \Drupal::getContainer()->get('plugin.manager.wmentity_overview_builder');
if (!$vocabulary = $routeMatch->getParameter('taxonomy_vocabulary')) {
return;
}
if ($definition->getEntityTypeId() !== 'taxonomy_term') {
return;
}
$filters = ['vid' => $vocabulary->id()];
$alternatives = array_merge(
$alternatives,
$overviewBuilders->getAlternativesByFilters($definition, $filters)
);
}
function hook_wmentity_overview_builder_info_alter(array &$definitions)
{
$definitions['node.page']['class'] = \Drupal\my_module\Entity\Overview\Node\PageOverview::class;
}