-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbusiness_rules.install
46 lines (39 loc) · 1.48 KB
/
business_rules.install
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
<?php
use Drupal\business_rules\Entity\Action;
use Drupal\Core\Field\BaseFieldDefinition;
/**
* Update the email actions to allow HTML.
*/
function business_rules_update_8101(&$sandbox) {
$actions = Action::loadMultiple();
/** @var \Drupal\business_rules\Entity\Action $action */
foreach ($actions as $key => $action) {
if ($action->getType() == 'send_email') {
$old_body = $action->getSettings('body');
if (!is_array($old_body)) {
$new_body = [
'format' => 'full_html',
'value' => $old_body,
];
$action->setSetting('body', $new_body);
$action->save();
}
}
}
}
/**
* Allows schedule to work with event variables.
* @see https://www.drupal.org/project/business_rules/issues/3040833
*/
function business_rules_update_8102() {
$fields['update_entity'] = BaseFieldDefinition::create('boolean')
->setLabel('Save entity as the last action of the task')
->setDescription('It the task will save the entity in the end of the process.');
$fields['event'] = BaseFieldDefinition::create('map')
->setLabel(t('Event.'))
->setDescription(t('The event that has created the schedule.'));
\Drupal::entityDefinitionUpdateManager()
->installFieldStorageDefinition('update_entity', 'business_rules_schedule', 'business_rules', $fields['update_entity']);
\Drupal::entityDefinitionUpdateManager()
->installFieldStorageDefinition('event', 'business_rules_schedule', 'business_rules', $fields['event']);
}