Loading core/modules/block/tests/src/Functional/BlockTest.php +11 −0 Changes for core/modules/block/tests/src/Functional/BlockTest.php: 11 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -244,6 +244,17 @@ public function testBlock() { $xpath = $this->assertSession()->buildXPathQuery('//div[@id=:id]/*', [':id' => 'block-' . str_replace('_', '-', strtolower($block['id']))]); $this->assertSession()->elementNotExists('xpath', $xpath); $pages = [ '', '<front>', '/valid-page', 'user/login', ]; // Test error when not including forward slash. $this->drupalGet('admin/structure/block/manage/' . $block['id']); $this->submitForm(['visibility[request_path][pages]' => implode("\n", $pages)], 'Save block'); $this->assertSession()->pageTextContains('The path user/login requires a leading forward slash when used with the Pages setting.'); // Test deleting the block from the edit form. $this->drupalGet('admin/structure/block/manage/' . $block['id']); $this->clickLink('Remove block'); Loading core/modules/system/src/Plugin/Condition/RequestPath.php +13 −0 Changes for core/modules/system/src/Plugin/Condition/RequestPath.php: 13 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -112,6 +112,19 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta return parent::buildConfigurationForm($form, $form_state); } /** * {@inheritdoc} */ public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { $paths = array_map('trim', explode("\n", $form_state->getValue('pages'))); foreach ($paths as $path) { if (empty($path) || $path === '<front>' || str_starts_with($path, '/')) { continue; } $form_state->setErrorByName('pages', $this->t("The path %path requires a leading forward slash when used with the Pages setting.", ['%path' => $path])); } } /** * {@inheritdoc} */ Loading Loading
core/modules/block/tests/src/Functional/BlockTest.php +11 −0 Changes for core/modules/block/tests/src/Functional/BlockTest.php: 11 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -244,6 +244,17 @@ public function testBlock() { $xpath = $this->assertSession()->buildXPathQuery('//div[@id=:id]/*', [':id' => 'block-' . str_replace('_', '-', strtolower($block['id']))]); $this->assertSession()->elementNotExists('xpath', $xpath); $pages = [ '', '<front>', '/valid-page', 'user/login', ]; // Test error when not including forward slash. $this->drupalGet('admin/structure/block/manage/' . $block['id']); $this->submitForm(['visibility[request_path][pages]' => implode("\n", $pages)], 'Save block'); $this->assertSession()->pageTextContains('The path user/login requires a leading forward slash when used with the Pages setting.'); // Test deleting the block from the edit form. $this->drupalGet('admin/structure/block/manage/' . $block['id']); $this->clickLink('Remove block'); Loading
core/modules/system/src/Plugin/Condition/RequestPath.php +13 −0 Changes for core/modules/system/src/Plugin/Condition/RequestPath.php: 13 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -112,6 +112,19 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta return parent::buildConfigurationForm($form, $form_state); } /** * {@inheritdoc} */ public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { $paths = array_map('trim', explode("\n", $form_state->getValue('pages'))); foreach ($paths as $path) { if (empty($path) || $path === '<front>' || str_starts_with($path, '/')) { continue; } $form_state->setErrorByName('pages', $this->t("The path %path requires a leading forward slash when used with the Pages setting.", ['%path' => $path])); } } /** * {@inheritdoc} */ Loading