Install, update, and uninstall functions for the Filter module.
<?php
/**
* @file
* Install, update, and uninstall functions for the Filter module.
*/
use Drupal\Component\Uuid\Uuid;
/**
* @addtogroup updates-7.x-to-8.x
* @{
*/
/**
* Moves filter_fallback settings from variable to config.
*
* @ingroup config_upgrade
*/
function filter_update_8000() {
update_variables_to_config('filter.settings', array(
'filter_fallback_format' => 'fallback_format',
));
}
/**
* Migrate filter formats into configuration.
*
* @ingroup config_upgrade
*/
function filter_update_8001() {
$uuid = new Uuid();
$result = db_query('SELECT format, name, cache, status, weight FROM {filter_format}', array(), array(
'fetch' => PDO::FETCH_ASSOC,
));
foreach ($result as $format) {
$id = $format['format'];
// Generate a UUID.
$format['uuid'] = $uuid
->generate();
// Retrieve and prepare all filters.
$filters = db_query('SELECT name, module, status, weight, settings FROM {filter} WHERE format = :format ORDER BY weight, module, name', array(
':format' => $id,
), array(
'fetch' => PDO::FETCH_ASSOC,
))
->fetchAllAssoc('name');
foreach ($filters as $name => &$filter) {
// The filter name is used as key only.
unset($filter['name']);
$filter['settings'] = unserialize($filter['settings']);
}
$format['filters'] = $filters;
// Save the config object.
$config = config('filter.format.' . $id);
$config
->setData($format);
$config
->save();
}
}
/**
* @} End of "defgroup updates-7.x-to-8.x".
* The next series of updates should start at 9000.
*/
Name | Description |
---|---|
filter_update_8001 | Migrate filter formats into configuration. |
filter_update_8000 | Moves filter_fallback settings from variable to config. |