Loading core/modules/block_content/src/Controller/BlockContentController.php +3 −2 Original line number Diff line number Diff line Loading @@ -2,9 +2,9 @@ namespace Drupal\block_content\Controller; use Drupal\block_content\BlockContentTypeInterface; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\block_content\BlockContentTypeInterface; use Drupal\Core\Extension\ThemeHandlerInterface; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; Loading Loading @@ -88,7 +88,8 @@ public function add(Request $request) { uasort($types, [$this->blockContentTypeStorage->getEntityType()->getClass(), 'sort']); if ($types && count($types) == 1) { $type = reset($types); return $this->addForm($type, $request); $query = $request->query->all(); return $this->redirect('block_content.add_form', ['block_content_type' => $type->id()], ['query' => $query]); } if (count($types) === 0) { return [ Loading core/modules/block_content/src/Plugin/Menu/LocalAction/BlockContentAddLocalAction.php +0 −6 Original line number Diff line number Diff line Loading @@ -5,7 +5,6 @@ use Drupal\Core\Menu\LocalActionDefault; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Routing\RouteProviderInterface; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RequestStack; Loading Loading @@ -54,11 +53,6 @@ public function getOptions(RouteMatchInterface $route_match) { if ($region = $this->requestStack->getCurrentRequest()->query->getString('region')) { $options['query']['region'] = $region; } // Adds a destination on content block listing. if ($route_match->getRouteName() == 'entity.block_content.collection') { $options['query']['destination'] = Url::fromRoute('<current>')->toString(); } return $options; } Loading core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php +1 −5 Original line number Diff line number Diff line Loading @@ -155,11 +155,7 @@ public function testBlockContentFormSubmitHandlers(): void { // Create a block and place in block layout. $this->drupalGet('/admin/content/block'); $this->clickLink('Add content block'); // Verify destination URL, when clicking "Save and configure" this // destination will be ignored. $base = base_path(); $url = 'block/add?destination=' . $base . 'admin/content/block'; $this->assertSession()->addressEquals($url); $this->assertSession()->addressEquals('/block/add/basic'); $edit = []; $edit['info[0][value]'] = 'Test Block'; $edit['body[0][value]'] = $this->randomMachineName(16); Loading core/modules/block_content/tests/src/Functional/LocalActionTest.php 0 → 100644 +53 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace Drupal\Tests\block_content\Functional; /** * Tests block_content local action links. * * @group block_content */ class LocalActionTest extends BlockContentTestBase { /** * {@inheritdoc} */ protected $defaultTheme = 'stark'; /** * {@inheritdoc} */ protected function setUp(): void { parent::setUp(); $this->drupalLogin($this->adminUser); } /** * Tests the block_content_add_action link. */ public function testAddContentBlockLink(): void { // Verify that the link takes you straight to the block form if there's only // one type. $this->drupalGet('/admin/content/block'); $this->clickLink('Add content block'); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->addressEquals('/block/add/basic'); $type = $this->randomMachineName(); $this->createBlockContentType([ 'id' => $type, 'label' => $type, ]); // Verify that the link takes you to the block add page if there's more than // one type. $this->drupalGet('/admin/content/block'); $this->clickLink('Add content block'); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->addressEquals('/block/add'); } } Loading
core/modules/block_content/src/Controller/BlockContentController.php +3 −2 Original line number Diff line number Diff line Loading @@ -2,9 +2,9 @@ namespace Drupal\block_content\Controller; use Drupal\block_content\BlockContentTypeInterface; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\block_content\BlockContentTypeInterface; use Drupal\Core\Extension\ThemeHandlerInterface; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; Loading Loading @@ -88,7 +88,8 @@ public function add(Request $request) { uasort($types, [$this->blockContentTypeStorage->getEntityType()->getClass(), 'sort']); if ($types && count($types) == 1) { $type = reset($types); return $this->addForm($type, $request); $query = $request->query->all(); return $this->redirect('block_content.add_form', ['block_content_type' => $type->id()], ['query' => $query]); } if (count($types) === 0) { return [ Loading
core/modules/block_content/src/Plugin/Menu/LocalAction/BlockContentAddLocalAction.php +0 −6 Original line number Diff line number Diff line Loading @@ -5,7 +5,6 @@ use Drupal\Core\Menu\LocalActionDefault; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Routing\RouteProviderInterface; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RequestStack; Loading Loading @@ -54,11 +53,6 @@ public function getOptions(RouteMatchInterface $route_match) { if ($region = $this->requestStack->getCurrentRequest()->query->getString('region')) { $options['query']['region'] = $region; } // Adds a destination on content block listing. if ($route_match->getRouteName() == 'entity.block_content.collection') { $options['query']['destination'] = Url::fromRoute('<current>')->toString(); } return $options; } Loading
core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php +1 −5 Original line number Diff line number Diff line Loading @@ -155,11 +155,7 @@ public function testBlockContentFormSubmitHandlers(): void { // Create a block and place in block layout. $this->drupalGet('/admin/content/block'); $this->clickLink('Add content block'); // Verify destination URL, when clicking "Save and configure" this // destination will be ignored. $base = base_path(); $url = 'block/add?destination=' . $base . 'admin/content/block'; $this->assertSession()->addressEquals($url); $this->assertSession()->addressEquals('/block/add/basic'); $edit = []; $edit['info[0][value]'] = 'Test Block'; $edit['body[0][value]'] = $this->randomMachineName(16); Loading
core/modules/block_content/tests/src/Functional/LocalActionTest.php 0 → 100644 +53 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace Drupal\Tests\block_content\Functional; /** * Tests block_content local action links. * * @group block_content */ class LocalActionTest extends BlockContentTestBase { /** * {@inheritdoc} */ protected $defaultTheme = 'stark'; /** * {@inheritdoc} */ protected function setUp(): void { parent::setUp(); $this->drupalLogin($this->adminUser); } /** * Tests the block_content_add_action link. */ public function testAddContentBlockLink(): void { // Verify that the link takes you straight to the block form if there's only // one type. $this->drupalGet('/admin/content/block'); $this->clickLink('Add content block'); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->addressEquals('/block/add/basic'); $type = $this->randomMachineName(); $this->createBlockContentType([ 'id' => $type, 'label' => $type, ]); // Verify that the link takes you to the block add page if there's more than // one type. $this->drupalGet('/admin/content/block'); $this->clickLink('Add content block'); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->addressEquals('/block/add'); } }