function gridstack_update_8101 in GridStack 8
Same name and namespace in other branches
- 8.2 gridstack.install \gridstack_update_8101()
Update config settings, and optionsets.
File
- ./
gridstack.install, line 41 - Installation actions for GridStack.
Code
function gridstack_update_8101() {
/** @var \Drupal\Core\Config\ConfigFactoryInterface $config */
$config = \Drupal::service('config.factory');
// Remove deprecated jQuery UI option as per v0.3.0.
$config
->getEditable('gridstack.settings')
->clear('jquery_ui')
->save();
// Clear the caches.
\Drupal::entityTypeManager()
->clearCachedDefinitions();
// Cleanup unused options.
$config_factory = \Drupal::configFactory();
foreach ($config_factory
->listAll('gridstack.optionset.') as $optionset_name) {
$optionset = $config_factory
->getEditable($optionset_name);
// Remove options.settings.framework for options.use_framework.
$optionset
->clear('options.settings.framework');
// Loop through each grid.
$grids = $optionset
->get('options.grids');
foreach ($grids as $key => $grid) {
// Remove unused empty nested options.
if (isset($grid['nested']) && empty($grid['nested'])) {
$optionset
->clear('options.grids.' . $key . '.nested');
}
}
$optionset
->save(TRUE);
}
// Import new optionsets.
foreach ([
'bootstrap',
'foundation',
] as $key) {
$config_path = drupal_get_path('module', 'gridstack') . '/config/install/gridstack.optionset.' . $key . '.yml';
$data = Yaml::parse($config_path);
$config_factory
->getEditable('gridstack.optionset.' . $key)
->setData($data)
->save(TRUE);
}
}