Mercurial > hg > isophonics-drupal-site
diff core/modules/content_translation/src/Routing/ContentTranslationRouteSubscriber.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 4c8ae668cc8c |
children | 129ea1e6d783 |
line wrap: on
line diff
--- a/core/modules/content_translation/src/Routing/ContentTranslationRouteSubscriber.php Mon Apr 23 09:33:26 2018 +0100 +++ b/core/modules/content_translation/src/Routing/ContentTranslationRouteSubscriber.php Mon Apr 23 09:46:53 2018 +0100 @@ -2,6 +2,7 @@ namespace Drupal\content_translation\Routing; +use Drupal\content_translation\ContentTranslationManager; use Drupal\content_translation\ContentTranslationManagerInterface; use Drupal\Core\Routing\RouteSubscriberBase; use Drupal\Core\Routing\RoutingEvents; @@ -55,6 +56,7 @@ } $path = $base_path . '/translations'; + $load_latest_revision = ContentTranslationManager::isPendingRevisionSupportEnabled($entity_type_id); $route = new Route( $path, @@ -70,6 +72,7 @@ 'parameters' => [ $entity_type_id => [ 'type' => 'entity:' . $entity_type_id, + 'load_latest_revision' => $load_latest_revision, ], ], '_admin_route' => $is_admin, @@ -102,6 +105,7 @@ ], $entity_type_id => [ 'type' => 'entity:' . $entity_type_id, + 'load_latest_revision' => $load_latest_revision, ], ], '_admin_route' => $is_admin, @@ -127,6 +131,7 @@ ], $entity_type_id => [ 'type' => 'entity:' . $entity_type_id, + 'load_latest_revision' => $load_latest_revision, ], ], '_admin_route' => $is_admin, @@ -152,12 +157,21 @@ ], $entity_type_id => [ 'type' => 'entity:' . $entity_type_id, + 'load_latest_revision' => $load_latest_revision, ], ], '_admin_route' => $is_admin, ] ); $collection->add("entity.$entity_type_id.content_translation_delete", $route); + + // Add our custom translation deletion access checker. + if ($load_latest_revision) { + $entity_delete_route = $collection->get("entity.$entity_type_id.delete_form"); + if ($entity_delete_route) { + $entity_delete_route->addRequirements(['_access_content_translation_delete' => "$entity_type_id.delete"]); + } + } } }