-
Notifications
You must be signed in to change notification settings - Fork 4
/
wmmodel.module
47 lines (36 loc) · 1.13 KB
/
wmmodel.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
<?php
/**
* Implements @see hook_entity_type_alter
*/
function wmmodel_entity_type_alter(array &$entityTypes)
{
$manager = \Drupal::getContainer()->get('plugin.manager.wmmodel.model');
foreach ($manager->getDefinitions() as $definition) {
$entityTypeId = $definition['entity_type'];
if (!isset($entityTypes[$entityTypeId])) {
continue;
}
if (isset($definition['bundle'])) {
continue;
}
$entityTypes[$definition['entity_type']]->setClass($definition['class']);
}
}
/**
* Implements @see hook_entity_bundle_info_alter
*/
function wmmodel_entity_bundle_info_alter(array &$bundles): void
{
$manager = \Drupal::getContainer()->get('plugin.manager.wmmodel.model');
foreach ($manager->getDefinitions() as $definition) {
$entityTypeId = $definition['entity_type'];
if (!isset($definition['bundle'])) {
continue;
}
$bundle = $definition['bundle'];
if (!isset($bundles[$entityTypeId][$bundle])) {
continue;
}
$bundles[$entityTypeId][$bundle]['class'] = $definition['class'];
}
}