diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index c76dc40..24a0ebf 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -164,8 +164,9 @@ public function urlInfo($rel = 'canonical', array $options = []) { $link_templates = $this->linkTemplates(); if (isset($link_templates[$rel])) { - // If there is a template for the given relationship type, generate the path. - $uri = new Url($link_templates[$rel], $this->urlRouteParameters($rel)); + $route_parameters = $this->urlRouteParameters($rel); + $route_name = "entity.{$this->entityTypeId}." . str_replace(array('-', 'drupal:'), array('_', ''), $rel); + $uri = new Url($route_name, $route_parameters); } else { $bundle = $this->bundle(); @@ -224,7 +225,7 @@ public function hasLinkTemplate($rel) { * Returns an array link templates. * * @return array - * An array of link templates containing route names. + * An array of link templates containing paths. */ protected function linkTemplates() { return $this->getEntityType()->getLinkTemplates(); diff --git a/core/lib/Drupal/Core/Entity/EntityInterface.php b/core/lib/Drupal/Core/Entity/EntityInterface.php index d8e8e3e..fb1d932 100644 --- a/core/lib/Drupal/Core/Entity/EntityInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityInterface.php @@ -105,9 +105,9 @@ public function label(); * example: * @code * links = { - * "canonical" = "entity.node.canonical", - * "edit-form" = "entity.node.edit_form", - * "version-history" = "entity.node.version_history" + * "canonical" = "/node/{node}", + * "edit-form" = "/node/{node}/edit", + * "version-history" = "/node/{node}/revisions" * } * @endcode * or specified in a callback function set like: diff --git a/core/lib/Drupal/Core/Entity/EntityType.php b/core/lib/Drupal/Core/Entity/EntityType.php index 9c99d0a..b23cd9d 100644 --- a/core/lib/Drupal/Core/Entity/EntityType.php +++ b/core/lib/Drupal/Core/Entity/EntityType.php @@ -546,8 +546,12 @@ public function hasLinkTemplate($key) { /** * {@inheritdoc} */ - public function setLinkTemplate($key, $route_name) { - $this->links[$key] = $route_name; + public function setLinkTemplate($key, $path) { + if ($path[0] !== '/') { + throw new \InvalidArgumentException('Link templates accepts paths, which have to start with a leading slash.'); + } + + $this->links[$key] = $path; return $this; } diff --git a/core/lib/Drupal/Core/Entity/EntityTypeInterface.php b/core/lib/Drupal/Core/Entity/EntityTypeInterface.php index 7a87db9..8104828 100644 --- a/core/lib/Drupal/Core/Entity/EntityTypeInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityTypeInterface.php @@ -455,7 +455,7 @@ public function getLinkTemplates(); * The link type. * * @return string|bool - * The route name for this link, or FALSE if it doesn't exist. + * The path for this link, or FALSE if it doesn't exist. */ public function getLinkTemplate($key); @@ -475,12 +475,12 @@ public function hasLinkTemplate($key); * * @param string $key * The name of a link. - * @param string $route_name - * The route name to use for the link. + * @param string $path + * The route path to use for the link. * * @return $this */ - public function setLinkTemplate($key, $route_name); + public function setLinkTemplate($key, $path); /** * Gets the callback for the label of the entity. diff --git a/core/modules/action/action.module b/core/modules/action/action.module index f1cde81..22138ae 100644 --- a/core/modules/action/action.module +++ b/core/modules/action/action.module @@ -44,6 +44,6 @@ function action_entity_type_build(array &$entity_types) { ->setFormClass('edit', 'Drupal\action\ActionEditForm') ->setFormClass('delete', 'Drupal\action\Form\ActionDeleteForm') ->setListBuilderClass('Drupal\action\ActionListBuilder') - ->setLinkTemplate('delete-form', 'entity.action.delete_form') - ->setLinkTemplate('edit-form', 'entity.action.edit_form'); + ->setLinkTemplate('delete-form', '/admin/config/system/actions/configure/{action}/delete') + ->setLinkTemplate('edit-form', '/admin/config/system/actions/configure/{action}'); } diff --git a/core/modules/aggregator/src/Entity/Feed.php b/core/modules/aggregator/src/Entity/Feed.php index fe468b6..7f0c287 100644 --- a/core/modules/aggregator/src/Entity/Feed.php +++ b/core/modules/aggregator/src/Entity/Feed.php @@ -33,9 +33,9 @@ * } * }, * links = { - * "canonical" = "entity.aggregator_feed.canonical", - * "edit-form" = "entity.aggregator_feed.edit_form", - * "delete-form" = "entity.aggregator_feed.delete_form", + * "canonical" = "/aggregator/sources/{aggregator_feed}", + * "edit-form" = "/aggregator/sources/{aggregator_feed}/configure", + * "delete-form" = "/aggregator/sources/{aggregator_feed}/delete", * }, * field_ui_base_route = "aggregator.admin_overview", * base_table = "aggregator_feed", diff --git a/core/modules/block/src/Entity/Block.php b/core/modules/block/src/Entity/Block.php index 0edc961..275acde 100644 --- a/core/modules/block/src/Entity/Block.php +++ b/core/modules/block/src/Entity/Block.php @@ -36,8 +36,8 @@ * "id" = "id" * }, * links = { - * "delete-form" = "entity.block.delete_form", - * "edit-form" = "entity.block.edit_form" + * "delete-form" = "/admin/structure/block/manage/{block}/delete", + * "edit-form" = "/admin/structure/block/manage/{block}" * } * ) */ diff --git a/core/modules/block_content/block_content.routing.yml b/core/modules/block_content/block_content.routing.yml index 90d26ea..6ab7937 100644 --- a/core/modules/block_content/block_content.routing.yml +++ b/core/modules/block_content/block_content.routing.yml @@ -45,6 +45,15 @@ entity.block_content.canonical: requirements: _entity_access: 'block_content.update' +entity.block_content.edit_form: + path: '/block/{block_content}' + defaults: + _entity_form: 'block_content.edit' + options: + _admin_route: TRUE + requirements: + _entity_access: 'block_content.update' + entity.block_content.delete_form: path: '/block/{block_content}/delete' defaults: diff --git a/core/modules/block_content/src/Entity/BlockContent.php b/core/modules/block_content/src/Entity/BlockContent.php index 4908d95..f3c4767 100644 --- a/core/modules/block_content/src/Entity/BlockContent.php +++ b/core/modules/block_content/src/Entity/BlockContent.php @@ -39,9 +39,9 @@ * revision_table = "block_content_revision", * data_table = "block_content_field_data", * links = { - * "canonical" = "entity.block_content.canonical", - * "delete-form" = "entity.block_content.delete_form", - * "edit-form" = "entity.block_content.canonical", + * "canonical" = "/block/{block_content}", + * "delete-form" = "/block/{block_content}/delete", + * "edit-form" = "/block/{block_content}", * }, * translatable = TRUE, * entity_keys = { diff --git a/core/modules/block_content/src/Entity/BlockContentType.php b/core/modules/block_content/src/Entity/BlockContentType.php index fa1aba1..d4308e7 100644 --- a/core/modules/block_content/src/Entity/BlockContentType.php +++ b/core/modules/block_content/src/Entity/BlockContentType.php @@ -35,8 +35,8 @@ * "label" = "label" * }, * links = { - * "delete-form" = "entity.block_content_type.delete_form", - * "edit-form" = "entity.block_content_type.edit_form" + * "delete-form" = "/admin/structure/block/block-content/manage/{block_content_type}/delete", + * "edit-form" = "/admin/structure/block/block-content/manage/{block_content_type}" * } * ) */ diff --git a/core/modules/book/book.module b/core/modules/book/book.module index 51da823..9c7ab55 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -89,8 +89,8 @@ function book_entity_type_build(array &$entity_types) { /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ $entity_types['node'] ->setFormClass('book_outline', 'Drupal\book\Form\BookOutlineForm') - ->setLinkTemplate('book-outline-form', 'entity.node.book_outline_form') - ->setLinkTemplate('book-remove-form', 'entity.node.book_remove_form'); + ->setLinkTemplate('book-outline-form', '/node/{node}/outline') + ->setLinkTemplate('book-remove-form', '/node/{node}/outline/remove'); } /** diff --git a/core/modules/comment/src/Entity/Comment.php b/core/modules/comment/src/Entity/Comment.php index 828c1b6..8b24aba 100644 --- a/core/modules/comment/src/Entity/Comment.php +++ b/core/modules/comment/src/Entity/Comment.php @@ -47,9 +47,9 @@ * "uuid" = "uuid" * }, * links = { - * "canonical" = "entity.comment.canonical", - * "delete-form" = "entity.comment.delete_form", - * "edit-form" = "entity.comment.edit_form", + * "canonical" = "/comment/{comment}", + * "delete-form" = "/comment/{comment}/delete", + * "edit-form" = "/comment/{comment}/edit", * }, * bundle_entity_type = "comment_type", * field_ui_base_route = "entity.comment_type.edit_form", diff --git a/core/modules/comment/src/Entity/CommentType.php b/core/modules/comment/src/Entity/CommentType.php index 8c36b22..80a1aaa 100644 --- a/core/modules/comment/src/Entity/CommentType.php +++ b/core/modules/comment/src/Entity/CommentType.php @@ -34,9 +34,9 @@ * "label" = "label" * }, * links = { - * "delete-form" = "entity.comment_type.delete_form", - * "edit-form" = "entity.comment_type.edit_form", - * "add-form" = "entity.comment_type.add_form" + * "delete-form" = "/admin/structure/comment/manage/{comment_type}/delete", + * "edit-form" = "/admin/structure/comment/manage/{comment_type}", + * "add-form" = "/admin/structure/comment/types/add" * } * ) */ diff --git a/core/modules/comment/src/Form/CommentAdminOverview.php b/core/modules/comment/src/Form/CommentAdminOverview.php index 4abff68..c241841 100644 --- a/core/modules/comment/src/Form/CommentAdminOverview.php +++ b/core/modules/comment/src/Form/CommentAdminOverview.php @@ -224,7 +224,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $type = ' if ($this->moduleHandler->moduleExists('content_translation') && $this->moduleHandler->invoke('content_translation', 'translate_access', array($comment))->isAllowed()) { $links['translate'] = array( 'title' => $this->t('Translate'), - 'url' => Url::fromRoute('content_translation.translation_overview_comment', ['comment' => $comment->id()], $comment_uri_options + ['query' => $destination]), + 'url' => Url::fromRoute('entity.comment.content_translation_overview', ['comment' => $comment->id()], $comment_uri_options + ['query' => $destination]), ); } $options[$comment->id()]['operations']['data'] = array( diff --git a/core/modules/comment/src/Tests/CommentTypeTest.php b/core/modules/comment/src/Tests/CommentTypeTest.php index 148d1ef..060d69d 100644 --- a/core/modules/comment/src/Tests/CommentTypeTest.php +++ b/core/modules/comment/src/Tests/CommentTypeTest.php @@ -108,7 +108,7 @@ public function testCommentTypeEditing() { $this->drupalGet('admin/structure/comment'); $this->assertRaw('Bar', 'New name was displayed.'); $this->clickLink('Manage fields'); - $this->assertUrl(\Drupal::url('field_ui.overview_comment', array('comment_type' => 'comment'), array('absolute' => TRUE)), [], 'Original machine name was used in URL.'); + $this->assertUrl(\Drupal::url('entity.comment_type.field_ui_fields', ['comment_type' => 'comment'], ['absolute' => TRUE]), [], 'Original machine name was used in URL.'); $this->assertTrue($this->cssSelect('tr#comment-body'), 'Body field exists.'); // Remove the body field. diff --git a/core/modules/config/tests/config_test/config_test.module b/core/modules/config/tests/config_test/config_test.module index 1f3a30b..d7742d0 100644 --- a/core/modules/config/tests/config_test/config_test.module +++ b/core/modules/config/tests/config_test/config_test.module @@ -50,8 +50,8 @@ function config_test_entity_type_alter(array &$entity_types) { // Create a clone of config_test that does not have a status. $entity_types['config_test_no_status'] = clone $entity_types['config_test']; $config_test_no_status = &$entity_types['config_test_no_status']; - $config_test_no_status->setLinkTemplate('edit-form', 'entity.config_test.edit_form_config_test_no_status'); - $config_test_no_status->setLinkTemplate('delete-form', 'entity.config_test.delete_form_config_test_no_status'); + $config_test_no_status->setLinkTemplate('edit-form', '/admin/structure/config_test/manage/{config_test_no_status}'); + $config_test_no_status->setLinkTemplate('delete-form', '/admin/structure/config_test/manage/{config_test_no_status}/delete'); $keys = $config_test_no_status->getKeys(); unset($keys['status']); diff --git a/core/modules/config/tests/config_test/src/Entity/ConfigTest.php b/core/modules/config/tests/config_test/src/Entity/ConfigTest.php index ae56360..d9b69df 100644 --- a/core/modules/config/tests/config_test/src/Entity/ConfigTest.php +++ b/core/modules/config/tests/config_test/src/Entity/ConfigTest.php @@ -34,10 +34,10 @@ * "status" = "status" * }, * links = { - * "edit-form" = "entity.config_test.edit_form", - * "delete-form" = "entity.config_test.delete_form", - * "enable" = "entity.config_test.enable", - * "disable" = "entity.config_test.disable" + * "edit-form" = "/admin/structure/config_test/manage/{config_test}", + * "delete-form" = "/admin/structure/config_test/manage/{config_test}/delete", + * "enable" = "/admin/structure/config_test/manage/{config_test}/enable", + * "disable" = "/admin/structure/config_test/manage/{config_test}/disable" * } * ) */ diff --git a/core/modules/config_translation/config_translation.api.php b/core/modules/config_translation/config_translation.api.php index e44c168..f631655 100644 --- a/core/modules/config_translation/config_translation.api.php +++ b/core/modules/config_translation/config_translation.api.php @@ -36,13 +36,13 @@ function hook_config_translation_info(&$info) { $route_provider = \Drupal::service('router.route_provider'); // If field UI is not enabled, the base routes of the type - // "field_ui.field_edit_$entity_type" are not defined. + // "entity.field_config.{$entity_type}_field_edit_form" are not defined. if (\Drupal::moduleHandler()->moduleExists('field_ui')) { // Add fields entity mappers to all fieldable entity types defined. foreach ($entity_manager->getDefinitions() as $entity_type_id => $entity_type) { $base_route = NULL; try { - $base_route = $route_provider->getRouteByName('field_ui.field_edit_' . $entity_type_id); + $base_route = $route_provider->getRouteByName('entity.field_config.' . $entity_type_id . '_field_edit_form'); } catch (RouteNotFoundException $e) { // Ignore non-existent routes. @@ -51,7 +51,7 @@ function hook_config_translation_info(&$info) { // Make sure entity type has field UI enabled and has a base route. if ($entity_type->get('field_ui_base_route') && !empty($base_route)) { $info[$entity_type_id . '_fields'] = array( - 'base_route_name' => 'field_ui.field_edit_' . $entity_type_id, + 'base_route_name' => 'entity.field_config.' . $entity_type_id . '_field_edit_form', 'entity_type' => 'field_config', 'title' => t('!label field'), 'class' => '\Drupal\config_translation\ConfigFieldMapper', diff --git a/core/modules/config_translation/config_translation.module b/core/modules/config_translation/config_translation.module index 336a405..3655d49 100644 --- a/core/modules/config_translation/config_translation.module +++ b/core/modules/config_translation/config_translation.module @@ -8,6 +8,7 @@ use Drupal\config_translation\Plugin\Derivative\ConfigTranslationLocalTasks; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Routing\RouteMatchInterface; +use Drupal\field\FieldConfigInterface; use Symfony\Component\Routing\Exception\RouteNotFoundException; /** @@ -83,7 +84,7 @@ function config_translation_entity_type_alter(array &$entity_types) { elseif ($entity_type_id == 'field_config') { $class = 'Drupal\config_translation\Controller\ConfigTranslationFieldListBuilder'; // Will be filled in dynamically, see \Drupal\field\Entity\FieldConfig::linkTemplates(). - $entity_type->setLinkTemplate('drupal:config-translation-overview', 'config_translation.item.overview.'); + $entity_type->setLinkTemplate('config-translation-overview', $entity_type->getLinkTemplate('edit-form') . '/translate'); } else { $class = 'Drupal\config_translation\Controller\ConfigTranslationEntityListBuilder'; @@ -91,7 +92,7 @@ function config_translation_entity_type_alter(array &$entity_types) { $entity_type->setHandlerClass('config_translation_list', $class); if ($entity_type->hasLinkTemplate('edit-form')) { - $entity_type->setLinkTemplate('drupal:config-translation-overview', 'config_translation.item.overview.' . $entity_type->getLinkTemplate('edit-form')); + $entity_type->setLinkTemplate('config-translation-overview', $entity_type->getLinkTemplate('edit-form') . '/translate'); } } } @@ -105,14 +106,14 @@ function config_translation_config_translation_info(&$info) { $route_provider = \Drupal::service('router.route_provider'); // If field UI is not enabled, the base routes of the type - // "field_ui.field_edit_$entity_type" are not defined. + // "entity.field_config.{$entity_type}_field_edit_form" are not defined. if (\Drupal::moduleHandler()->moduleExists('field_ui')) { // Add fields entity mappers to all fieldable entity types defined. foreach ($entity_manager->getDefinitions() as $entity_type_id => $entity_type) { // Make sure entity type has field UI enabled and has a base route. if ($entity_type->get('field_ui_base_route')) { $info[$entity_type_id . '_fields'] = array( - 'base_route_name' => 'field_ui.field_edit_' . $entity_type_id, + 'base_route_name' => "entity.field_config.{$entity_type_id}_field_edit_form", 'entity_type' => 'field_config', 'title' => '!label field', 'class' => '\Drupal\config_translation\ConfigFieldMapper', @@ -139,9 +140,10 @@ function config_translation_config_translation_info(&$info) { } // Use the entity type as the plugin ID. + $base_route_name = "entity.$entity_type_id.edit_form"; $info[$entity_type_id] = array( 'class' => '\Drupal\config_translation\ConfigEntityMapper', - 'base_route_name' => $entity_type->getLinkTemplate('edit-form'), + 'base_route_name' => $base_route_name, 'title' => '!label !entity_type', 'names' => array(), 'entity_type' => $entity_type_id, @@ -157,12 +159,18 @@ function config_translation_entity_operation(EntityInterface $entity) { $operations = array(); $entity_type = $entity->getEntityType(); if ($entity_type->isSubclassOf('Drupal\Core\Config\Entity\ConfigEntityInterface') && - $entity->hasLinkTemplate('drupal:config-translation-overview') && + $entity->hasLinkTemplate('config-translation-overview') && \Drupal::currentUser()->hasPermission('translate configuration')) { + + $link_template = 'config-translation-overview'; + if ($entity instanceof FieldConfigInterface) { + $link_template = "config-translation-overview.{$entity->getTargetEntityTypeId()}"; + } + $operations['translate'] = array( 'title' => t('Translate'), 'weight' => 50, - 'url' => $entity->urlInfo('drupal:config-translation-overview'), + 'url' => $entity->urlInfo($link_template), ); } diff --git a/core/modules/config_translation/src/ConfigEntityMapper.php b/core/modules/config_translation/src/ConfigEntityMapper.php index 848a6ce..e9bdc60 100644 --- a/core/modules/config_translation/src/ConfigEntityMapper.php +++ b/core/modules/config_translation/src/ConfigEntityMapper.php @@ -245,6 +245,13 @@ public function getContextualLinkGroup() { /** * {@inheritdoc} */ + public function getOverviewRouteName() { + return 'entity.' . $this->entityType . '.config_translation_overview'; + } + + /** + * {@inheritdoc} + */ protected function processRoute(Route $route) { // Add entity upcasting information. $parameters = $route->getOption('parameters') ?: array(); diff --git a/core/modules/config_translation/src/ConfigFieldMapper.php b/core/modules/config_translation/src/ConfigFieldMapper.php index 242e084..e9d48e4 100644 --- a/core/modules/config_translation/src/ConfigFieldMapper.php +++ b/core/modules/config_translation/src/ConfigFieldMapper.php @@ -37,6 +37,13 @@ public function getBaseRouteParameters() { /** * {@inheritdoc} */ + public function getOverviewRouteName() { + return 'entity.field_config.config_translation_overview.' . $this->pluginDefinition['base_entity_type']; + } + + /** + * {@inheritdoc} + */ public function getTypeLabel() { $base_entity_info = $this->entityManager->getDefinition($this->pluginDefinition['base_entity_type']); return $this->t('@label fields', array('@label' => $base_entity_info->getLabel())); diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index 99ac31f..c56633f 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -43,7 +43,7 @@ function contact_help($route_name, RouteMatchInterface $route_match) { */ function contact_entity_type_alter(array &$entity_types) { /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ - $entity_types['user']->setLinkTemplate('contact-form', 'entity.user.contact_form'); + $entity_types['user']->setLinkTemplate('contact-form', '/user/{user}/contact'); } /** diff --git a/core/modules/contact/src/Entity/ContactForm.php b/core/modules/contact/src/Entity/ContactForm.php index 2dd7ce3..c6ffdaf 100644 --- a/core/modules/contact/src/Entity/ContactForm.php +++ b/core/modules/contact/src/Entity/ContactForm.php @@ -34,8 +34,8 @@ * "label" = "label" * }, * links = { - * "delete-form" = "entity.contact_form.delete_form", - * "edit-form" = "entity.contact_form.edit_form" + * "delete-form" = "/admin/structure/contact/manage/{contact_form}/delete", + * "edit-form" = "/admin/structure/contact/manage/{contact_form}" * } * ) */ diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index 89a6cbb..9f5ae57 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -116,7 +116,7 @@ function content_translation_entity_type_alter(array &$entity_types) { if ($entity_type->hasLinkTemplate('canonical')) { // Provide default route names for the translation paths. if (!$entity_type->hasLinkTemplate('drupal:content-translation-overview')) { - $entity_type->setLinkTemplate('drupal:content-translation-overview', "content_translation.translation_overview_" . $entity_type->id()); + $entity_type->setLinkTemplate('drupal:content-translation-overview', $entity_type->getLinkTemplate('canonical') . '/translations'); } // @todo Remove this as soon as menu access checks rely on the // controller. See https://drupal.org/node/2155787. diff --git a/core/modules/content_translation/src/Plugin/Derivative/ContentTranslationContextualLinks.php b/core/modules/content_translation/src/Plugin/Derivative/ContentTranslationContextualLinks.php index b1f424f..9acf394 100644 --- a/core/modules/content_translation/src/Plugin/Derivative/ContentTranslationContextualLinks.php +++ b/core/modules/content_translation/src/Plugin/Derivative/ContentTranslationContextualLinks.php @@ -53,7 +53,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { // Create contextual links for translatable entity types. foreach ($this->contentTranslationManager->getSupportedEntityTypes() as $entity_type_id => $entity_type) { $this->derivatives[$entity_type_id]['title'] = t('Translate'); - $this->derivatives[$entity_type_id]['route_name'] = $entity_type->getLinkTemplate('drupal:content-translation-overview'); + $this->derivatives[$entity_type_id]['route_name'] = "entity.$entity_type_id.content_translation_overview"; $this->derivatives[$entity_type_id]['group'] = $entity_type_id; } return parent::getDerivativeDefinitions($base_plugin_definition); diff --git a/core/modules/content_translation/src/Plugin/Derivative/ContentTranslationLocalTasks.php b/core/modules/content_translation/src/Plugin/Derivative/ContentTranslationLocalTasks.php index 8b060f2..995de59 100644 --- a/core/modules/content_translation/src/Plugin/Derivative/ContentTranslationLocalTasks.php +++ b/core/modules/content_translation/src/Plugin/Derivative/ContentTranslationLocalTasks.php @@ -61,13 +61,14 @@ public function getDerivativeDefinitions($base_plugin_definition) { // Create tabs for all possible entity types. foreach ($this->contentTranslationManager->getSupportedEntityTypes() as $entity_type_id => $entity_type) { // Find the route name for the translation overview. - $translation_route_name = $entity_type->getLinkTemplate('drupal:content-translation-overview'); + $translation_route_name = "entity.$entity_type_id.content_translation_overview"; + $base_route_name = "entity.$entity_type_id.canonical"; $this->derivatives[$translation_route_name] = array( 'entity_type' => $entity_type_id, 'title' => 'Translate', 'route_name' => $translation_route_name, - 'base_route' => $entity_type->getLinkTemplate('canonical'), + 'base_route' => $base_route_name, ) + $base_plugin_definition; } return parent::getDerivativeDefinitions($base_plugin_definition); diff --git a/core/modules/content_translation/src/Routing/ContentTranslationRouteSubscriber.php b/core/modules/content_translation/src/Routing/ContentTranslationRouteSubscriber.php index 2ec582b..f6c5bc0 100644 --- a/core/modules/content_translation/src/Routing/ContentTranslationRouteSubscriber.php +++ b/core/modules/content_translation/src/Routing/ContentTranslationRouteSubscriber.php @@ -42,17 +42,26 @@ public function __construct(ContentTranslationManagerInterface $content_translat protected function alterRoutes(RouteCollection $collection) { foreach ($this->contentTranslationManager->getSupportedEntityTypes() as $entity_type_id => $entity_type) { // Try to get the route from the current collection. - if (!$entity_route = $collection->get($entity_type->getLinkTemplate('canonical'))) { - continue; + $link_template = $entity_type->getLinkTemplate('canonical'); + if (strpos($link_template, '/') !== FALSE) { + $base_path = '/' . $link_template; + } + else { + if (!$entity_route = $collection->get("entity.$entity_type_id.canonical")) { + continue; + } + $base_path = $entity_route->getPath(); } - $path = $entity_route->getPath() . '/translations'; // Inherit admin route status from edit route, if exists. $is_admin = FALSE; - if ($edit_route = $collection->get($entity_type->getLinkTemplate('edit-form'))) { + $route_name = "entity.$entity_type_id.edit_form"; + if ($edit_route = $collection->get($route_name)) { $is_admin = (bool) $edit_route->getOption('_admin_route'); } + $path = $base_path . '/translations'; + $route = new Route( $path, array( @@ -71,7 +80,8 @@ protected function alterRoutes(RouteCollection $collection) { '_admin_route' => $is_admin, ) ); - $collection->add($entity_type->getLinkTemplate('drupal:content-translation-overview'), $route); + $route_name = "entity.$entity_type_id.content_translation_overview"; + $collection->add($route_name, $route); $route = new Route( $path . '/add/{source}/{target}', diff --git a/core/modules/content_translation/src/Tests/ContentTranslationWorkflowsTest.php b/core/modules/content_translation/src/Tests/ContentTranslationWorkflowsTest.php index 1c6ff21..df14e15 100644 --- a/core/modules/content_translation/src/Tests/ContentTranslationWorkflowsTest.php +++ b/core/modules/content_translation/src/Tests/ContentTranslationWorkflowsTest.php @@ -62,6 +62,7 @@ protected function setupEntity() { // Create a translation. $this->drupalLogin($this->translator); $path = $this->entity->getSystemPath('drupal:content-translation-overview'); + $add_translation_path = $path . "/add/$default_langcode/{$this->langcodes[2]}"; $this->drupalPostForm($add_translation_path, array(), t('Save')); $this->rebuildContainer(); diff --git a/core/modules/content_translation/tests/src/Unit/Menu/ContentTranslationLocalTasksTest.php b/core/modules/content_translation/tests/src/Unit/Menu/ContentTranslationLocalTasksTest.php index b8d799a..1a58b31 100644 --- a/core/modules/content_translation/tests/src/Unit/Menu/ContentTranslationLocalTasksTest.php +++ b/core/modules/content_translation/tests/src/Unit/Menu/ContentTranslationLocalTasksTest.php @@ -28,7 +28,7 @@ protected function setUp() { ->method('getLinkTemplate') ->will($this->returnValueMap(array( array('canonical', 'entity.node.canonical'), - array('drupal:content-translation-overview', 'content_translation.translation_overview_node'), + array('drupal:content-translation-overview', 'entity.node.content_translation_overview'), ))); $content_translation_manager = $this->getMock('Drupal\content_translation\ContentTranslationManagerInterface'); $content_translation_manager->expects($this->any()) @@ -54,14 +54,14 @@ public function testBlockAdminDisplay($route, $expected) { public function providerTestBlockAdminDisplay() { return array( array('entity.node.canonical', array(array( - 'content_translation.local_tasks:content_translation.translation_overview_node', + 'content_translation.local_tasks:entity.node.content_translation_overview', 'entity.node.canonical', 'entity.node.edit_form', 'entity.node.delete_form', 'entity.node.version_history', ))), - array('content_translation.translation_overview_node', array(array( - 'content_translation.local_tasks:content_translation.translation_overview_node', + array('entity.node.content_translation_overview', array(array( + 'content_translation.local_tasks:entity.node.content_translation_overview', 'entity.node.canonical', 'entity.node.edit_form', 'entity.node.delete_form', diff --git a/core/modules/field/src/Entity/FieldConfig.php b/core/modules/field/src/Entity/FieldConfig.php index a8d9c0a..dc5607a 100644 --- a/core/modules/field/src/Entity/FieldConfig.php +++ b/core/modules/field/src/Entity/FieldConfig.php @@ -261,12 +261,12 @@ public static function postDelete(EntityStorageInterface $storage, array $fields protected function linkTemplates() { $link_templates = parent::linkTemplates(); if (\Drupal::moduleHandler()->moduleExists('field_ui')) { - $link_templates['edit-form'] = 'field_ui.field_edit_' . $this->entity_type; - $link_templates['storage-edit-form'] = 'field_ui.storage_edit_' . $this->entity_type; - $link_templates['delete-form'] = 'field_ui.delete_' . $this->entity_type; + $link_templates["{$this->entity_type}-field-edit-form"] = 'entity.field_config.' . $this->entity_type . '_field_edit_form'; + $link_templates["{$this->entity_type}-storage-edit-form"] = 'entity.field_config.' . $this->entity_type . '_storage_edit_form'; + $link_templates["{$this->entity_type}-field-delete-form"] = 'entity.field_config.' . $this->entity_type . '_field_delete_form'; - if (isset($link_templates['drupal:config-translation-overview'])) { - $link_templates['drupal:config-translation-overview'] .= $link_templates['edit-form']; + if (isset($link_templates['config-translation-overview'])) { + $link_templates["config-translation-overview.{$this->entity_type}"] = "entity.field_config.config_translation_overview.{$this->entity_type}"; } } return $link_templates; diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module index bdd492a..c314a6c 100644 --- a/core/modules/field_ui/field_ui.module +++ b/core/modules/field_ui/field_ui.module @@ -51,7 +51,7 @@ function field_ui_help($route_name, RouteMatchInterface $route_match) { $output .= '
' . t('Individual content types can have different fields, behaviors, and permissions assigned to them.') . '
'; - case 'field_ui.form_display_overview_node': + case "entity.node.field_ui_form_display": case 'field_ui.form_display_overview_form_mode_node': $type = $route_match->getParameter('node_type'); return '' . t('Content items can be edited using different form modes. Here, you can define which fields are shown and hidden when %type content is edited in each form mode, and define how the field form widgets are displayed in each form mode.', array('%type' => $type->label())) . '
' ; - case 'field_ui.display_overview_node': + case 'entity.node.field_ui_display': case 'field_ui.display_overview_view_mode_node': $type = $route_match->getParameter('node_type'); return '' . t('Content items can be displayed using different view modes: Teaser, Full content, Print, RSS, etc. Teaser is a short format that is typically used in lists of multiple content items. Full content is typically used when the content is displayed on its own page.') . '
' . diff --git a/core/modules/node/src/Entity/Node.php b/core/modules/node/src/Entity/Node.php index 4e7dc84..40d0053 100644 --- a/core/modules/node/src/Entity/Node.php +++ b/core/modules/node/src/Entity/Node.php @@ -57,10 +57,10 @@ * field_ui_base_route = "entity.node_type.edit_form", * permission_granularity = "bundle", * links = { - * "canonical" = "entity.node.canonical", - * "delete-form" = "entity.node.delete_form", - * "edit-form" = "entity.node.edit_form", - * "version-history" = "entity.node.version_history", + * "canonical" = "/node/{node}", + * "delete-form" = "/node/{node}/delete", + * "edit-form" = "/node/{node}/edit", + * "version-history" = "/node/{node}/revisions", * } * ) */ diff --git a/core/modules/node/src/Entity/NodeType.php b/core/modules/node/src/Entity/NodeType.php index 6113247..8ba20e1 100644 --- a/core/modules/node/src/Entity/NodeType.php +++ b/core/modules/node/src/Entity/NodeType.php @@ -35,8 +35,8 @@ * "label" = "name" * }, * links = { - * "edit-form" = "entity.node_type.edit_form", - * "delete-form" = "entity.node_type.delete_form" + * "edit-form" = "/admin/structure/types/manage/{node_type}", + * "delete-form" = "/admin/structure/types/manage/{node_type}/delete" * } * ) */ diff --git a/core/modules/responsive_image/src/Entity/ResponsiveImageMapping.php b/core/modules/responsive_image/src/Entity/ResponsiveImageMapping.php index 3e8440e..f866656 100644 --- a/core/modules/responsive_image/src/Entity/ResponsiveImageMapping.php +++ b/core/modules/responsive_image/src/Entity/ResponsiveImageMapping.php @@ -33,8 +33,8 @@ * "label" = "label" * }, * links = { - * "edit-form" = "entity.responsive_image_mapping.edit_form", - * "duplicate-form" = "entity.responsive_image_mapping.duplicate_form" + * "edit-form" = "/admin/config/media/responsive-image-mapping/{responsive_image_mapping}", + * "duplicate-form" = "/admin/config/media/responsive-image-mapping/{responsive_image_mapping}/duplicate" * } * ) */ diff --git a/core/modules/rest/src/Plugin/Derivative/EntityDerivative.php b/core/modules/rest/src/Plugin/Derivative/EntityDerivative.php index 888a724..b7f02a7 100644 --- a/core/modules/rest/src/Plugin/Derivative/EntityDerivative.php +++ b/core/modules/rest/src/Plugin/Derivative/EntityDerivative.php @@ -110,7 +110,11 @@ public function getDerivativeDefinitions($base_plugin_definition) { foreach ($default_uris as $link_relation => $default_uri) { // Check if there are link templates defined for the entity type and // use the path from the route instead of the default. - if ($route_name = $entity_type->getLinkTemplate($link_relation)) { + $link_template = $entity_type->getLinkTemplate($link_relation); + if (strpos($link_template, '/') !== FALSE) { + $this->derivatives[$entity_type_id]['uri_paths'][$link_relation] = '/' . $link_template; + } + elseif ($route_name = $link_template) { // @todo remove the try/catch as part of // http://drupal.org/node/2281645 try { diff --git a/core/modules/search/src/Entity/SearchPage.php b/core/modules/search/src/Entity/SearchPage.php index c2d0794..1ca1b54 100644 --- a/core/modules/search/src/Entity/SearchPage.php +++ b/core/modules/search/src/Entity/SearchPage.php @@ -35,11 +35,11 @@ * }, * admin_permission = "administer search", * links = { - * "edit-form" = "entity.search_page.edit_form", - * "delete-form" = "entity.search_page.delete_form", - * "enable" = "entity.search_page.enable", - * "disable" = "entity.search_page.disable", - * "set-default" = "entity.search_page.set_default" + * "edit-form" = "/admin/config/search/pages/manage/{search_page}", + * "delete-form" = "/admin/config/search/pages/manage/{search_page}/delete", + * "enable" = "/admin/config/search/pages/manage/{search_page}/enable", + * "disable" = "/admin/config/search/pages/manage/{search_page}/disable", + * "set-default" = "/admin/config/search/pages/manage/{search_page}/set-default" * }, * config_prefix = "page", * entity_keys = { diff --git a/core/modules/shortcut/shortcut.routing.yml b/core/modules/shortcut/shortcut.routing.yml index d8d8ea2..7fb1c09 100644 --- a/core/modules/shortcut/shortcut.routing.yml +++ b/core/modules/shortcut/shortcut.routing.yml @@ -62,6 +62,14 @@ entity.shortcut.canonical: requirements: _entity_access: 'shortcut.update' +entity.shortcut.edit_form: + path: '/admin/config/user-interface/shortcut/link/{shortcut}' + defaults: + _entity_form: 'shortcut.default' + _title: 'Edit' + requirements: + _entity_access: 'shortcut.update' + entity.shortcut.link_delete_inline: path: '/admin/config/user-interface/shortcut/link/{shortcut}/delete-inline' defaults: diff --git a/core/modules/shortcut/src/Entity/Shortcut.php b/core/modules/shortcut/src/Entity/Shortcut.php index ad43339..da40881 100644 --- a/core/modules/shortcut/src/Entity/Shortcut.php +++ b/core/modules/shortcut/src/Entity/Shortcut.php @@ -43,9 +43,9 @@ * "langcode" = "langcode", * }, * links = { - * "canonical" = "entity.shortcut.canonical", - * "delete-form" = "entity.shortcut.delete_form", - * "edit-form" = "entity.shortcut.canonical", + * "canonical" = "/admin/config/user-interface/shortcut/link/{shortcut}", + * "delete-form" = "/admin/config/user-interface/shortcut/link/{shortcut}/delete", + * "edit-form" = "/admin/config/user-interface/shortcut/link/{shortcut}", * }, * list_cache_tags = { "shortcut_set_list" }, * bundle_entity_type = "shortcut_set" diff --git a/core/modules/shortcut/src/Entity/ShortcutSet.php b/core/modules/shortcut/src/Entity/ShortcutSet.php index f72b7d0..2b862c5 100644 --- a/core/modules/shortcut/src/Entity/ShortcutSet.php +++ b/core/modules/shortcut/src/Entity/ShortcutSet.php @@ -36,9 +36,9 @@ * "label" = "label" * }, * links = { - * "customize-form" = "entity.shortcut_set.customize_form", - * "delete-form" = "entity.shortcut_set.delete_form", - * "edit-form" = "entity.shortcut_set.edit_form" + * "customize-form" = "/admin/config/user-interface/shortcut/manage/{shortcut_set}/customize", + * "delete-form" = "/admin/config/user-interface/shortcut/manage/{shortcut_set}/delete", + * "edit-form" = "/admin/config/user-interface/shortcut/manage/{shortcut_set}" * } * ) */ diff --git a/core/modules/system/entity.api.php b/core/modules/system/entity.api.php index 6a97060..f9cb41c 100644 --- a/core/modules/system/entity.api.php +++ b/core/modules/system/entity.api.php @@ -327,10 +327,11 @@ * also need to add a corresponding route to your module's routing.yml file; * see the entity.node.canonical route in node.routing.yml for an example, and see * @ref sec_routes below for some notes. - * - Define routing and links for the various URLs associated with the entity. + * - Define routes and links for the various URLs associated with the entity. * These go into the 'links' annotation, with the link type as the key, and - * the route machine name (defined in your module's routing.yml file) as the - * value; see @ref sec_routes below for some routing notes. Typical link + * the path of this link template. The corresponding route requires the + * following route name: "entity.$entity_type_id.$link_template_type". + * See @ref sec_routes below for some routing notes. Typical link * types are: * - canonical: Default link, either to view (if entities are viewed on their * own pages) or edit the entity. diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 8f2a8ab..676e0da 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -1309,8 +1309,8 @@ function system_entity_type_build(array &$entity_types) { ->setFormClass('edit', 'Drupal\system\Form\DateFormatEditForm') ->setFormClass('delete', 'Drupal\system\Form\DateFormatDeleteForm') ->setListBuilderClass('Drupal\system\DateFormatListBuilder') - ->setLinkTemplate('edit-form', 'entity.date_format.edit_form') - ->setLinkTemplate('delete-form', 'entity.date_format.delete_form'); + ->setLinkTemplate('edit-form', '/admin/config/regional/date-time/formats/manage/{date_format}') + ->setLinkTemplate('delete-form', '/admin/config/regional/date-time/formats/manage/{date_format}/delete'); } /** diff --git a/core/modules/system/tests/modules/entity_test/entity_test.module b/core/modules/system/tests/modules/entity_test/entity_test.module index 6a6c6e2..f56a27e 100644 --- a/core/modules/system/tests/modules/entity_test/entity_test.module +++ b/core/modules/system/tests/modules/entity_test/entity_test.module @@ -27,6 +27,11 @@ const ENTITY_TEST_TYPES_MULTILINGUAL = 2; /** + * Filter that limits test entity list to routeable ones. + */ +const ENTITY_TEST_TYPES_ROUTING = 3; + +/** * Returns a list of test entity types. * * The returned entity types are one for each available entity storage type: @@ -47,7 +52,7 @@ */ function entity_test_entity_types($filter = NULL) { $types = array(); - if ($filter == NULL) { + if ($filter === NULL || $filter === ENTITY_TEST_TYPES_ROUTING) { $types[] = 'entity_test'; } if ($filter != ENTITY_TEST_TYPES_REVISABLE) { @@ -57,7 +62,11 @@ function entity_test_entity_types($filter = NULL) { if ($filter != ENTITY_TEST_TYPES_MULTILINGUAL) { $types[] = 'entity_test_rev'; } + if ($filter === ENTITY_TEST_TYPES_ROUTING) { + $types[] = 'entity_test_base_field_display'; + } $types[] = 'entity_test_mulrev'; + return array_combine($types, $types); } diff --git a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTest.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTest.php index d9800be..0f444a1 100644 --- a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTest.php +++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTest.php @@ -41,9 +41,9 @@ * "langcode" = "langcode", * }, * links = { - * "canonical" = "entity.entity_test.canonical", - * "edit-form" = "entity.entity_test.edit_form", - * "delete-form" = "entity.entity_test.delete_form", + * "canonical" = "/entity_test/{entity_test}", + * "edit-form" = "/entity_test/manage/{entity_test}", + * "delete-form" = "/entity_test/delete/entity_test/{entity_test}", * }, * field_ui_base_route = "entity.entity_test.admin_form", * ) diff --git a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestBaseFieldDisplay.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestBaseFieldDisplay.php index ed213e3..210eb53 100644 --- a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestBaseFieldDisplay.php +++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestBaseFieldDisplay.php @@ -30,7 +30,7 @@ * "bundle" = "type" * }, * links = { - * "edit-form" = "entity.entity_test_base_field_display.edit_form", + * "edit-form" = "/entity_test_base_field_display/manage/{entity_test_base_field_display}", * }, * field_ui_base_route = "entity.entity_test_base_field_display.admin_form", * ) diff --git a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestMul.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestMul.php index cabb610..334ff94 100644 --- a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestMul.php +++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestMul.php @@ -38,9 +38,9 @@ * "langcode" = "langcode", * }, * links = { - * "canonical" = "entity.entity_test_mul.edit_form", - * "edit-form" = "entity.entity_test_mul.edit_form", - * "delete-form" = "entity.entity_test_mul.delete_form", + * "canonical" = "/entity_test_mul/manage/{entity_test_mul}", + * "edit-form" = "/entity_test_mul/manage/{entity_test_mul}", + * "delete-form" = "/entity_test/delete/entity_test_mul/{entity_test_mul}", * }, * field_ui_base_route = "entity.entity_test_mul.admin_form", * ) diff --git a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestMulDefaultValue.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestMulDefaultValue.php index fa3a60e..48b13e2 100644 --- a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestMulDefaultValue.php +++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestMulDefaultValue.php @@ -37,9 +37,9 @@ * "langcode" = "langcode" * }, * links = { - * "canonical" = "entity.entity_test_mul.edit_form", - * "edit-form" = "entity.entity_test_mul.edit_form", - * "delete-form" = "entity.entity_test_mul.delete_form", + * "canonical" = "/entity_test_mul_default_value/manage/{entity_test_mul_default_value}", + * "edit-form" = "/entity_test_mul_default_value/manage/{entity_test_mul_default_value}", + * "delete-form" = "/entity_test/delete/entity_test_mul_default_value/{entity_test_mul_default_value}", * }, * field_ui_base_route = "entity.entity_test_mul.admin_form", * ) diff --git a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestMulLangcodeKey.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestMulLangcodeKey.php index 575d125..0b5585b 100644 --- a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestMulLangcodeKey.php +++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestMulLangcodeKey.php @@ -36,9 +36,9 @@ * "langcode" = "custom_langcode_key", * }, * links = { - * "canonical" = "entity.entity_test_mul_langcode_key.edit_form", - * "edit-form" = "entity.entity_test_mul_langcode_key.edit_form", - * "delete-form" = "entity.entity_test_mul_langcode_key.delete_form", + * "canonical" = "/entity_test_mul_langcode_key/manage/{entity_test_mul_langcode_key}", + * "edit-form" = "/entity_test_mul_langcode_key/manage/{entity_test_mul_langcode_key}", + * "delete-form" = "/entity_test/delete/entity_test_mul_langcode_key/{entity_test_mul_langcode_key}", * }, * field_ui_base_route = "entity.entity_test_mul_langcode_key.admin_form", * ) diff --git a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestMulRev.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestMulRev.php index 7fa29a9..94b4bbe 100644 --- a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestMulRev.php +++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestMulRev.php @@ -41,9 +41,9 @@ * "langcode" = "langcode", * }, * links = { - * "canonical" = "entity.entity_test_mulrev.edit_form", - * "delete-form" = "entity.entity_test_mulrev.delete_form", - * "edit-form" = "entity.entity_test_mulrev.edit_form" + * "canonical" = "/entity_test_mulrev/manage/{entity_test_mulrev}", + * "delete-form" = "/entity_test/delete/entity_test_mulrev/{entity_test_mulrev}", + * "edit-form" = "/entity_test_mulrev/manage/{entity_test_mulrev}", * } * ) */ diff --git a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestRev.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestRev.php index f5bee90..3859a02 100644 --- a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestRev.php +++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestRev.php @@ -37,9 +37,9 @@ * "langcode" = "langcode", * }, * links = { - * "canonical" = "entity.entity_test_rev.edit_form", - * "delete-form" = "entity.entity_test_rev.delete_form", - * "edit-form" = "entity.entity_test_rev.edit_form" + * "canonical" = "/entity_test_rev/manage/{entity_test_rev}", + * "delete-form" = "/entity_test/delete/entity_test_rev/{entity_test_rev}", + * "edit-form" = "/entity_test_rev/manage/{entity_test_rev}" * } * ) */ diff --git a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestStringId.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestStringId.php index 9d74938..7e057d4 100644 --- a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestStringId.php +++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestStringId.php @@ -29,8 +29,8 @@ * "bundle" = "type" * }, * links = { - * "canonical" = "entity.entity_test.canonical", - * "edit-form" = "entity.entity_test_string_id.edit_form", + * "canonical" = "/entity_test_string_id/manage/{entity_test_string_id}", + * "edit-form" = "/entity_test_string_id/manage/{entity_test_string_id}", * }, * field_ui_base_route = "entity.entity_test_string_id.admin_form", * ) diff --git a/core/modules/system/tests/modules/entity_test/src/Plugin/Derivative/EntityTestLocalTasks.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Derivative/EntityTestLocalTasks.php index 7c7a90a..e4f8e49 100644 --- a/core/modules/system/tests/modules/entity_test/src/Plugin/Derivative/EntityTestLocalTasks.php +++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Derivative/EntityTestLocalTasks.php @@ -19,13 +19,18 @@ class EntityTestLocalTasks extends DeriverBase { */ public function getDerivativeDefinitions($base_plugin_definition) { $this->derivatives = array(); - $types = entity_test_entity_types(); + $types = entity_test_entity_types(ENTITY_TEST_TYPES_ROUTING); foreach($types as $entity_type) { - $this->derivatives[$entity_type] = array(); - $this->derivatives[$entity_type]['base_route'] = "entity.$entity_type.edit_form"; - $this->derivatives[$entity_type]['route_name'] = "entity.$entity_type.edit_form"; - $this->derivatives[$entity_type]['title'] = 'Edit'; + $this->derivatives[$entity_type . '.canonical'] = array(); + $this->derivatives[$entity_type . '.canonical']['base_route'] = "entity.$entity_type.canonical"; + $this->derivatives[$entity_type . '.canonical']['route_name'] = "entity.$entity_type.canonical"; + $this->derivatives[$entity_type . '.canonical']['title'] = 'View'; + + $this->derivatives[$entity_type . '.edit'] = array(); + $this->derivatives[$entity_type . '.edit']['base_route'] = "entity.$entity_type.canonical"; + $this->derivatives[$entity_type . '.edit']['route_name'] = "entity.$entity_type.edit_form"; + $this->derivatives[$entity_type . '.edit']['title'] = 'Edit'; } return parent::getDerivativeDefinitions($base_plugin_definition); diff --git a/core/modules/system/tests/modules/entity_test/src/Routing/EntityTestRoutes.php b/core/modules/system/tests/modules/entity_test/src/Routing/EntityTestRoutes.php index 03e147c..53c1978 100644 --- a/core/modules/system/tests/modules/entity_test/src/Routing/EntityTestRoutes.php +++ b/core/modules/system/tests/modules/entity_test/src/Routing/EntityTestRoutes.php @@ -21,7 +21,7 @@ class EntityTestRoutes { * An array of route objects. */ public function routes() { - $types = entity_test_entity_types(); + $types = entity_test_entity_types(ENTITY_TEST_TYPES_ROUTING); $types[] = 'entity_test_string_id'; $types[] = 'entity_test_no_id'; @@ -33,6 +33,15 @@ public function routes() { array('_permission' => 'administer entity_test content') ); + $routes["entity.$entity_type_id.canonical"] = new Route( + $entity_type_id . '/manage/{' . $entity_type_id . '}', + array('_controller' => '\Drupal\entity_test\Controller\EntityTestController::testEdit', 'entity_type_id' => $entity_type_id), + array('_permission' => 'administer entity_test content'), + array('parameters' => array( + $entity_type_id => array('type' => 'entity:' . $entity_type_id), + )) + ); + $routes["entity.$entity_type_id.edit_form"] = new Route( $entity_type_id . '/manage/{' . $entity_type_id . '}', array('_controller' => '\Drupal\entity_test\Controller\EntityTestController::testEdit', 'entity_type_id' => $entity_type_id), diff --git a/core/modules/taxonomy/src/Entity/Term.php b/core/modules/taxonomy/src/Entity/Term.php index 93f9009..043c90d 100644 --- a/core/modules/taxonomy/src/Entity/Term.php +++ b/core/modules/taxonomy/src/Entity/Term.php @@ -46,9 +46,9 @@ * bundle_entity_type = "taxonomy_vocabulary", * field_ui_base_route = "entity.taxonomy_vocabulary.overview_form", * links = { - * "canonical" = "entity.taxonomy_term.canonical", - * "delete-form" = "entity.taxonomy_term.delete_form", - * "edit-form" = "entity.taxonomy_term.edit_form", + * "canonical" = "/taxonomy/term/{taxonomy_term}", + * "delete-form" = "/taxonomy/term/{taxonomy_term}/delete", + * "edit-form" = "/taxonomy/term/{taxonomy_term}/edit", * }, * permission_granularity = "bundle" * ) diff --git a/core/modules/taxonomy/src/Entity/Vocabulary.php b/core/modules/taxonomy/src/Entity/Vocabulary.php index 6d83fa7..ef831de 100644 --- a/core/modules/taxonomy/src/Entity/Vocabulary.php +++ b/core/modules/taxonomy/src/Entity/Vocabulary.php @@ -36,11 +36,11 @@ * "weight" = "weight" * }, * links = { - * "add-form" = "entity.taxonomy_term.add_form", - * "delete-form" = "entity.taxonomy_vocabulary.delete_form", - * "reset-form" = "entity.taxonomy_vocabulary.reset_form", - * "overview-form" = "entity.taxonomy_vocabulary.overview_form", - * "edit-form" = "entity.taxonomy_vocabulary.edit_form" + * "add-form" = "/admin/structure/taxonomy/manage/{taxonomy_vocabulary}/add", + * "delete-form" = "/admin/structure/taxonomy/manage/{taxonomy_vocabulary}/delete", + * "reset-form" = "/admin/structure/taxonomy/manage/{taxonomy_vocabulary}/reset", + * "overview-form" = "/admin/structure/taxonomy/manage/{taxonomy_vocabulary}/overview", + * "edit-form" = "/admin/structure/taxonomy/manage/{taxonomy_vocabulary}" * } * ) */ diff --git a/core/modules/user/src/Entity/Role.php b/core/modules/user/src/Entity/Role.php index cad0530..9bda8d0 100644 --- a/core/modules/user/src/Entity/Role.php +++ b/core/modules/user/src/Entity/Role.php @@ -36,9 +36,9 @@ * "label" = "label" * }, * links = { - * "delete-form" = "entity.user_role.delete_form", - * "edit-form" = "entity.user_role.edit_form", - * "edit-permissions-form" = "entity.user_role.edit_permissions_form" + * "delete-form" = "/admin/people/roles/manage/{user_role}/delete", + * "edit-form" = "/admin/people/roles/manage/{user_role}", + * "edit-permissions-form" = "/admin/people/permissions/{user_role}" * } * ) */ diff --git a/core/modules/user/src/Entity/User.php b/core/modules/user/src/Entity/User.php index 99c91db..7c8af82 100644 --- a/core/modules/user/src/Entity/User.php +++ b/core/modules/user/src/Entity/User.php @@ -51,9 +51,9 @@ * "uuid" = "uuid" * }, * links = { - * "canonical" = "entity.user.canonical", - * "edit-form" = "entity.user.edit_form", - * "cancel-form" = "entity.user.cancel_form", + * "canonical" = "/user/{user}", + * "edit-form" = "/user/{user}/edit", + * "cancel-form" = "/user/{user}/cancel", * }, * field_ui_base_route = "entity.user.admin_form", * ) diff --git a/core/modules/user/user.module b/core/modules/user/user.module index a251fd7..c3d125c 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -81,13 +81,13 @@ function user_help($route_name, RouteMatchInterface $route_match) { case 'user.role_list': return '' . t('A role defines a group of users that have certain privileges. These privileges are defined on the Permissions page. Here, you can define the names and the display sort order of the roles on your site. It is recommended to order roles from least permissive (for example, Anonymous user) to most permissive (for example, Administrator user). Users who are not logged in have the Anonymous user role. Users who are logged in have the Authenticated user role, plus any other roles granted to their user account.', array('!permissions' => \Drupal::url('user.admin_permissions'))) . '
'; - case 'field_ui.overview_user': + case 'entity.user.field_ui_fields': return '' . t('This form lets administrators add and edit fields for storing user data.') . '
'; - case 'field_ui.form_display_overview_user': + case 'entity.user.field_ui_form_display': return '' . t('This form lets administrators configure how form fields should be displayed when editing a user profile.') . '
'; - case 'field_ui.display_overview_user': + case 'entity.node.field_ui_display': return '' . t('This form lets administrators configure how fields should be displayed when rendering a user profile page.') . '
'; } } diff --git a/core/modules/views_ui/views_ui.module b/core/modules/views_ui/views_ui.module index 7bf6e71..e9837eb 100644 --- a/core/modules/views_ui/views_ui.module +++ b/core/modules/views_ui/views_ui.module @@ -54,14 +54,14 @@ function views_ui_entity_type_build(array &$entity_types) { ->setFormClass('delete', 'Drupal\views_ui\ViewDeleteForm') ->setFormClass('break_lock', 'Drupal\views_ui\Form\BreakLockForm') ->setListBuilderClass('Drupal\views_ui\ViewListBuilder') - ->setLinkTemplate('edit-form', 'entity.view.edit_form') - ->setLinkTemplate('edit-display-form', 'entity.view.edit_display_form') - ->setLinkTemplate('preview-form', 'entity.view.preview_form') - ->setLinkTemplate('duplicate-form', 'entity.view.duplicate_form') - ->setLinkTemplate('delete-form', 'entity.view.delete_form') - ->setLinkTemplate('enable', 'entity.view.enable') - ->setLinkTemplate('disable', 'entity.view.disable') - ->setLinkTemplate('break-lock-form', 'entity.view.break_lock_form'); + ->setLinkTemplate('edit-form', '/admin/structure/views/view/{view}') + ->setLinkTemplate('edit-display-form', '/admin/structure/views/view/{view}/edit/{display_id}') + ->setLinkTemplate('preview-form', '/admin/structure/views/view/{view}/preview/{display_id}') + ->setLinkTemplate('duplicate-form', '/admin/structure/views/view/{view}/duplicate') + ->setLinkTemplate('delete-form', '/admin/structure/views/view/{view}/delete') + ->setLinkTemplate('enable', '/admin/structure/views/view/{view}/enable') + ->setLinkTemplate('disable', '/admin/structure/views/view/{view}/disable') + ->setLinkTemplate('break-lock-form', '/admin/structure/views/view/{view}/break-lock'); } /** diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php index c6d70ce..c4ae0b6 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php @@ -241,4 +241,14 @@ protected function getTestHandlerClass() { return get_class($this->getMockForAbstractClass('Drupal\Core\Entity\EntityHandlerBase')); } + /** + * @covers ::setLinkTemplate + * + * @expectedException \InvalidArgumentException + */ + public function testSetLinkTemplateWithInvalidPath() { + $entity_type = $this->setUpEntityType(['id' => $this->randomMachineName()]); + $entity_type->setLinkTemplate('test', 'invalid-path'); + } + } diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php index ba6f046..9a70b9f 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php @@ -65,10 +65,10 @@ public function testUrlInfo($entity_class, $link_template, $expected) { */ public function providerTestUrlInfo() { return array( - array('Drupal\Core\Entity\Entity', 'edit-form', 'test_entity_type.edit'), - array('Drupal\Core\Config\Entity\ConfigEntityBase', 'edit-form', 'test_entity_type.edit'), + array('Drupal\Core\Entity\Entity', 'edit-form', 'entity.test_entity_type.edit_form'), + array('Drupal\Core\Config\Entity\ConfigEntityBase', 'edit-form', 'entity.test_entity_type.edit_form'), // Test that overriding the default $rel parameter works. - array('Drupal\Core\Config\Entity\ConfigEntityBase', FALSE, 'test_entity_type.edit'), + array('Drupal\Core\Config\Entity\ConfigEntityBase', FALSE, 'entity.test_entity_type.edit_form'), ); } @@ -181,13 +181,13 @@ public function testUrl() { ->method('generateFromRoute') ->will($this->returnValueMap(array( array( - 'test_entity_type.view', + 'entity.test_entity_type.canonical', array('test_entity_type' => 'test_entity_id'), array('entity_type' => 'test_entity_type', 'entity' => $valid_entity), '/entity/test_entity_type/test_entity_id', ), array( - 'test_entity_type.view', + 'entity.test_entity_type.canonical', array('test_entity_type' => 'test_entity_id'), array('absolute' => TRUE, 'entity_type' => 'test_entity_type', 'entity' => $valid_entity), 'http://drupal/entity/test_entity_type/test_entity_id', @@ -208,7 +208,7 @@ public function testGetSystemPath() { $entity_type->expects($this->exactly(3)) ->method('getLinkTemplates') ->will($this->returnValue(array( - 'canonical' => 'test_entity_type.view', + 'canonical' => 'entity.test_entity_type.canonical', ))); $this->entityManager @@ -222,7 +222,7 @@ public function testGetSystemPath() { $this->urlGenerator->expects($this->once()) ->method('getPathFromRoute') - ->with('test_entity_type.view', array('test_entity_type' => 'test_entity_id')) + ->with('entity.test_entity_type.canonical', array('test_entity_type' => 'test_entity_id')) ->will($this->returnValue('entity/test_entity_type/test_entity_id')); $valid_entity = $this->getMockForAbstractClass('Drupal\Core\Entity\Entity', array(array('id' => 'test_entity_id'), 'test_entity_type'));