diff --git a/core/modules/block/src/Controller/BlockLibraryController.php b/core/modules/block/src/Controller/BlockLibraryController.php index ebc9a7ef9e..3737e26657 100644 --- a/core/modules/block/src/Controller/BlockLibraryController.php +++ b/core/modules/block/src/Controller/BlockLibraryController.php @@ -106,10 +106,9 @@ public function listBlocks(Request $request, $theme) { // Adds to the "Add custom block" action url route parameters, to provide // correct region setting after creation. - $add_action_url = isset($build['local_actions']['block_content_add_action']['#link']['url']) - ? $build['local_actions']['block_content_add_action']['#link']['url'] - : NULL; - if ($add_action_url instanceof Url && $region) { + $add_action_url = $build['local_actions']['block_content_add_action']['#link'] + ['url'] ?? NULL; + if ($add_action_url instanceof Url) { $add_action_url->setRouteParameter('region', $region); $build['local_actions']['block_content_add_action']['#link']['url'] = $add_action_url; } diff --git a/core/modules/block_content/src/BlockContentForm.php b/core/modules/block_content/src/BlockContentForm.php index e624d42eef..397072b7d4 100644 --- a/core/modules/block_content/src/BlockContentForm.php +++ b/core/modules/block_content/src/BlockContentForm.php @@ -68,14 +68,14 @@ public function save(array $form, FormStateInterface $form_state) { if (!$theme = $block->getTheme()) { $theme = $this->config('system.theme')->get('default'); } - $route_parameters = [ - 'plugin_id' => 'block_content:' . $block->uuid(), - 'theme' => $theme, - ]; - if ($region = $this->getRequest()->query->get('region')) { - $route_parameters['region'] = $region; - } - $form_state->setRedirect('block.admin_add', $route_parameters); + $form_state->setRedirect( + 'block.admin_add', + [ + 'plugin_id' => 'block_content:' . $block->uuid(), + 'theme' => $theme, + 'region' => $this->getRequest()->query->get('region') + ] + ); } else { $form_state->setRedirectUrl($block->toUrl('collection'));