12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- /**
- * Update all blocks reaction configuration with additional "context_id" property.
- */
- function context_update_8001() {
- foreach (Drupal::service('context.manager')->getContexts() as $context) {
- foreach ($context->getReactions() as $reaction) {
- if ($reaction instanceof Drupal\context\Plugin\ContextReaction\Blocks) {
- foreach ($reaction->getBlocks() as $block) {
- $config = $block->getConfiguration();
- if (!isset($config['context_id'])) {
- $config['context_id'] = $context->id();
- $block->setConfiguration($config);
- $context->save();
- }
- }
- }
- }
- }
- }
- /**
- * Update all blocks reaction configuration with additional "css_class" property.
- */
- function context_update_8002() {
- $context_manager = \Drupal::service('context.manager');
- foreach ($context_manager->getContexts() as $context) {
- foreach ($context->getReactions() as $reaction) {
- if ($reaction instanceof \Drupal\context\Plugin\ContextReaction\Blocks) {
- foreach ($reaction->getBlocks() as $block) {
- $configuration = $block->getConfiguration();
- if (!isset($configuration['css_class'])) {
- $configuration['css_class'] = '';
- // Update the block.
- $reaction->updateBlock($configuration['uuid'], $configuration);
- $context->save();
- }
- }
- }
- }
- }
- }
|