Loading core/modules/node/src/Plugin/views/argument_default/Node.php +3 −1 Original line number Diff line number Diff line Loading @@ -60,7 +60,9 @@ public static function create(ContainerInterface $container, array $configuratio * {@inheritdoc} */ public function getArgument() { if (($node = $this->routeMatch->getParameter('node')) && $node instanceof NodeInterface) { // Get the node object from current route. $node = $this->routeMatch->getParameter('node') ?? $this->routeMatch->getParameter('node_preview'); if ($node instanceof NodeInterface) { return $node->id(); } } Loading core/modules/views/tests/src/Functional/Plugin/ArgumentDefaultTest.php +6 −0 Original line number Diff line number Diff line Loading @@ -168,6 +168,12 @@ public function testArgumentDefaultNode() { $this->assertSession()->elementTextContains('xpath', '//*[@id="block-' . $id . '"]', $node1->getTitle()); $this->drupalGet('node/' . $node2->id()); $this->assertSession()->elementTextContains('xpath', '//*[@id="block-' . $id . '"]', $node2->getTitle()); // Check the view from node preview page. $node3 = $this->drupalCreateNode(['title' => 'Title 1', 'type' => 'page']); $this->drupalGet($node3->toUrl('edit-form')); $this->submitForm(['title[0][value]' => 'Title 2'], 'Preview'); $this->assertSession()->elementTextContains('xpath', '//*[@id="block-' . $id . '"]', $node3->getTitle()); } /** Loading Loading
core/modules/node/src/Plugin/views/argument_default/Node.php +3 −1 Original line number Diff line number Diff line Loading @@ -60,7 +60,9 @@ public static function create(ContainerInterface $container, array $configuratio * {@inheritdoc} */ public function getArgument() { if (($node = $this->routeMatch->getParameter('node')) && $node instanceof NodeInterface) { // Get the node object from current route. $node = $this->routeMatch->getParameter('node') ?? $this->routeMatch->getParameter('node_preview'); if ($node instanceof NodeInterface) { return $node->id(); } } Loading
core/modules/views/tests/src/Functional/Plugin/ArgumentDefaultTest.php +6 −0 Original line number Diff line number Diff line Loading @@ -168,6 +168,12 @@ public function testArgumentDefaultNode() { $this->assertSession()->elementTextContains('xpath', '//*[@id="block-' . $id . '"]', $node1->getTitle()); $this->drupalGet('node/' . $node2->id()); $this->assertSession()->elementTextContains('xpath', '//*[@id="block-' . $id . '"]', $node2->getTitle()); // Check the view from node preview page. $node3 = $this->drupalCreateNode(['title' => 'Title 1', 'type' => 'page']); $this->drupalGet($node3->toUrl('edit-form')); $this->submitForm(['title[0][value]' => 'Title 2'], 'Preview'); $this->assertSession()->elementTextContains('xpath', '//*[@id="block-' . $id . '"]', $node3->getTitle()); } /** Loading