diff --git a/core/lib/Drupal/Core/Entity/Annotation/EntityType.php b/core/lib/Drupal/Core/Entity/Annotation/EntityType.php index 0171dd5..6cdf337 100644 --- a/core/lib/Drupal/Core/Entity/Annotation/EntityType.php +++ b/core/lib/Drupal/Core/Entity/Annotation/EntityType.php @@ -268,7 +268,7 @@ class EntityType extends Plugin { * @var array */ public $links = array( - 'canonical' => '/entity/{entityType}/{id}', + 'canonical' => NULL, ); /** diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index de881b9..efd73ac 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -90,10 +90,9 @@ function content_translation_entity_info_alter(array &$entity_info) { } if (!empty($info['links']['canonical'])) { - // Provide default links for the translation paths. - // @todo NOPE NOPE NOPE NOPE NOPE. + // Provide default route names for the translation paths. $info['links'] += array( - 'drupal:content-translation-overview' => $info['links']['canonical'] . '/translations', + 'drupal:content-translation-overview' => "content_translation.translation_overview_$entity_type", ); $parts = explode('/', trim($info['links']['canonical'], '/')); diff --git a/core/modules/content_translation/content_translation.services.yml b/core/modules/content_translation/content_translation.services.yml index e81c13d..41547ed 100644 --- a/core/modules/content_translation/content_translation.services.yml +++ b/core/modules/content_translation/content_translation.services.yml @@ -5,9 +5,9 @@ services: content_translation.subscriber: class: Drupal\content_translation\Routing\ContentTranslationRouteSubscriber - arguments: ['@plugin.manager.entity'] + arguments: ['@plugin.manager.entity', '@router.route_provider'] tags: - - { name: event_subscriber } + - { name: event_subscriber, priority: -100 } content_translation.overview_access: class: Drupal\content_translation\Access\ContentTranslationOverviewAccess 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 368dc27..5ff8c8f 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 @@ -8,6 +8,7 @@ namespace Drupal\content_translation\Routing; use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Routing\RouteProviderInterface; use Drupal\Core\Routing\RouteSubscriberBase; use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; @@ -25,13 +26,24 @@ class ContentTranslationRouteSubscriber extends RouteSubscriberBase { protected $entityManager; /** + * + * The route provider. + * + * @var \Drupal\Core\Routing\RouteProviderInterface + */ + protected $routeProvider; + + /** * Constructs a ContentTranslationRouteSubscriber object. * * @param \Drupal\Core\Entity\EntityManagerInterface $entityManager * The entity type manager. + * @param \Drupal\Core\Routing\RouteProviderInterface $route_provider + * The route provider. */ - public function __construct(EntityManagerInterface $entityManager) { + public function __construct(EntityManagerInterface $entityManager, RouteProviderInterface $route_provider) { $this->entityManager = $entityManager; + $this->routeProvider = $route_provider; } /** @@ -39,8 +51,9 @@ public function __construct(EntityManagerInterface $entityManager) { */ protected function routes(RouteCollection $collection) { foreach ($this->entityManager->getDefinitions() as $entity_type => $entity_info) { - if (!empty($entity_info['translatable']) && !empty($entity_info['links']['drupal:content-translation-overview'])) { - $path = $entity_info['links']['drupal:content-translation-overview']; + if (!empty($entity_info['translatable']) && !empty($entity_info['links']['canonical'])) { + $entity_route = $this->routeProvider->getRouteByName($entity_info['links']['canonical']); + $path = $entity_route->getPath() . '/translations'; $route = new Route( $path,