Commit 5a06f7b2 authored by alexpott's avatar alexpott

Issue #2276387 by Gábor Hojtsy, vijaycs85: Fixed Translate routes should...

Issue #2276387 by Gábor Hojtsy, vijaycs85: Fixed Translate routes should properly inherit admin path use from edit route.
parent f309e651
......@@ -46,8 +46,14 @@ protected function alterRoutes(RouteCollection $collection) {
}
$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'))) {
$is_admin = (bool) $edit_route->getOption('_admin_route');
}
$route = new Route(
$path,
$path,
array(
'_content' => '\Drupal\content_translation\Controller\ContentTranslationController::overview',
'_entity_type_id' => $entity_type_id,
......@@ -63,6 +69,7 @@ protected function alterRoutes(RouteCollection $collection) {
'type' => 'entity:' . $entity_type_id,
),
),
'_admin_route' => $is_admin,
)
);
$collection->add($entity_type->getLinkTemplate('drupal:content-translation-overview'), $route);
......@@ -88,6 +95,7 @@ protected function alterRoutes(RouteCollection $collection) {
'type' => 'entity:' . $entity_type_id,
),
),
'_admin_route' => $is_admin,
)
);
$collection->add("content_translation.translation_add_$entity_type_id", $route);
......@@ -111,6 +119,7 @@ protected function alterRoutes(RouteCollection $collection) {
'type' => 'entity:' . $entity_type_id,
),
),
'_admin_route' => $is_admin,
)
);
$collection->add("content_translation.translation_edit_$entity_type_id", $route);
......@@ -134,6 +143,7 @@ protected function alterRoutes(RouteCollection $collection) {
),
),
'_access_mode' => 'ANY',
'_admin_route' => $is_admin,
)
);
$collection->add("content_translation.delete_$entity_type_id", $route);
......
......@@ -70,7 +70,7 @@ protected function getEditorPermissions() {
* {@inheritdoc}
*/
protected function getAdministratorPermissions() {
return array_merge(parent::getAdministratorPermissions(), array('access administration pages', 'administer content types', 'administer node fields', 'access content overview', 'bypass node access', 'administer languages'));
return array_merge(parent::getAdministratorPermissions(), array('access administration pages', 'administer content types', 'administer node fields', 'access content overview', 'bypass node access', 'administer languages', 'administer themes', 'view the administration theme'));
}
/**
......@@ -195,6 +195,29 @@ function testTranslateLinkContentAdminPage() {
$this->assertNoLinkByHref('node/' . $page->id() . '/translations');
}
/**
* Tests that translation page inherits admin status of edit page.
*/
function testTranslationLinkTheme() {
$this->drupalLogin($this->administrator);
$article = $this->drupalCreateNode(array('type' => 'article', 'langcode' => $this->langcodes[0]));
// Set up Seven as the admin theme and use it for node editing.
$this->container->get('theme_handler')->enable(array('seven'));
$edit = array();
$edit['admin_theme'] = 'seven';
$edit['use_admin_theme'] = TRUE;
$this->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
$this->drupalGet('node/' . $article->id() . '/translations');
$this->assertRaw('"theme":"seven"', 'Translation uses admin theme if edit is admin.');
// Turn off admin theme for editing, assert inheritance to translations.
$edit['use_admin_theme'] = FALSE;
$this->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
$this->drupalGet('node/' . $article->id() . '/translations');
$this->assertNoRaw('"theme":"seven"', 'Translation uses frontend theme if edit is frontend.');
}
/**
* Tests that no metadata is stored for a disabled bundle.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment