diff --git a/core/modules/config_translation/src/ConfigEntityMapper.php b/core/modules/config_translation/src/ConfigEntityMapper.php index 2cbc78e..3b748a7 100644 --- a/core/modules/config_translation/src/ConfigEntityMapper.php +++ b/core/modules/config_translation/src/ConfigEntityMapper.php @@ -163,6 +163,25 @@ public function getBaseRouteParameters() { } /** + * {@inheritdoc} + */ + public function getEditRouteName() { + return $this->entityManager->getDefinition($this->entityType)->getLinkTemplate('edit-form'); + } + + /** + * {@inheritdoc} + */ + public function getEditRoute() { + if ($this->routeCollection) { + return $this->routeCollection->get($this->getEditRouteName()); + } + else { + return $this->routeProvider->getRouteByName($this->getEditRouteName()); + } + } + + /** * Set entity type for this mapper. * * This should be set in initialization. A mapper that knows its type but diff --git a/core/modules/config_translation/src/ConfigMapperInterface.php b/core/modules/config_translation/src/ConfigMapperInterface.php index ba75aa2..d7e1d37 100644 --- a/core/modules/config_translation/src/ConfigMapperInterface.php +++ b/core/modules/config_translation/src/ConfigMapperInterface.php @@ -118,7 +118,30 @@ public function getAddRouteParameters(); public function getAddRoute(); /** - * Returns route name for the translation edit form route. + * Returns route name for the translation route. + * + * @return string + * Route name for the mapper. + */ + public function getTranslateRouteName(); + + /** + * Returns the route parameters for the translation route. + * + * @return array + */ + public function getTranslateRouteParameters(); + + /** + * Returns the route object for the translation route. + * + * @return \Symfony\Component\Routing\Route + * The route object for the translation page. + */ + public function getTranslateRoute(); + + /** + * Returns route name for the edit route. * * @return string * Route name for the mapper. @@ -126,14 +149,14 @@ public function getAddRoute(); public function getEditRouteName(); /** - * Returns the route parameters for the translation edit form route. + * Returns the route parameters for the edit form route. * * @return array */ public function getEditRouteParameters(); /** - * Returns the route object for a translation edit form route. + * Returns the route object for the edit form route. * * @return \Symfony\Component\Routing\Route * The route object for the translation page. diff --git a/core/modules/config_translation/src/ConfigNamesMapper.php b/core/modules/config_translation/src/ConfigNamesMapper.php index ed796af..e8c7d84 100644 --- a/core/modules/config_translation/src/ConfigNamesMapper.php +++ b/core/modules/config_translation/src/ConfigNamesMapper.php @@ -189,6 +189,27 @@ public function getBaseRoute() { } /** + * {@inheritdoc} + */ + public function getEditRouteName() { + return $this->getBaseRouteName(); + } + + /** + * {@inheritdoc} + */ + public function getEditRouteParameters() { + return $this->getBaseRouteParameters(); + } + + /** + * {@inheritdoc} + */ + public function getEditRoute() { + return $this->getBaseRoute(); + } + + /** * Allows to process all config translation routes. * * @param \Symfony\Component\Routing\Route $route @@ -278,21 +299,21 @@ public function getAddRoute() { /** * {@inheritdoc} */ - public function getEditRouteName() { + public function getTranslateRouteName() { return 'config_translation.item.edit.' . $this->getBaseRouteName(); } /** * {@inheritdoc} */ - public function getEditRouteParameters() { + public function getTranslateRouteParameters() { return $this->getAddRouteParameters(); } /** * {@inheritdoc} */ - public function getEditRoute() { + public function getTranslateRoute() { $route = new Route( $this->getBaseRoute()->getPath() . '/translate/{langcode}/edit', array( diff --git a/core/modules/config_translation/src/Controller/ConfigTranslationController.php b/core/modules/config_translation/src/Controller/ConfigTranslationController.php index 72fe9cc..cf7c5ec 100644 --- a/core/modules/config_translation/src/Controller/ConfigTranslationController.php +++ b/core/modules/config_translation/src/Controller/ConfigTranslationController.php @@ -175,7 +175,7 @@ public function itemPage(Request $request, RouteMatchInterface $route_match, $pl if ($edit_access) { $operations['edit'] = array( 'title' => $this->t('Edit'), - 'url' => Url::fromRoute($mapper->getBaseRouteName(), $mapper->getBaseRouteParameters(), ['query' => ['destination' => $mapper->getOverviewPath()]]), + 'url' => Url::fromRoute($mapper->getEditRouteName(), $mapper->getEditRouteParameters(), ['query' => ['destination' => $mapper->getOverviewPath()]]), ); } } @@ -194,7 +194,7 @@ public function itemPage(Request $request, RouteMatchInterface $route_match, $pl // Otherwise, link to edit the existing translation. $operations['edit'] = array( 'title' => $this->t('Edit'), - 'url' => Url::fromRoute($mapper->getEditRouteName(), $mapper->getEditRouteParameters()), + 'url' => Url::fromRoute($mapper->getTranslateRouteName(), $mapper->getTranslateRouteParameters()), ); $operations['delete'] = array( diff --git a/core/modules/config_translation/src/Routing/RouteSubscriber.php b/core/modules/config_translation/src/Routing/RouteSubscriber.php index d9d56ad..981e778 100644 --- a/core/modules/config_translation/src/Routing/RouteSubscriber.php +++ b/core/modules/config_translation/src/Routing/RouteSubscriber.php @@ -43,7 +43,7 @@ protected function alterRoutes(RouteCollection $collection) { foreach ($mappers as $mapper) { $collection->add($mapper->getOverviewRouteName(), $mapper->getOverviewRoute()); $collection->add($mapper->getAddRouteName(), $mapper->getAddRoute()); - $collection->add($mapper->getEditRouteName(), $mapper->getEditRoute()); + $collection->add($mapper->getTranslateRouteName(), $mapper->getTranslateRoute()); $collection->add($mapper->getDeleteRouteName(), $mapper->getDeleteRoute()); } } diff --git a/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php b/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php index 50e2712..7c8c633 100644 --- a/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php +++ b/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php @@ -259,7 +259,7 @@ public function testGetAddRoute() { * Tests ConfigNamesMapper::getEditRouteName(). */ public function testGetEditRouteName() { - $result = $this->configNamesMapper->getEditRouteName(); + $result = $this->configNamesMapper->getTranslateRouteName(); $expected = 'config_translation.item.edit.' . $this->pluginDefinition['base_route_name']; $this->assertSame($expected, $result); } @@ -273,7 +273,7 @@ public function testGetEditRouteParameters() { $this->configNamesMapper->populateFromRequest($request); $expected = array('langcode' => 'xx'); - $result = $this->configNamesMapper->getEditRouteParameters(); + $result = $this->configNamesMapper->getTranslateRouteParameters(); $this->assertSame($expected, $result); } @@ -290,7 +290,7 @@ public function testGetEditRoute() { '_config_translation_form_access' => 'TRUE', ) ); - $result = $this->configNamesMapper->getEditRoute(); + $result = $this->configNamesMapper->getTranslateRoute(); $this->assertSame(serialize($expected), serialize($result)); }