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;
}
$path = $base_path . '/translations';
+ $load_latest_revision = ContentTranslationManager::isPendingRevisionSupportEnabled($entity_type_id);
$route = new Route(
$path,
'parameters' => [
$entity_type_id => [
'type' => 'entity:' . $entity_type_id,
+ 'load_latest_revision' => $load_latest_revision,
],
],
'_admin_route' => $is_admin,
],
$entity_type_id => [
'type' => 'entity:' . $entity_type_id,
+ 'load_latest_revision' => $load_latest_revision,
],
],
'_admin_route' => $is_admin,
],
$entity_type_id => [
'type' => 'entity:' . $entity_type_id,
+ 'load_latest_revision' => $load_latest_revision,
],
],
'_admin_route' => $is_admin,
],
$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"]);
+ }
+ }
}
}