protected function ContentModerationRouteSubscriber::setLatestRevisionFlag in Drupal 10
Same name and namespace in other branches
- 8 core/modules/content_moderation/src/Routing/ContentModerationRouteSubscriber.php \Drupal\content_moderation\Routing\ContentModerationRouteSubscriber::setLatestRevisionFlag()
- 9 core/modules/content_moderation/src/Routing/ContentModerationRouteSubscriber.php \Drupal\content_moderation\Routing\ContentModerationRouteSubscriber::setLatestRevisionFlag()
Ensure revisionable entities load the latest revision on entity forms.
Parameters
\Symfony\Component\Routing\Route $route: The route object.
File
- core/
modules/ content_moderation/ src/ Routing/ ContentModerationRouteSubscriber.php, line 63
Class
- ContentModerationRouteSubscriber
- Subscriber for moderated revisionable entity forms.
Namespace
Drupal\content_moderation\RoutingCode
protected function setLatestRevisionFlag(Route $route) {
if (!($entity_form = $route
->getDefault('_entity_form'))) {
return;
}
// Only set the flag on entity types which are revisionable.
[
$entity_type,
] = explode('.', $entity_form, 2);
if (!isset($this
->getModeratedEntityTypes()[$entity_type]) || !$this
->getModeratedEntityTypes()[$entity_type]
->isRevisionable()) {
return;
}
$parameters = $route
->getOption('parameters') ?: [];
foreach ($parameters as &$parameter) {
if (isset($parameter['type']) && $parameter['type'] === 'entity:' . $entity_type && !isset($parameter['load_latest_revision'])) {
$parameter['load_latest_revision'] = TRUE;
}
}
$route
->setOption('parameters', $parameters);
}