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
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -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[] */
foreach ($entity_info as $entity_type_id => $entity_type) {
if ($entity_type_id == 'block') {
$class = 'Drupal\config_translation\Controller\ConfigTranslationBlockListController';
}
elseif ($entity_type_id == 'field_instance') {
$class = 'Drupal\config_translation\Controller\ConfigTranslationFieldInstanceListController';
}
else {
$class = 'Drupal\config_translation\Controller\ConfigTranslationEntityListController';
if ($entity_type->isSubclassOf('Drupal\Core\Config\Entity\ConfigEntityInterface')) {
if ($entity_type_id == 'block') {
$class = 'Drupal\config_translation\Controller\ConfigTranslationBlockListController';
}
elseif ($entity_type_id == 'field_instance') {
$class = 'Drupal\config_translation\Controller\ConfigTranslationFieldInstanceListController';
// Will be filled in dynamically, see \Drupal\field\Entity\FieldInstance::linkTemplates().
$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) {
*/
function config_translation_entity_operation_alter(array &$operations, EntityInterface $entity) {
if (\Drupal::currentUser()->hasPermission('translate configuration')) {
$uri = $entity->urlInfo();
$operations['translate'] = array(
'title' => t('Translate'),
'href' => $entity->getSystemPath() . '/translate',
'options' => $uri['options'],
'weight' => 50,
);
) + $entity->urlInfo('drupal:config-translation-overview');
}
}
......
......@@ -64,7 +64,7 @@ protected function renderLink(EntityInterface $entity, ResultRow $values) {
$text = !empty($this->options['text']) ? $this->options['text'] : t('translate');
$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;
}
......
......@@ -511,6 +511,9 @@ protected function linkTemplates() {
$link_templates = parent::linkTemplates();
if (\Drupal::moduleHandler()->moduleExists('field_ui')) {
$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;
}
......
......@@ -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) {
$operations['translate'] = array(
'title' => t('Translate'),
'href' => $entity->getSystemPath() . '/translate',
'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