diff --git a/core/modules/comment/comment.local_tasks.yml b/core/modules/comment/comment.local_tasks.yml index 1c0c901..3119823 100644 --- a/core/modules/comment/comment.local_tasks.yml +++ b/core/modules/comment/comment.local_tasks.yml @@ -1,14 +1,14 @@ comment.permalink_tab: - route_name: comment_permalink + route_name: comment.permalink title: 'View comment' tab_root_id: comment.permalink_tab comment.edit_page_tab: - route_name: comment_edit_page + route_name: comment.edit_page title: 'Edit' tab_root_id: comment.permalink_tab weight: 0 comment.confirm_delete_tab: - route_name: comment_confirm_delete + route_name: comment.confirm_delete title: 'Delete' tab_root_id: comment.permalink_tab weight: 10 diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 64d1e1a..1081ed4 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -223,32 +223,6 @@ function comment_menu() { 'route_name' => 'comment.admin_approval', 'type' => MENU_LOCAL_TASK, ); - $items['comment/%comment'] = array( - 'title' => 'Comment permalink', - 'route_name' => 'comment.permalink', - ); - $items['comment/%comment/view'] = array( - 'title' => 'View comment', - 'type' => MENU_DEFAULT_LOCAL_TASK, - ); - // Every other comment path uses %, but this one loads the comment directly, - // so we don't end up loading it twice (in the page and access callback). - $items['comment/%comment/edit'] = array( - 'title' => 'Edit', - 'type' => MENU_LOCAL_TASK, - 'route_name' => 'comment.edit_page', - ); - $items['comment/%comment/approve'] = array( - 'title' => 'Approve', - 'weight' => 10, - 'route_name' => 'comment.approve', - ); - $items['comment/%comment/delete'] = array( - 'title' => 'Delete', - 'type' => MENU_LOCAL_TASK, - 'route_name' => 'comment.confirm_delete', - 'weight' => 20, - ); return $items; } diff --git a/core/modules/comment/comment.routing.yml b/core/modules/comment/comment.routing.yml index a61e8c1..e2343fb 100644 --- a/core/modules/comment/comment.routing.yml +++ b/core/modules/comment/comment.routing.yml @@ -19,6 +19,7 @@ comment.admin_approval: comment.edit_page: path: '/comment/{comment}/edit' defaults: + _title: 'Edit' _entity_form: 'comment.default' requirements: _entity_access: 'comment.update' @@ -26,6 +27,7 @@ comment.edit_page: comment.approve: path: '/comment/{comment}/approve' defaults: + _title: 'Approve' _content: '\Drupal\comment\Controller\CommentController::commentApprove' entity_type: 'comment' requirements: @@ -34,6 +36,7 @@ comment.approve: comment.permalink: path: '/comment/{comment}' defaults: + _title: 'Comment permalink' _controller: '\Drupal\comment\Controller\CommentController::commentPermalink' requirements: _entity_access: 'comment.view' @@ -41,6 +44,7 @@ comment.permalink: comment.confirm_delete: path: '/comment/{comment}/delete' defaults: + _title: 'Delete' _entity_form: 'comment.delete' requirements: _entity_access: 'comment.delete' diff --git a/core/modules/content_translation/content_translation.pages.inc b/core/modules/content_translation/content_translation.pages.inc index 552c87b..6bb8d98 100644 --- a/core/modules/content_translation/content_translation.pages.inc +++ b/core/modules/content_translation/content_translation.pages.inc @@ -68,7 +68,7 @@ function content_translation_overview(EntityInterface $entity) { // Existing translation in the translation set: display status. $source = isset($entity->translation[$langcode]['source']) ? $entity->translation[$langcode]['source'] : ''; $is_original = $langcode == $original; - $label = $entity->label($langcode); + $label = $entity->getTranslation($langcode)->label(); $link = isset($links->links[$langcode]['href']) ? $links->links[$langcode] : array('href' => $path, 'language' => $language); $row_title = l($label, $link['href'], $link); diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationManageAccessCheck.php b/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationManageAccessCheck.php index 3a53710..330e21d 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationManageAccessCheck.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationManageAccessCheck.php @@ -46,10 +46,10 @@ public function appliesTo() { * {@inheritdoc} */ public function access(Route $route, Request $request) { - if ($entity = $request->attributes->get('entity')) { + $entity_type = $request->attributes->get('_entity_type'); + if ($entity = $request->attributes->get($entity_type)) { $route_requirements = $route->getRequirements(); $operation = $route_requirements['_access_content_translation_manage']; - $entity_type = $entity->entityType(); $controller_class = $this->entityManager->getControllerClass($entity_type, 'translation'); $controller = new $controller_class($entity_type, $entity->entityInfo()); diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationOverviewAccess.php b/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationOverviewAccess.php index 116e9c5..60a4214 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationOverviewAccess.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationOverviewAccess.php @@ -45,9 +45,9 @@ public function appliesTo() { * {@inheritdoc} */ public function access(Route $route, Request $request) { - if ($entity = $request->attributes->get('entity')) { + $entity_type = $request->attributes->get('_entity_type'); + if ($entity = $request->attributes->get($entity_type)) { // Get entity base info. - $entity_type = $entity->entityType(); $bundle = $entity->bundle(); // Get account details from request. diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Controller/ContentTranslationController.php b/core/modules/content_translation/lib/Drupal/content_translation/Controller/ContentTranslationController.php index ec229e1..0550bde 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Controller/ContentTranslationController.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Controller/ContentTranslationController.php @@ -7,7 +7,7 @@ namespace Drupal\content_translation\Controller; -use Drupal\Core\Entity\EntityInterface; +use Symfony\Component\HttpFoundation\Request; /** * Base class for entity translation controllers. @@ -17,7 +17,8 @@ class ContentTranslationController { /** * @todo Remove content_translation_overview(). */ - public function overview(EntityInterface $entity) { + public function overview(Request $request) { + $entity = $request->attributes->get($request->attributes->get('_entity_type')); module_load_include('pages.inc', 'content_translation'); return content_translation_overview($entity); } @@ -25,7 +26,8 @@ public function overview(EntityInterface $entity) { /** * @todo Remove content_translation_add_page(). */ - public function add(EntityInterface $entity, $source, $target) { + public function add(Request $request, $source, $target) { + $entity = $request->attributes->get($request->attributes->get('_entity_type')); module_load_include('pages.inc', 'content_translation'); $source = language_load($source); $target = language_load($target); @@ -35,7 +37,8 @@ public function add(EntityInterface $entity, $source, $target) { /** * @todo Remove content_translation_edit_page(). */ - public function edit(EntityInterface $entity, $language) { + public function edit(Request $request, $language) { + $entity = $request->attributes->get($request->attributes->get('_entity_type')); module_load_include('pages.inc', 'content_translation'); $language = language_load($language); return content_translation_edit_page($entity, $language); diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Form/ContentTranslationForm.php b/core/modules/content_translation/lib/Drupal/content_translation/Form/ContentTranslationForm.php index 7142a49..4ec42ba 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Form/ContentTranslationForm.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Form/ContentTranslationForm.php @@ -6,8 +6,8 @@ namespace Drupal\content_translation\Form; -use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Language\Language; +use Symfony\Component\HttpFoundation\Request; /** * Temporary form controller for content_translation module. @@ -19,7 +19,8 @@ class ContentTranslationForm { * * @todo Remove content_translation_delete_confirm(). */ - public function deleteTranslation(EntityInterface $entity, $language) { + public function deleteTranslation(Request $request, $language) { + $entity = $request->attributes->get($request->attributes->get('_entity_type')); module_load_include('pages.inc', 'content_translation'); $language = language_load($language); return drupal_get_form('content_translation_delete_confirm', $entity, $language); diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Routing/ContentTranslationRouteSubscriber.php b/core/modules/content_translation/lib/Drupal/content_translation/Routing/ContentTranslationRouteSubscriber.php index 622fd83..cb4858c 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Routing/ContentTranslationRouteSubscriber.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Routing/ContentTranslationRouteSubscriber.php @@ -50,13 +50,14 @@ public function routes(RouteBuildEvent $event) { $collection = $event->getRouteCollection(); foreach ($this->entityManager->getDefinitions() as $entity_type => $entity_info) { if ($entity_info['translatable'] && isset($entity_info['translation'])) { - $path = '/' . str_replace($entity_info['menu_path_wildcard'], '{entity}', $entity_info['menu_base_path']) . '/translations'; + $path = '/' . str_replace($entity_info['menu_path_wildcard'], '{' . $entity_type . '}', $entity_info['menu_base_path']) . '/translations'; $route = new Route( $path, array( '_content' => '\Drupal\content_translation\Controller\ContentTranslationController::overview', '_title' => 'Translate', 'account' => 'NULL', + '_entity_type' => $entity_type, ), array( '_access_content_translation_overview' => $entity_type, @@ -80,6 +81,7 @@ public function routes(RouteBuildEvent $event) { 'source' => NULL, 'target' => NULL, '_title' => 'Add', + '_entity_type' => $entity_type, ), array( @@ -103,6 +105,7 @@ public function routes(RouteBuildEvent $event) { '_content' => '\Drupal\content_translation\Controller\ContentTranslationController::edit', 'language' => NULL, '_title' => 'Edit', + '_entity_type' => $entity_type, ), array( '_permission' => 'translate any entity', @@ -125,6 +128,7 @@ public function routes(RouteBuildEvent $event) { '_content' => '\Drupal\content_translation\Form\ContentTranslationForm::deleteTranslation', 'language' => NULL, '_title' => 'Delete', + '_entity_type' => $entity_type, ), array( '_permission' => 'translate any entity', diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php index 956e6dd..21c8465 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php @@ -35,6 +35,7 @@ */ function testTranslationUI() { $this->assertBasicTranslation(); + $this->doTestTranslationOverview(); $this->assertOutdatedStatus(); $this->assertPublishedStatus(); $this->assertAuthoringInfo(); @@ -99,6 +100,21 @@ protected function assertBasicTranslation() { } /** + * Tests that the translation overview shows the correct values. + */ + protected function doTestTranslationOverview() { + $entity = entity_load($this->entityType, $this->entityId, TRUE); + $path = $this->controller->getBasePath($entity) . '/translations'; + $this->drupalGet($path); + + foreach ($this->langcodes as $langcode) { + if ($entity->hasTranslation($langcode)) { + $this->assertText($entity->getTranslation($langcode)->label(), format_string('Label correctly shown for %language translation', array('%language' => $langcode))); + } + } + } + + /** * Tests up-to-date status tracking. */ protected function assertOutdatedStatus() { diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTestMul.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTestMul.php index 81c251d..76db7ab 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTestMul.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTestMul.php @@ -33,7 +33,8 @@ * entity_keys = { * "id" = "id", * "uuid" = "uuid", - * "bundle" = "type" + * "bundle" = "type", + * "label" = "name" * }, * menu_base_path = "entity_test_mul/manage/%entity_test_mul", * route_base_path = "entity_test_mul/structure/{bundle}"