public EntityRevisionConverter::convert($value, $definition, $name, array $defaults)
Converts path variables to their corresponding objects.
Parameters
mixed $value: The raw value.
mixed $definition: The parameter definition provided in the route options.
string $name: The name of the parameter.
array $defaults: The route defaults array.
Return value
mixed|null The converted parameter value.
Overrides EntityConverter::convert
File
- core/modules/content_moderation/src/ParamConverter/EntityRevisionConverter.php, line 88
Class
- EntityRevisionConverter
- Defines a class for making sure the edit-route loads the current draft.
Namespace
Drupal\content_moderation\ParamConverter
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | public function convert( $value , $definition , $name , array $defaults ) { $entity = parent::convert( $value , $definition , $name , $defaults ); if ( $entity && $this ->moderationInformation->isModeratedEntity( $entity ) && ! $this ->moderationInformation->isLatestRevision( $entity )) { $entity_type_id = $this ->getEntityTypeFromDefaults( $definition , $name , $defaults ); $latest_revision = $this ->moderationInformation->getLatestRevision( $entity_type_id , $value ); // If the entity type is translatable, ensure we return the proper // translation object for the current context. if ( $latest_revision instanceof EntityInterface && $entity instanceof TranslatableInterface) { $latest_revision = $this ->entityManager->getTranslationFromContext( $latest_revision , NULL, array ( 'operation' => 'entity_upcast' )); } if ( $latest_revision ->isRevisionTranslationAffected()) { $entity = $latest_revision ; } } return $entity ; } |
Please login to continue.