Commit a4df58b1 authored by alexpott's avatar alexpott

Issue #2391289 by penyaskito, sidharthap, RavindraSingh, lokapujya: Blocks are...

Issue #2391289 by penyaskito, sidharthap, RavindraSingh, lokapujya: Blocks are invisible while selecting content types
parent 4210a02b
......@@ -38,7 +38,7 @@ public static function getSubscribedEvents() {
* // Set that specific node as the value of the 'node' context.
* $context = new Context(new ContextDefinition('entity:node'));
* $context->setContextValue($node);
* $event->setContext('node', $context);
* $event->setContext('node.node', $context);
* @endcode
*
* @param \Drupal\block\Event\BlockContextEvent $event
......@@ -57,12 +57,12 @@ public static function getSubscribedEvents() {
* For example:
* @code
* // During configuration, there is no specific node to pass as context.
* // However, inform the system that a context named 'node' is available,
* // and provide its definition, so that blocks can be configured to use
* // it. When the block is rendered, the value of this context will be
* // supplied by onBlockActiveContext().
* // However, inform the system that a context named 'node.node' is
* // available, and provide its definition, so that blocks can be
* // configured to use it. When the block is rendered, the value of this
* // context will be supplied by onBlockActiveContext().
* $context = new Context(new ContextDefinition('entity:node'));
* $event->setContext('node', $context);
* $event->setContext('node.node', $context);
* @endcode
*
* @param \Drupal\block\Event\BlockContextEvent $event
......
......@@ -59,7 +59,7 @@ public function onBlockActiveContext(BlockContextEvent $event) {
*/
public function onBlockAdministrativeContext(BlockContextEvent $event) {
$context = new Context(new ContextDefinition('entity:node'));
$event->setContext('node', $context);
$event->setContext('node.node', $context);
}
}
......@@ -7,6 +7,8 @@
namespace Drupal\node\Tests;
use Drupal\block\Entity\Block;
/**
* Tests node block functionality.
*
......@@ -120,18 +122,15 @@ public function testRecentNodeBlock() {
$this->assertText($node4->label(), 'Node found in block.');
// Enable the "Powered by Drupal" block only on article nodes.
$block = $this->drupalPlaceBlock('system_powered_by_block', array(
'visibility' => array(
'node_type' => array(
'context_mapping' => array(
'node' => 'node.node',
),
'bundles' => array(
'article' => 'article',
),
),
),
));
$edit = [
'id' => strtolower($this->randomMachineName()),
'region' => 'sidebar_first',
'visibility[node_type][bundles][article]' => 'article',
];
$theme = \Drupal::service('theme_handler')->getDefault();
$this->drupalPostForm("admin/structure/block/add/system_powered_by_block/$theme", $edit, t('Save block'));
$block = Block::load($edit['id']);
$visibility = $block->getVisibility();
$this->assertTrue(isset($visibility['node_type']['bundles']['article']), 'Visibility settings were saved to configuration');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment