Issue #2106349 by plach, dawehner, Gábor Hojtsy: Fixed Comment translation overview has broken local tasks.
parent
396d402306
commit
db6985bae4
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -46,10 +46,10 @@ class ContentTranslationManageAccessCheck implements StaticAccessCheckInterface
|
|||
* {@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());
|
||||
|
||||
|
|
|
@ -45,9 +45,9 @@ class ContentTranslationOverviewAccess implements StaticAccessCheckInterface {
|
|||
* {@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.
|
||||
|
|
|
@ -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 @@ class ContentTranslationController {
|
|||
/**
|
||||
* @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 @@ class ContentTranslationController {
|
|||
/**
|
||||
* @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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -50,13 +50,14 @@ class ContentTranslationRouteSubscriber implements EventSubscriberInterface {
|
|||
$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 @@ class ContentTranslationRouteSubscriber implements EventSubscriberInterface {
|
|||
'source' => NULL,
|
||||
'target' => NULL,
|
||||
'_title' => 'Add',
|
||||
'_entity_type' => $entity_type,
|
||||
|
||||
),
|
||||
array(
|
||||
|
@ -103,6 +105,7 @@ class ContentTranslationRouteSubscriber implements EventSubscriberInterface {
|
|||
'_content' => '\Drupal\content_translation\Controller\ContentTranslationController::edit',
|
||||
'language' => NULL,
|
||||
'_title' => 'Edit',
|
||||
'_entity_type' => $entity_type,
|
||||
),
|
||||
array(
|
||||
'_permission' => 'translate any entity',
|
||||
|
@ -125,6 +128,7 @@ class ContentTranslationRouteSubscriber implements EventSubscriberInterface {
|
|||
'_content' => '\Drupal\content_translation\Form\ContentTranslationForm::deleteTranslation',
|
||||
'language' => NULL,
|
||||
'_title' => 'Delete',
|
||||
'_entity_type' => $entity_type,
|
||||
),
|
||||
array(
|
||||
'_permission' => 'translate any entity',
|
||||
|
|
|
@ -35,6 +35,7 @@ abstract class ContentTranslationUITest extends ContentTranslationTestBase {
|
|||
*/
|
||||
function testTranslationUI() {
|
||||
$this->assertBasicTranslation();
|
||||
$this->doTestTranslationOverview();
|
||||
$this->assertOutdatedStatus();
|
||||
$this->assertPublishedStatus();
|
||||
$this->assertAuthoringInfo();
|
||||
|
@ -98,6 +99,21 @@ abstract class ContentTranslationUITest extends ContentTranslationTestBase {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
|
|
@ -33,7 +33,8 @@ use Drupal\Core\Annotation\Translation;
|
|||
* 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}"
|
||||
|
|
Loading…
Reference in New Issue