Skip to content
Snippets Groups Projects
Commit f451e3d9 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2188915 by tim.plunkett: Stop appending paths to Entity::getSystemPath().

parent 07b878de
No related branches found
No related tags found
No related merge requests found
...@@ -85,21 +85,29 @@ function config_translation_theme() { ...@@ -85,21 +85,29 @@ function config_translation_theme() {
} }
/** /**
* Implements hook_entity_info(). * Implements hook_entity_info_alter().
*/ */
function config_translation_entity_info($entity_info) { function config_translation_entity_info_alter($entity_info) {
/** @var $entity_info \Drupal\Core\Entity\EntityTypeInterface[] */ /** @var $entity_info \Drupal\Core\Entity\EntityTypeInterface[] */
foreach ($entity_info as $entity_type_id => $entity_type) { foreach ($entity_info as $entity_type_id => $entity_type) {
if ($entity_type_id == 'block') { if ($entity_type->isSubclassOf('Drupal\Core\Config\Entity\ConfigEntityInterface')) {
$class = 'Drupal\config_translation\Controller\ConfigTranslationBlockListController'; if ($entity_type_id == 'block') {
} $class = 'Drupal\config_translation\Controller\ConfigTranslationBlockListController';
elseif ($entity_type_id == 'field_instance') { }
$class = 'Drupal\config_translation\Controller\ConfigTranslationFieldInstanceListController'; elseif ($entity_type_id == 'field_instance') {
} $class = 'Drupal\config_translation\Controller\ConfigTranslationFieldInstanceListController';
else { // Will be filled in dynamically, see \Drupal\field\Entity\FieldInstance::linkTemplates().
$class = 'Drupal\config_translation\Controller\ConfigTranslationEntityListController'; $entity_type->setLinkTemplate('drupal:config-translation-overview', 'config_translation.item.overview.');
}
else {
$class = 'Drupal\config_translation\Controller\ConfigTranslationEntityListController';
}
$entity_type->setControllerClass('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->setControllerClass('config_translation_list', $class);
} }
} }
...@@ -169,13 +177,10 @@ function config_translation_config_translation_info(&$info) { ...@@ -169,13 +177,10 @@ function config_translation_config_translation_info(&$info) {
*/ */
function config_translation_entity_operation_alter(array &$operations, EntityInterface $entity) { function config_translation_entity_operation_alter(array &$operations, EntityInterface $entity) {
if (\Drupal::currentUser()->hasPermission('translate configuration')) { if (\Drupal::currentUser()->hasPermission('translate configuration')) {
$uri = $entity->urlInfo();
$operations['translate'] = array( $operations['translate'] = array(
'title' => t('Translate'), 'title' => t('Translate'),
'href' => $entity->getSystemPath() . '/translate',
'options' => $uri['options'],
'weight' => 50, 'weight' => 50,
); ) + $entity->urlInfo('drupal:config-translation-overview');
} }
} }
......
...@@ -64,7 +64,7 @@ protected function renderLink(EntityInterface $entity, ResultRow $values) { ...@@ -64,7 +64,7 @@ protected function renderLink(EntityInterface $entity, ResultRow $values) {
$text = !empty($this->options['text']) ? $this->options['text'] : t('translate'); $text = !empty($this->options['text']) ? $this->options['text'] : t('translate');
$this->options['alter']['make_link'] = TRUE; $this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = $entity->getSystemPath() . '/translations'; $this->options['alter']['path'] = $entity->getSystemPath('drupal:content-translation-overview');
return $text; return $text;
} }
......
...@@ -511,6 +511,9 @@ protected function linkTemplates() { ...@@ -511,6 +511,9 @@ protected function linkTemplates() {
$link_templates = parent::linkTemplates(); $link_templates = parent::linkTemplates();
if (\Drupal::moduleHandler()->moduleExists('field_ui')) { if (\Drupal::moduleHandler()->moduleExists('field_ui')) {
$link_templates['edit-form'] = 'field_ui.instance_edit_' . $this->entity_type; $link_templates['edit-form'] = 'field_ui.instance_edit_' . $this->entity_type;
if (isset($link_templates['drupal:config-translation-overview'])) {
$link_templates['drupal:config-translation-overview'] .= $link_templates['edit-form'];
}
} }
return $link_templates; return $link_templates;
} }
......
...@@ -730,9 +730,8 @@ function hook_entity_field_info_alter(&$info, $entity_type_id) { ...@@ -730,9 +730,8 @@ function hook_entity_field_info_alter(&$info, $entity_type_id) {
function hook_entity_operation_alter(array &$operations, \Drupal\Core\Entity\EntityInterface $entity) { function hook_entity_operation_alter(array &$operations, \Drupal\Core\Entity\EntityInterface $entity) {
$operations['translate'] = array( $operations['translate'] = array(
'title' => t('Translate'), 'title' => t('Translate'),
'href' => $entity->getSystemPath() . '/translate',
'weight' => 50, 'weight' => 50,
); ) + $entity->urlInfo('my-custom-link-template');
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment