diff --git a/core/modules/settings_tray/settings_tray.links.contextual.yml b/core/modules/settings_tray/settings_tray.links.contextual.yml index 5534ab2..c62fa98 100644 --- a/core/modules/settings_tray/settings_tray.links.contextual.yml +++ b/core/modules/settings_tray/settings_tray.links.contextual.yml @@ -1,6 +1,6 @@ settings_tray.block_configure: title: 'Quick edit' - route_name: 'entity.block.off_canvas_form' + route_name: 'entity.block.settings_tray_form' group: 'block' options: attributes: diff --git a/core/modules/settings_tray/settings_tray.module b/core/modules/settings_tray/settings_tray.module index 48b08ca..54f2b0a 100644 --- a/core/modules/settings_tray/settings_tray.module +++ b/core/modules/settings_tray/settings_tray.module @@ -8,7 +8,7 @@ use Drupal\Core\Asset\AttachedAssetsInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Url; -use Drupal\settings_tray\Block\BlockEntityOffCanvasForm; +use Drupal\settings_tray\Block\BlockEntitySettingTrayForm; use Drupal\settings_tray\Form\SystemBrandingOffCanvasForm; use Drupal\settings_tray\Form\SystemMenuOffCanvasForm; @@ -72,8 +72,8 @@ function settings_tray_block_view_alter(array &$build) { function settings_tray_entity_type_build(array &$entity_types) { /* @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ $entity_types['block'] - ->setFormClass('off_canvas', BlockEntityOffCanvasForm::class) - ->setLinkTemplate('off_canvas-form', '/admin/structure/block/manage/{block}/off-canvas'); + ->setFormClass('settings_tray', BlockEntitySettingTrayForm::class) + ->setLinkTemplate('settings_tray-form', '/admin/structure/block/manage/{block}/settings-tray'); } /** diff --git a/core/modules/settings_tray/settings_tray.routing.yml b/core/modules/settings_tray/settings_tray.routing.yml index 01109e4..fd340e5 100644 --- a/core/modules/settings_tray/settings_tray.routing.yml +++ b/core/modules/settings_tray/settings_tray.routing.yml @@ -1,8 +1,15 @@ -entity.block.off_canvas_form: - path: '/admin/structure/block/manage/{block}/off-canvas' +entity.block.settings_tray_form: + path: '/admin/structure/block/manage/{block}/settings-tray' defaults: - _entity_form: 'block.off_canvas' - _title_callback: '\Drupal\settings_tray\Block\BlockEntityOffCanvasForm::title' + _entity_form: 'block.settings_tray' + _title_callback: '\Drupal\settings_tray\Block\BlockEntitySettingTrayForm::title' requirements: _permission: 'administer blocks' _access_block_plugin_has_settings_tray_form: 'TRUE' + +# Deprecated. +# @see entity.block.settings_tray_form +# @see \Drupal\settings_tray\RouteProcessor\BlockEntityOffCanvasFormRouteProcessorBC +# @todo Remove in Drupal 9.0.0. +entity.block.off_canvas_form: + path: '' diff --git a/core/modules/settings_tray/settings_tray.services.yml b/core/modules/settings_tray/settings_tray.services.yml index a11a1d4..0457101 100644 --- a/core/modules/settings_tray/settings_tray.services.yml +++ b/core/modules/settings_tray/settings_tray.services.yml @@ -3,3 +3,12 @@ services: class: Drupal\settings_tray\Access\BlockPluginHasSettingsTrayFormAccessCheck tags: - { name: access_check, applies_to: _access_block_plugin_has_settings_tray_form } + + # BC layers. + # @todo Remove in Drupal 9.0.0. + settings_tray.route_processor_off_canvas_form_bc: + class: \Drupal\settings_tray\RouteProcessor\BlockEntityOffCanvasFormRouteProcessorBC + arguments: ['@router.route_provider'] + public: false + tags: + - { name: route_processor_outbound } diff --git a/core/modules/settings_tray/src/Block/BlockEntityOffCanvasForm.php b/core/modules/settings_tray/src/Block/BlockEntitySettingTrayForm.php similarity index 99% rename from core/modules/settings_tray/src/Block/BlockEntityOffCanvasForm.php rename to core/modules/settings_tray/src/Block/BlockEntitySettingTrayForm.php index 2c6f80d..fd44b0c 100644 --- a/core/modules/settings_tray/src/Block/BlockEntityOffCanvasForm.php +++ b/core/modules/settings_tray/src/Block/BlockEntitySettingTrayForm.php @@ -21,7 +21,7 @@ * * @internal */ -class BlockEntityOffCanvasForm extends BlockForm { +class BlockEntitySettingTrayForm extends BlockForm { /** * Provides a title callback to get the block's admin label. diff --git a/core/modules/settings_tray/src/RouteProcessor/BlockEntityOffCanvasFormRouteProcessorBC.php b/core/modules/settings_tray/src/RouteProcessor/BlockEntityOffCanvasFormRouteProcessorBC.php new file mode 100644 index 0000000..48935ae --- /dev/null +++ b/core/modules/settings_tray/src/RouteProcessor/BlockEntityOffCanvasFormRouteProcessorBC.php @@ -0,0 +1,65 @@ +routeProvider = $route_provider; + } + + /** + * {@inheritdoc} + */ + public function processOutbound($route_name, Route $route, array &$parameters, BubbleableMetadata $bubbleable_metadata = NULL) { + if ($route_name === 'entity.block.off_canvas_form') { + $redirected_route_name = 'entity.block.settings_tray_form'; + @trigger_error(sprintf("The '%s' route is deprecated since version 8.5.x and will be removed in 9.0.0. Use the '%s' route instead.", $route_name, $redirected_route_name), E_USER_DEPRECATED); + static::overwriteRoute($route, $this->routeProvider->getRouteByName($redirected_route_name)); + } + } + + /** + * Overwrites one route's metadata with the other's. + * + * @param \Symfony\Component\Routing\Route $target_route + * The route whose metadata to overwrite. + * @param \Symfony\Component\Routing\Route $source_route + * The route whose metadata to read from. + * + * @see \Symfony\Component\Routing\Route + */ + protected static function overwriteRoute(Route $target_route, Route $source_route) { + $target_route->setPath($source_route->getPath()); + $target_route->setDefaults($source_route->getDefaults()); + $target_route->setRequirements($source_route->getRequirements()); + $target_route->setOptions($source_route->getOptions()); + $target_route->setHost($source_route->getHost()); + $target_route->setSchemes($source_route->getSchemes()); + $target_route->setMethods($source_route->getMethods()); + } + +} diff --git a/core/modules/settings_tray/tests/src/Functional/BcRoutesTest.php b/core/modules/settings_tray/tests/src/Functional/BcRoutesTest.php new file mode 100644 index 0000000..6750b1c --- /dev/null +++ b/core/modules/settings_tray/tests/src/Functional/BcRoutesTest.php @@ -0,0 +1,33 @@ +placeBlock('system_powered_by_block'); + $url_for_current_route = Url::fromRoute('entity.block.settings_tray_form', ['block' => $block->id()])->toString(TRUE)->getGeneratedUrl(); + $url_for_bc_route = Url::fromRoute('entity.block.off_canvas_form', ['block' => $block->id()])->toString(TRUE)->getGeneratedUrl(); + $this->assertSame($url_for_current_route, $url_for_bc_route); + } + +} diff --git a/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php index fcfecde..0e281eb 100644 --- a/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php +++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php @@ -81,7 +81,7 @@ public function testBlocks($theme, $block_plugin, $new_page_text, $element_selec $link = $page->find('css', "$block_selector .contextual-links li a"); $this->assertEquals('Quick edit', $link->getText(), "'Quick edit' is the first contextual link for the block."); - $this->assertContains("/admin/structure/block/manage/$block_id/off-canvas?destination=user/2", $link->getAttribute('href')); + $this->assertContains("/admin/structure/block/manage/$block_id/settings-tray?destination=user/2", $link->getAttribute('href')); if (isset($toolbar_item)) { // Check that you can open a toolbar tray and it will be closed after @@ -518,7 +518,7 @@ public function testCustomBlockLinks() { $href = array_search('Quick edit', $link_labels); $this->assertEquals('', $href); $href = array_search('Quick edit settings', $link_labels); - $this->assertTrue(strstr($href, '/admin/structure/block/manage/custom/off-canvas?destination=user/2') !== FALSE); + $this->assertTrue(strstr($href, '/admin/structure/block/manage/custom/settings-tray?destination=user/2') !== FALSE); } /**