diff --git a/core/config/schema/core.data_types.schema.yml b/core/config/schema/core.data_types.schema.yml index 4f6ef0c..7273d16 100644 --- a/core/config/schema/core.data_types.schema.yml +++ b/core/config/schema/core.data_types.schema.yml @@ -291,18 +291,17 @@ block_settings: sequence: - type: string label: 'Context' - status: - type: boolean - label: 'Status' info: type: label label: 'Admin info' - view_mode: - type: string - label: 'View mode' provider: type: string label: 'Provider' + context_mapping: + type: sequence + label: 'Context assignments' + sequence: + - type: string condition.plugin: type: mapping diff --git a/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php b/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php index efb3d2f..573d8ce 100644 --- a/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php +++ b/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php @@ -44,7 +44,7 @@ public function testBlockLinks() { $block = $this->drupalPlaceBlock("aggregator_feed_block", array('label' => 'feed-' . $feed->label())); // Configure the feed that should be displayed. - $block->getPlugin()->setConfigurationValue('feed', $feed->id()); + $block->getPlugin()->setContextMapping(['feed' => 'aggregator.feed:' . $feed->id()]); $block->getPlugin()->setConfigurationValue('block_count', 2); $block->save(); diff --git a/core/modules/aggregator/src/Tests/DeleteFeedTest.php b/core/modules/aggregator/src/Tests/DeleteFeedTest.php index 6ec7c50..c4b4bab 100644 --- a/core/modules/aggregator/src/Tests/DeleteFeedTest.php +++ b/core/modules/aggregator/src/Tests/DeleteFeedTest.php @@ -30,10 +30,10 @@ function testDeleteFeed() { // Place a block for both feeds. $block = $this->drupalPlaceBlock('aggregator_feed_block'); - $block->getPlugin()->setConfigurationValue('feed', $feed1->id()); + $block->getPlugin()->setContextMapping(['feed' => 'aggregator.feed:' . $feed1->id()]); $block->save(); $block2 = $this->drupalPlaceBlock('aggregator_feed_block'); - $block2->getPlugin()->setConfigurationValue('feed', $feed2->id()); + $block2->getPlugin()->setContextMapping(['feed' => 'aggregator.feed:' . $feed2->id()]); $block2->save(); // Delete feed. diff --git a/core/modules/block/src/BlockForm.php b/core/modules/block/src/BlockForm.php index fc40684..1eb1114 100644 --- a/core/modules/block/src/BlockForm.php +++ b/core/modules/block/src/BlockForm.php @@ -313,7 +313,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $block = $entity->getPlugin(); $block->submitConfigurationForm($form, $settings); if ($block instanceof ContextAwarePluginInterface) { - $context_mapping = $settings->hasValue('context_mapping') ? $settings->getValue('context_mapping') : []; + $context_mapping = $settings->getValue('context_mapping', []); $block->setContextMapping($context_mapping); } // Update the original form values. diff --git a/core/modules/block/src/BlockRepository.php b/core/modules/block/src/BlockRepository.php index aed3223..1df8b52 100644 --- a/core/modules/block/src/BlockRepository.php +++ b/core/modules/block/src/BlockRepository.php @@ -83,7 +83,7 @@ public function getVisibleBlocksPerRegion(array $contexts) { $this->contextHandler->applyContextMapping($block_plugin, $contexts); } // Set the contexts on the block before checking access. - if ($block->setContexts($contexts)->access('view')) { + if ($block->access('view')) { $full[$block->get('region')][$block_id] = $block; } } diff --git a/core/modules/block/src/Tests/BlockInterfaceTest.php b/core/modules/block/src/Tests/BlockInterfaceTest.php index 3c7ecb0..cb17bf7 100644 --- a/core/modules/block/src/Tests/BlockInterfaceTest.php +++ b/core/modules/block/src/Tests/BlockInterfaceTest.php @@ -67,6 +67,7 @@ public function testBlockInterface() { $contexts = \Drupal::service("cache_contexts")->getLabels(); unset($contexts['cache_context.theme']); $expected_form = array( + 'context_mapping' => array(), 'provider' => array( '#type' => 'value', '#value' => 'block_test',