-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathxbbcode.install
35 lines (31 loc) · 952 Bytes
/
xbbcode.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
<?php
/**
* @file
* Update functions for the xbbcode module.
*/
use Drupal\Core\Utility\UpdateException;
/**
* Add an "xss" key to the filter settings.
*
* @throws \Drupal\Core\Utility\UpdateException
* If the update fails.
*/
function xbbcode_update_8300() {
try {
$storage = Drupal::entityTypeManager()->getStorage('filter_format');
/** @var \Drupal\filter\FilterFormatInterface[] $formats */
$formats = $storage->loadByProperties(['status' => TRUE]);
foreach ($formats as $format) {
$filters = $format->filters();
if ($filters->has('xbbcode')) {
$config = $filters->get('xbbcode')->getConfiguration();
$config['settings']['xss'] = $config['settings']['xss'] ?? TRUE;
$filters->get('xbbcode')->setConfiguration($config);
$format->save();
}
}
}
catch (Exception $exception) {
throw new UpdateException('Error while updating XBBCode.', 0, $exception);
}
}