diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index ba7380a..cb1572b 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -156,8 +156,9 @@ public function urlInfo($rel = 'canonical') { $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(); @@ -215,7 +216,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 route names (temporary) or paths. */ protected function linkTemplates() { return $this->getEntityType()->getLinkTemplates(); diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index e3acce9..04c72ed 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -315,6 +315,20 @@ public function getHandler($entity_type, $handler_type) { /** * {@inheritdoc} */ + public function getAdminRouteInfo($entity_type_id, $bundle) { + if (($entity_type = $this->getDefinition($entity_type_id, FALSE)) && $entity_type->getLinkTemplate('admin-form')) { + return array( + 'route_name' => "entity.$entity_type_id.admin_form", + 'route_parameters' => array( + $entity_type->getBundleEntityType() => $bundle, + ), + ); + } + } + + /** + * {@inheritdoc} + */ public function getBaseFieldDefinitions($entity_type_id) { // Check the static cache. if (!isset($this->baseFieldDefinitions[$entity_type_id])) { diff --git a/core/lib/Drupal/Core/Entity/EntityType.php b/core/lib/Drupal/Core/Entity/EntityType.php index 79c092e..b104bba 100644 --- a/core/lib/Drupal/Core/Entity/EntityType.php +++ b/core/lib/Drupal/Core/Entity/EntityType.php @@ -533,8 +533,8 @@ public function hasLinkTemplate($key) { /** * {@inheritdoc} */ - public function setLinkTemplate($key, $route_name) { - $this->links[$key] = $route_name; + public function setLinkTemplate($key, $path) { + $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 7e8662b..862c573 100644 --- a/core/lib/Drupal/Core/Entity/EntityTypeInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityTypeInterface.php @@ -440,7 +440,8 @@ public function getLinkTemplates(); * The link type. * * @return string|bool - * The route name for this link, or FALSE if it doesn't exist. + * The route name (temporary) or path for this link, or FALSE if it doesn't + * exist. */ public function getLinkTemplate($key); @@ -460,12 +461,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 name (temporary) or path to use for the link. * * @return static */ - public function setLinkTemplate($key, $route_name); + public function setLinkTemplate($key, $path); /** * Gets the callback for the label of the entity. diff --git a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php index e1d0731..d6e9e71 100644 --- a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php +++ b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php @@ -179,7 +179,7 @@ public function clearCachedDefinitions() { * and would actually be returned by the getDefinitions() method. */ protected function getCachedDefinitions() { - if (!isset($this->definitions) && $this->cacheBackend && $cache = $this->cacheBackend->get($this->cacheKey)) { + if (FALSE && !isset($this->definitions) && $this->cacheBackend && $cache = $this->cacheBackend->get($this->cacheKey)) { $this->definitions = $cache->data; } return $this->definitions; diff --git a/core/modules/block_content/block_content.routing.yml b/core/modules/block_content/block_content.routing.yml index 1628b89..f13572a 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/book/book.links.task.yml b/core/modules/book/book.links.task.yml index 2ce18c6..2f6765e 100644 --- a/core/modules/book/book.links.task.yml +++ b/core/modules/book/book.links.task.yml @@ -8,8 +8,8 @@ book.settings: base_route: book.admin weight: 100 -book.outline: - route_name: book.outline +entity.node.book_outline_form: + route_name: entity.node.book_outline_form base_route: entity.node.canonical title: Outline weight: 2 diff --git a/core/modules/book/book.module b/core/modules/book/book.module index 5e87f43..ca97f5c 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -42,7 +42,7 @@ function book_help($route_name, RouteMatchInterface $route_match) { case 'book.admin': return '

' . t('The book module offers a means to organize a collection of related content pages, collectively known as a book. When viewed, this content automatically displays links to adjacent book pages, providing a simple navigation system for creating and reviewing structured content.') . '

'; - case 'book.outline': + case 'entity.node.book_outline_form': return '

' . t('The outline feature allows you to include pages in the Book hierarchy, as well as move them within the hierarchy or to reorder an entire book.', array('!book' => \Drupal::url('book.render'), '!book-admin' => \Drupal::url('book.admin'))) . '

'; } } @@ -110,7 +110,7 @@ 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', 'book.outline') + ->setLinkTemplate('book-outline-form', 'entity.node.book_outline_form') ->setLinkTemplate('book-remove-form', 'book.remove'); } diff --git a/core/modules/book/book.routing.yml b/core/modules/book/book.routing.yml index c365d01..13c0f10 100644 --- a/core/modules/book/book.routing.yml +++ b/core/modules/book/book.routing.yml @@ -30,7 +30,7 @@ book.export: _permission: 'access printer-friendly version' _entity_access: 'node.view' -book.outline: +entity.node.book_outline_form: path: '/node/{node}/outline' defaults: _entity_form: 'node.book_outline' @@ -51,7 +51,7 @@ book.admin_edit: _entity_access: 'node.view' node: \d+ -book.remove: +entity.node.book_remove_form: path: '/node/{node}/outline/remove' defaults: _form: '\Drupal\book\Form\BookRemoveForm' diff --git a/core/modules/book/tests/src/Unit/Menu/BookLocalTasksTest.php b/core/modules/book/tests/src/Unit/Menu/BookLocalTasksTest.php index 2e58f85..1702855 100644 --- a/core/modules/book/tests/src/Unit/Menu/BookLocalTasksTest.php +++ b/core/modules/book/tests/src/Unit/Menu/BookLocalTasksTest.php @@ -53,7 +53,7 @@ public function getBookAdminRoutes() { */ public function testBookNodeLocalTasks($route) { $this->assertLocalTasks($route, array( - 0 => array('book.outline', 'entity.node.canonical', 'entity.node.edit_form', 'entity.node.delete_form', 'entity.node.version_history',), + 0 => array('entity.node.book_outline_form', 'entity.node.canonical', 'entity.node.edit_form', 'entity.node.delete_form', 'entity.node.version_history',), )); } @@ -63,7 +63,7 @@ public function testBookNodeLocalTasks($route) { public function getBookNodeRoutes() { return array( array('entity.node.canonical'), - array('book.outline'), + array('entity.node.book_outline_form'), ); } diff --git a/core/modules/config_translation/config_translation.module b/core/modules/config_translation/config_translation.module index 43aa754..339e13e 100644 --- a/core/modules/config_translation/config_translation.module +++ b/core/modules/config_translation/config_translation.module @@ -103,7 +103,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('drupal:config-translation-overview', 'entity.' . $entity_type_id . '.config_translation_overview'); } } } @@ -162,9 +162,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, diff --git a/core/modules/config_translation/src/ConfigEntityMapper.php b/core/modules/config_translation/src/ConfigEntityMapper.php index ce66ff6..29770e3 100644 --- a/core/modules/config_translation/src/ConfigEntityMapper.php +++ b/core/modules/config_translation/src/ConfigEntityMapper.php @@ -241,6 +241,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/content_translation/src/Plugin/Derivative/ContentTranslationContextualLinks.php b/core/modules/content_translation/src/Plugin/Derivative/ContentTranslationContextualLinks.php index b1f424f..9afcd5f 100644 --- a/core/modules/content_translation/src/Plugin/Derivative/ContentTranslationContextualLinks.php +++ b/core/modules/content_translation/src/Plugin/Derivative/ContentTranslationContextualLinks.php @@ -53,7 +53,13 @@ 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'); + // @TODO What to do with this once link templates are paths again? + if (($link_template = $entity_type->getLinkTemplate('drupal:content-translation-overview')) && strpos($link_template, '/') !== FALSE) { + $this->derivatives[$entity_type_id]['route_name'] = "entity.$entity_type_id.content_translation_overview"; + } + else { + $this->derivatives[$entity_type_id]['route_name'] = $entity_type->getLinkTemplate('drupal: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 ce8bd57..a33b07b 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/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/FieldInstanceConfig.php b/core/modules/field/src/Entity/FieldInstanceConfig.php index 4a4239d..911bda7 100644 --- a/core/modules/field/src/Entity/FieldInstanceConfig.php +++ b/core/modules/field/src/Entity/FieldInstanceConfig.php @@ -258,12 +258,12 @@ public static function postDelete(EntityStorageInterface $storage, array $instan protected function linkTemplates() { $link_templates = parent::linkTemplates(); if (\Drupal::moduleHandler()->moduleExists('field_ui')) { - $link_templates['edit-form'] = 'field_ui.instance_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["field_ui.instance-{$this->entity_type}-edit-form"] = 'field_ui.instance_edit_' . $this->entity_type; + $link_templates["field_ui.storage-{$this->entity_type}-edit-form"] = 'field_ui.storage_edit_' . $this->entity_type; + $link_templates["field_ui.{$this->entity_type}-delete-form"] = 'field_ui.delete_' . $this->entity_type; if (isset($link_templates['drupal:config-translation-overview'])) { - $link_templates['drupal:config-translation-overview'] .= $link_templates['edit-form']; + $link_templates['drupal:config-translation-overview' . "field_ui.instance-{$this->entity_type}-edit-form"] .= $link_templates["field_ui.instance-{$this->entity_type}-edit-form"]; } } return $link_templates; diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module index 4cd3bce..1cce756 100644 --- a/core/modules/field_ui/field_ui.module +++ b/core/modules/field_ui/field_ui.module @@ -116,9 +116,9 @@ function field_ui_entity_type_build(array &$entity_types) { foreach ($entity_types as $entity_type) { if ($bundle = $entity_type->getBundleOf()) { $entity_type - ->setLinkTemplate('field_ui-fields', "field_ui.overview_$bundle") - ->setLinkTemplate('field_ui-form-display', "field_ui.form_display_overview_$bundle") - ->setLinkTemplate('field_ui-display', "field_ui.display_overview_$bundle"); + ->setLinkTemplate('field_ui-fields', "entity.{$entity_type->id()}.field_ui_fields") + ->setLinkTemplate('field_ui-form-display', "entity.{$entity_type->id()}.field_ui_form_display") + ->setLinkTemplate('field_ui-display', "entity.{$entity_type->id()}.field_ui_display"); } } } diff --git a/core/modules/field_ui/src/FieldInstanceConfigListBuilder.php b/core/modules/field_ui/src/FieldInstanceConfigListBuilder.php index 74252e0..2bdb042 100644 --- a/core/modules/field_ui/src/FieldInstanceConfigListBuilder.php +++ b/core/modules/field_ui/src/FieldInstanceConfigListBuilder.php @@ -62,11 +62,25 @@ public function getDefaultOperations(EntityInterface $entity) { /** @var \Drupal\field\FieldInstanceConfigInterface $entity */ $operations = parent::getDefaultOperations($entity); + if ($entity->access('update') && $entity->hasLinkTemplate("field_ui.instance-{$entity->entity_type}-edit-form")) { + $operations['edit'] = array( + 'title' => $this->t('Edit'), + 'weight' => 10, + ) + $entity->urlInfo("field_ui.instance-{$entity->entity_type}-edit-form")->toArray(); + } + if ($entity->access('delete') && $entity->hasLinkTemplate("field_ui.{$entity->entity_type}-delete-form")) { + $operations['delete'] = array( + 'title' => $this->t('Delete'), + 'weight' => 100, + ) + $entity->urlInfo("field_ui.{$entity->entity_type}-delete-form")->toArray(); + } + + $bundle = $this->entityManager->getDefinition($entity->entity_type)->getBundleEntityType(); $operations['storage-settings'] = array( 'title' => $this->t('Field settings'), 'weight' => 20, 'attributes' => array('title' => $this->t('Edit field settings.')), - ) + $entity->urlInfo('storage-edit-form')->toArray(); + ) + $entity->urlInfo("field_ui.storage-{$entity->entity_type}-edit-form")->toArray(); $operations['edit']['attributes']['title'] = $this->t('Edit instance settings.'); $operations['delete']['attributes']['title'] = $this->t('Delete instance.'); diff --git a/core/modules/field_ui/src/FieldOverview.php b/core/modules/field_ui/src/FieldOverview.php index 59088f0..aab6b60 100644 --- a/core/modules/field_ui/src/FieldOverview.php +++ b/core/modules/field_ui/src/FieldOverview.php @@ -135,7 +135,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $entity_t 'type' => array( '#type' => 'link', '#title' => $field_types[$field_storage->getType()]['label'], - '#route_name' => 'field_ui.storage_edit_' . $this->entity_type, + '#route_name' => "entity.field_instance_config.field_ui.storage_{$this->entity_type}_edit_form", '#route_parameters' => $route_parameters, '#options' => array('attributes' => array('title' => $this->t('Edit field settings.'))), ), @@ -410,8 +410,8 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $this->bundleEntityType => $this->bundle, 'field_instance_config' => $new_instance->id(), ); - $destinations[] = array('route_name' => 'field_ui.storage_edit_' . $this->entity_type, 'route_parameters' => $route_parameters); - $destinations[] = array('route_name' => 'field_ui.instance_edit_' . $this->entity_type, 'route_parameters' => $route_parameters); + $destinations[] = array('route_name' => "entity.field_instance_config.field_ui.storage_{$this->entity_type}_edit_form", 'route_parameters' => $route_parameters); + $destinations[] = array('route_name' => "entity.field_instance_config.field_ui.instance_{$this->entity_type}_edit_form", 'route_parameters' => $route_parameters); // Store new field information for any additional submit handlers. $form_state['fields_added']['_add_new_field'] = $values['field_name']; diff --git a/core/modules/field_ui/src/FieldUI.php b/core/modules/field_ui/src/FieldUI.php index 77ec651..e3f557e 100644 --- a/core/modules/field_ui/src/FieldUI.php +++ b/core/modules/field_ui/src/FieldUI.php @@ -29,7 +29,7 @@ class FieldUI { public static function getOverviewRouteInfo($entity_type_id, $bundle) { $entity_type = \Drupal::entityManager()->getDefinition($entity_type_id); if ($entity_type->get('field_ui_base_route')) { - return new Url("field_ui.overview_$entity_type_id", array( + return new Url("entity.{$entity_type->getBundleEntityType()}.field_ui_fields", array( $entity_type->getBundleEntityType() => $bundle, )); } diff --git a/core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalTask.php b/core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalTask.php index 758a98b..cfb6b0d 100644 --- a/core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalTask.php +++ b/core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalTask.php @@ -70,41 +70,42 @@ public function getDerivativeDefinitions($base_plugin_definition) { foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) { if ($entity_type->isFieldable() && $entity_type->get('field_ui_base_route')) { - $this->derivatives["overview_$entity_type_id"] = array( - 'route_name' => "field_ui.overview_$entity_type_id", + $field_entity_type = $entity_type->getBundleEntityType() ?: $entity_type_id; + $this->derivatives["overview_$field_entity_type"] = array( + 'route_name' => "entity.$field_entity_type.field_ui_fields", 'weight' => 1, 'title' => $this->t('Manage fields'), - 'base_route' => "field_ui.overview_$entity_type_id", + 'base_route' => "entity.$field_entity_type.field_ui_fields", ); // 'Manage form display' tab. - $this->derivatives["form_display_overview_$entity_type_id"] = array( - 'route_name' => "field_ui.form_display_overview_$entity_type_id", + $this->derivatives["form_display_overview_$field_entity_type"] = array( + 'route_name' => "entity.{$field_entity_type}.field_ui_form_display", 'weight' => 2, 'title' => $this->t('Manage form display'), - 'base_route' => "field_ui.overview_$entity_type_id", + 'base_route' => "entity.$field_entity_type.field_ui_fields", ); // 'Manage display' tab. - $this->derivatives["display_overview_$entity_type_id"] = array( - 'route_name' => "field_ui.display_overview_$entity_type_id", + $this->derivatives["display_overview_$field_entity_type"] = array( + 'route_name' => "entity.{$field_entity_type}.field_ui_display", 'weight' => 3, 'title' => $this->t('Manage display'), - 'base_route' => "field_ui.overview_$entity_type_id", + 'base_route' => "entity.$field_entity_type.field_ui_fields", ); // Field instance edit tab. - $this->derivatives["instance_edit_$entity_type_id"] = array( - 'route_name' => "field_ui.instance_edit_$entity_type_id", + $this->derivatives["instance_edit_$field_entity_type"] = array( + 'route_name' => "field_ui.instance_edit_$field_entity_type", 'title' => $this->t('Edit'), - 'base_route' => "field_ui.instance_edit_$entity_type_id", + 'base_route' => "field_ui.instance_edit_$field_entity_type", ); // Field settings tab. - $this->derivatives["field_edit_$entity_type_id"] = array( - 'route_name' => "field_ui.storage_edit_$entity_type_id", + $this->derivatives["field_edit_$field_entity_type"] = array( + 'route_name' => "field_ui.storage_edit_$field_entity_type", 'title' => $this->t('Field settings'), - 'base_route' => "field_ui.instance_edit_$entity_type_id", + 'base_route' => "field_ui.instance_edit_$field_entity_type", ); // View and form modes secondary tabs. @@ -114,29 +115,29 @@ public function getDerivativeDefinitions($base_plugin_definition) { // modes available for customisation. So we define menu items for all // view modes, and use a route requirement to determine which ones are // actually visible for a given bundle. - $this->derivatives['field_form_display_default_' . $entity_type_id] = array( + $this->derivatives['field_form_display_default_' . $field_entity_type] = array( 'title' => 'Default', - 'route_name' => "field_ui.form_display_overview_$entity_type_id", - 'parent_id' => "field_ui.fields:form_display_overview_$entity_type_id", + 'route_name' => "entity.{$field_entity_type}.field_ui_form_display", + 'parent_id' => "field_ui.fields:form_display_overview_$field_entity_type", 'weight' => -1, ); - $this->derivatives['field_display_default_' . $entity_type_id] = array( + $this->derivatives['field_display_default_' . $field_entity_type] = array( 'title' => 'Default', - 'route_name' => "field_ui.display_overview_$entity_type_id", - 'parent_id' => "field_ui.fields:display_overview_$entity_type_id", + 'route_name' => "entity.{$field_entity_type}.field_ui_display", + 'parent_id' => "field_ui.fields:display_overview_$field_entity_type", 'weight' => -1, ); // One local task for each form mode. $weight = 0; foreach ($this->entityManager->getFormModes($entity_type_id) as $form_mode => $form_mode_info) { - $this->derivatives['field_form_display_' . $form_mode . '_' . $entity_type_id] = array( + $this->derivatives['field_form_display_' . $form_mode . '_' . $field_entity_type] = array( 'title' => $form_mode_info['label'], - 'route_name' => "field_ui.form_display_overview_form_mode_$entity_type_id", + 'route_name' => "field_ui.form_display_overview_form_mode_$field_entity_type", 'route_parameters' => array( 'form_mode_name' => $form_mode, ), - 'parent_id' => "field_ui.fields:form_display_overview_$entity_type_id", + 'parent_id' => "field_ui.fields:form_display_overview_$field_entity_type", 'weight' => $weight++, ); } @@ -144,13 +145,13 @@ public function getDerivativeDefinitions($base_plugin_definition) { // One local task for each view mode. $weight = 0; foreach ($this->entityManager->getViewModes($entity_type_id) as $view_mode => $form_mode_info) { - $this->derivatives['field_display_' . $view_mode . '_' . $entity_type_id] = array( + $this->derivatives['field_display_' . $view_mode . '_' . $field_entity_type] = array( 'title' => $form_mode_info['label'], - 'route_name' => "field_ui.display_overview_view_mode_$entity_type_id", + 'route_name' => "field_ui.display_overview_view_mode_$field_entity_type", 'route_parameters' => array( 'view_mode_name' => $view_mode, ), - 'parent_id' => "field_ui.fields:display_overview_$entity_type_id", + 'parent_id' => "field_ui.fields:display_overview_$field_entity_type", 'weight' => $weight++, ); } @@ -172,19 +173,20 @@ public function getDerivativeDefinitions($base_plugin_definition) { */ public function alterLocalTasks(&$local_tasks) { foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) { + $field_entity_type = $entity_type->getBundleEntityType() ?: $entity_type_id; if ($entity_type->isFieldable() && $route_name = $entity_type->get('field_ui_base_route')) { - $local_tasks["field_ui.fields:overview_$entity_type_id"]['base_route'] = $route_name; - $local_tasks["field_ui.fields:form_display_overview_$entity_type_id"]['base_route'] = $route_name; - $local_tasks["field_ui.fields:display_overview_$entity_type_id"]['base_route'] = $route_name; - $local_tasks["field_ui.fields:field_form_display_default_$entity_type_id"]['base_route'] = $route_name; - $local_tasks["field_ui.fields:field_display_default_$entity_type_id"]['base_route'] = $route_name; + $local_tasks["field_ui.fields:overview_$field_entity_type"]['base_route'] = $route_name; + $local_tasks["field_ui.fields:form_display_overview_$field_entity_type"]['base_route'] = $route_name; + $local_tasks["field_ui.fields:display_overview_$field_entity_type"]['base_route'] = $route_name; + $local_tasks["field_ui.fields:field_form_display_default_$field_entity_type"]['base_route'] = $route_name; + $local_tasks["field_ui.fields:field_display_default_$field_entity_type"]['base_route'] = $route_name; foreach ($this->entityManager->getFormModes($entity_type_id) as $form_mode => $form_mode_info) { - $local_tasks['field_ui.fields:field_form_display_' . $form_mode . '_' . $entity_type_id]['base_route'] = $route_name; + $local_tasks['field_ui.fields:field_form_display_' . $form_mode . '_' . $field_entity_type]['base_route'] = $route_name; } foreach ($this->entityManager->getViewModes($entity_type_id) as $view_mode => $form_mode_info) { - $local_tasks['field_ui.fields:field_display_' . $view_mode . '_' . $entity_type_id]['base_route'] = $route_name; + $local_tasks['field_ui.fields:field_display_' . $view_mode . '_' . $field_entity_type]['base_route'] = $route_name; } } } diff --git a/core/modules/field_ui/src/Routing/RouteSubscriber.php b/core/modules/field_ui/src/Routing/RouteSubscriber.php index 4b371ab..479a40d 100644 --- a/core/modules/field_ui/src/Routing/RouteSubscriber.php +++ b/core/modules/field_ui/src/Routing/RouteSubscriber.php @@ -64,7 +64,7 @@ protected function alterRoutes(RouteCollection $collection) { array('_entity_access' => 'field_instance_config.update'), $options ); - $collection->add("field_ui.instance_edit_$entity_type_id", $route); + $collection->add("entity.field_instance_config.field_ui.instance_{$entity_type_id}_edit_form", $route); $route = new Route( "$path/fields/{field_instance_config}/storage", @@ -72,7 +72,7 @@ protected function alterRoutes(RouteCollection $collection) { array('_entity_access' => 'field_instance_config.update'), $options ); - $collection->add("field_ui.storage_edit_$entity_type_id", $route); + $collection->add("entity.field_instance_config.field_ui.storage_{$entity_type_id}_edit_form", $route); $route = new Route( "$path/fields/{field_instance_config}/delete", @@ -80,7 +80,7 @@ protected function alterRoutes(RouteCollection $collection) { array('_entity_access' => 'field_instance_config.delete'), $options ); - $collection->add("field_ui.delete_$entity_type_id", $route); + $collection->add("entity.field_instance_config.field_ui.{$entity_type_id}_delete_form", $route); // If the entity type has no bundles, use the entity type. $defaults['entity_type_id'] = $entity_type_id; @@ -96,7 +96,7 @@ protected function alterRoutes(RouteCollection $collection) { array('_permission' => 'administer ' . $entity_type_id . ' fields'), $options ); - $collection->add("field_ui.overview_$entity_type_id", $route); + $collection->add("entity.$bundle_entity_type.field_ui_fields", $route); $route = new Route( "$path/form-display", @@ -107,7 +107,7 @@ protected function alterRoutes(RouteCollection $collection) { array('_field_ui_form_mode_access' => 'administer ' . $entity_type_id . ' form display'), $options ); - $collection->add("field_ui.form_display_overview_$entity_type_id", $route); + $collection->add("entity.{$bundle_entity_type}.field_ui_form_display", $route); $route = new Route( "$path/form-display/{form_mode_name}", @@ -118,7 +118,7 @@ protected function alterRoutes(RouteCollection $collection) { array('_field_ui_form_mode_access' => 'administer ' . $entity_type_id . ' form display'), $options ); - $collection->add("field_ui.form_display_overview_form_mode_$entity_type_id", $route); + $collection->add("field_ui.form_display_overview_form_mode_$bundle_entity_type", $route); $route = new Route( "$path/display", @@ -129,7 +129,7 @@ protected function alterRoutes(RouteCollection $collection) { array('_field_ui_view_mode_access' => 'administer ' . $entity_type_id . ' display'), $options ); - $collection->add("field_ui.display_overview_$entity_type_id", $route); + $collection->add("entity.{$bundle_entity_type}.field_ui_display", $route); $route = new Route( "$path/display/{view_mode_name}", @@ -140,7 +140,7 @@ protected function alterRoutes(RouteCollection $collection) { array('_field_ui_view_mode_access' => 'administer ' . $entity_type_id . ' display'), $options ); - $collection->add("field_ui.display_overview_view_mode_$entity_type_id", $route); + $collection->add("field_ui.display_overview_view_mode_$bundle_entity_type", $route); } } } diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 039c305..12f2888 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -165,8 +165,8 @@ function forum_entity_type_build(array &$entity_types) { $entity_types['taxonomy_term'] ->setFormClass('forum', 'Drupal\forum\Form\ForumForm') ->setFormClass('container', 'Drupal\forum\Form\ContainerForm') - ->setLinkTemplate('forum-delete-form', 'forum.delete') - ->setLinkTemplate('forum-edit-form', 'forum.edit_forum'); + ->setLinkTemplate('forum-delete-form', 'entity.taxonomy_term.forum_delete_form') + ->setLinkTemplate('forum-edit-form', 'entity.taxonomy_term.forum_edit_form'); } /** diff --git a/core/modules/forum/forum.routing.yml b/core/modules/forum/forum.routing.yml index aa21336..ac9d35d 100644 --- a/core/modules/forum/forum.routing.yml +++ b/core/modules/forum/forum.routing.yml @@ -1,4 +1,4 @@ -forum.delete: +entity.taxonomy_term.forum_delete_form: path: '/admin/structure/forum/delete/forum/{taxonomy_term}' defaults: _form: '\Drupal\forum\Form\DeleteForm' @@ -54,7 +54,7 @@ forum.edit_container: requirements: _permission: 'administer forums' -forum.edit_forum: +entity.taxonomy_term.forum_edit_form: path: '/admin/structure/forum/edit/forum/{taxonomy_term}' defaults: _entity_form: 'taxonomy_term.forum' diff --git a/core/modules/menu_link_content/menu_link_content.routing.yml b/core/modules/menu_link_content/menu_link_content.routing.yml index 20832e9..ac642bd 100644 --- a/core/modules/menu_link_content/menu_link_content.routing.yml +++ b/core/modules/menu_link_content/menu_link_content.routing.yml @@ -1,4 +1,4 @@ -entity.menu.add_link_form: +entity.menu.add_form: path: '/admin/structure/menu/manage/{menu}/add' defaults: _content: '\Drupal\menu_link_content\Controller\MenuController::addLink' diff --git a/core/modules/menu_ui/menu_ui.links.action.yml b/core/modules/menu_ui/menu_ui.links.action.yml index 848bcbe..d2feee0 100644 --- a/core/modules/menu_ui/menu_ui.links.action.yml +++ b/core/modules/menu_ui/menu_ui.links.action.yml @@ -1,5 +1,5 @@ -entity.menu.add_link_form: - route_name: entity.menu.add_link_form +entity.menu.add_form: + route_name: entity.menu.add_form title: 'Add link' class: \Drupal\menu_ui\Plugin\Menu\LocalAction\MenuLinkAdd appears_on: diff --git a/core/modules/menu_ui/menu_ui.module b/core/modules/menu_ui/menu_ui.module index 69c23e3..9f6e9f8 100644 --- a/core/modules/menu_ui/menu_ui.module +++ b/core/modules/menu_ui/menu_ui.module @@ -77,7 +77,7 @@ function menu_ui_entity_type_build(array &$entity_types) { ->setLinkTemplate('add-form', 'entity.menu.add_form') ->setLinkTemplate('delete-form', 'entity.menu.delete_form') ->setLinkTemplate('edit-form', 'entity.menu.edit_form') - ->setLinkTemplate('add-link-form', 'entity.menu.add_link_form'); + ->setLinkTemplate('add-link-form', 'entity.menu.add_form'); } diff --git a/core/modules/menu_ui/src/MenuForm.php b/core/modules/menu_ui/src/MenuForm.php index fde70bb..ab86985 100644 --- a/core/modules/menu_ui/src/MenuForm.php +++ b/core/modules/menu_ui/src/MenuForm.php @@ -240,7 +240,7 @@ protected function buildOverviewForm(array &$form, FormStateInterface $form_stat $form = array_merge($form, $this->buildOverviewTreeForm($tree, $delta)); $destination = $this->getUrlGenerator()->getPathFromRoute('entity.menu.edit_form', array('menu' => $this->entity->id())); - $url = $destination = $this->url('entity.menu.add_link_form', array('menu' => $this->entity->id()), array('query' => array('destination' => $destination))); + $url = $destination = $this->url('entity.add_form', array('menu' => $this->entity->id()), array('query' => array('destination' => $destination))); $form['#empty_text'] = $this->t('There are no menu links yet. Add link.', array('@url' => $url)); return $form; diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 99f3aee..1a1f131 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -127,12 +127,12 @@ function node_help($route_name, RouteMatchInterface $route_match) { case 'node.type_add': return '

' . 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/rest/src/Plugin/Derivative/EntityDerivative.php b/core/modules/rest/src/Plugin/Derivative/EntityDerivative.php index 5b17bc6..bfb0e35 100644 --- a/core/modules/rest/src/Plugin/Derivative/EntityDerivative.php +++ b/core/modules/rest/src/Plugin/Derivative/EntityDerivative.php @@ -109,7 +109,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/2158571 try { diff --git a/core/modules/shortcut/shortcut.routing.yml b/core/modules/shortcut/shortcut.routing.yml index 6a892bd..c3ce8ad 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/system/tests/modules/entity_test/src/Entity/EntityTestMul.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestMul.php index fa66635..eb71fce 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 @@ -37,7 +37,7 @@ * "label" = "name" * }, * links = { - * "canonical" = "entity.entity_test_mul.edit_form", + * "canonical" = "entity.entity_test_mul.canonical", * "edit-form" = "entity.entity_test_mul.edit_form", * "delete-form" = "entity.entity_test_mul.delete_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 50afa32..0d11126 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 @@ -38,7 +38,7 @@ * "bundle" = "type" * }, * links = { - * "canonical" = "entity.entity_test_mulrev.edit_form", + * "canonical" = "entity.entity_test_mulrev.canonical", * "delete-form" = "entity.entity_test_mulrev.delete_form", * "edit-form" = "entity.entity_test_mulrev.edit_form" * } 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 ebb39f2..3f98239 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 @@ -36,7 +36,7 @@ * "label" = "name", * }, * links = { - * "canonical" = "entity.entity_test_rev.edit_form", + * "canonical" = "entity.entity_test_rev.canonical", * "delete-form" = "entity.entity_test_rev.delete_form", * "edit-form" = "entity.entity_test_rev.edit_form" * } 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 5902b09..8e4985d 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 @@ -33,6 +33,15 @@ public function routes() { array('_permission' => 'administer entity_test content') ); + $routes["entity.$entity_type.canonical"] = new Route( + "$entity_type/manage/{" . $entity_type . '}', + array('_content' => '\Drupal\entity_test\Controller\EntityTestController::testEdit', '_entity_type' => $entity_type), + array('_permission' => 'administer entity_test content'), + array('parameters' => array( + $entity_type => array('type' => 'entity:' . $entity_type), + )) + ); + $routes["entity.$entity_type.edit_form"] = new Route( "$entity_type/manage/{" . $entity_type . '}', array('_content' => '\Drupal\entity_test\Controller\EntityTestController::testEdit', '_entity_type' => $entity_type), diff --git a/core/modules/user/user.module b/core/modules/user/user.module index e7afb5a..dd62c6b 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/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php index 4787e62..9091dd4 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'));