xbbcode.install in Extensible BBCode 4.0.x
Same filename and directory in other branches
Update functions for the xbbcode module.
File
xbbcode.installView source
<?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);
}
}
Functions
Name | Description |
---|---|
xbbcode_update_8300 | Add an "xss" key to the filter settings. |