function context_update_8003 in Context 8
Same name and namespace in other branches
- 8.4 context.install \context_update_8003()
Add default "custom_id" property to all blocks reactions.
File
- ./
context.install, line 55 - Install, update and uninstall functions for the context module.
Code
function context_update_8003() {
foreach (Drupal::service('context.manager')
->getContexts() as $context) {
foreach ($context
->getReactions() as $reaction) {
if ($reaction instanceof Blocks) {
foreach ($reaction
->getBlocks() as $block) {
$config = $block
->getConfiguration();
if (!isset($config['custom_id'])) {
$config['custom_id'] = preg_replace("/\\W+/", "_", $config['id']);
$block
->setConfiguration($config);
$context
->save();
}
}
}
}
}
}