-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentity_attributes.api.php
More file actions
35 lines (27 loc) · 880 Bytes
/
Copy pathentity_attributes.api.php
File metadata and controls
35 lines (27 loc) · 880 Bytes
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
<?php
/**
* @param $entity
* @return array
*/
function hook_entity_attributes_sets_info($entity) {
$attributeSets = [];
/** @var Drupal\Core\Entity\Entity $entity */
if ($entity->getEntityType()->id() == 'paragraph' && $entity->bundle() == 'paragraph_title') {
$attributeSets['green'] = t('Green');
$attributeSets['red'] = t('Red');
}
return $attributeSets;
}
function hook_entity_attributes_set($set, $entity) {
$attributes = [];
/** @var Drupal\Core\Entity\Entity $entity */
$entityType = $entity->getEntityType()->id();
$bundle = $entity->bundle();
if ($set == 'green' && $entityType == 'paragraph' && $bundle == 'paragraph_title') {
$attributes += ['class' => ['text-green']];
}
if ($set == 'hidden') {
$attributes += ['class' => ['element-invisible']];
}
return $attributes;
}