Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
GroupContactDeriver | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
getDerivativeDefinitions | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace Drupal\crm\Plugin\Group\Relation; |
4 | |
5 | use Drupal\Component\Plugin\Derivative\DeriverBase; |
6 | use Drupal\group\Plugin\Group\Relation\GroupRelationTypeInterface; |
7 | use Drupal\crm\Entity\ContactType; |
8 | |
9 | /** |
10 | * Derives plugins based on contact type. |
11 | */ |
12 | class GroupContactDeriver extends DeriverBase { |
13 | |
14 | /** |
15 | * {@inheritdoc} |
16 | */ |
17 | public function getDerivativeDefinitions($base_plugin_definition) { |
18 | assert($base_plugin_definition instanceof GroupRelationTypeInterface); |
19 | $this->derivatives = []; |
20 | |
21 | foreach (ContactType::loadMultiple() as $name => $contact_type) { |
22 | $label = $contact_type->label(); |
23 | |
24 | $this->derivatives[$name] = clone $base_plugin_definition; |
25 | $this->derivatives[$name]->set('entity_bundle', $name); |
26 | $this->derivatives[$name]->set('label', t('Group contact (@type)', ['@type' => $label])); |
27 | $this->derivatives[$name]->set('description', t('Adds %type contact to groups both publicly and privately.', ['%type' => $label])); |
28 | } |
29 | |
30 | return $this->derivatives; |
31 | } |
32 | |
33 | } |