function xbbcode_update_8300 in Extensible BBCode 4.0.x
Same name and namespace in other branches
- 8.3 xbbcode.install \xbbcode_update_8300()
Add an "xss" key to the filter settings.
Throws
\Drupal\Core\Utility\UpdateException If the update fails.
File
- ./
xbbcode.install, line 16 - Update functions for the xbbcode module.
Code
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);
}
}