class EntityRevisionConverter extends EntityConverter (View source)

internal  This class only exists to provide backwards compatibility with the load_pending_revision flag, the predecessor to load_latest_revision. The core entity converter now natively loads the latest revision of an entity when the load_latest_revision flag is present. This flag is also added automatically to all entity forms.
 

Defines a class for making sure the edit-route loads the current draft.

Traits

Provides a standard way to announce deprecated properties.

Provides a trait to replace dynamic entity types in routes.

Properties

protected $deprecatedProperties {@inheritdoc} from  EntityConverter
protected EntityTypeManagerInterface $entityTypeManager

Entity type manager which performs the upcasting in the end.

from  EntityConverter
protected EntityRepositoryInterface $entityRepository

Entity repository.

from  EntityConverter

Methods

__get($name)

Allows to access deprecated/removed properties.

string
getEntityTypeFromDefaults(mixed $definition, string $name, array $defaults)

Determines the entity type ID given a route definition and route defaults.

__construct(EntityTypeManagerInterface $entity_type_manager, EntityRepositoryInterface $entity_repository = NULL)

Constructs a new EntityConverter.

mixed|null
convert(mixed $value, mixed $definition, string $name, array $defaults)

Converts path variables to their corresponding objects.

getLatestTranslationAffectedRevision(RevisionableInterface $entity, string $langcode) deprecated

Returns the latest revision translation of the specified entity.

loadRevision(RevisionableInterface $entity, string $revision_id) deprecated

Loads the specified entity revision.

bool
applies(mixed $definition, string $name, Route $route)

Determines if the converter applies to a specific route and variable.

languageManager()

Returns a language manager instance.

Details

__get($name)

Allows to access deprecated/removed properties.

This method must be public.

Parameters

$name

protected string getEntityTypeFromDefaults(mixed $definition, string $name, array $defaults)

Determines the entity type ID given a route definition and route defaults.

Parameters

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

string

The entity type ID.

Exceptions

ParamNotConvertedException

__construct(EntityTypeManagerInterface $entity_type_manager, EntityRepositoryInterface $entity_repository = NULL)

Constructs a new EntityConverter.

Parameters

EntityTypeManagerInterface $entity_type_manager

The entity type manager.

EntityRepositoryInterface $entity_repository

The entity repository.

See also

https://www.drupal.org/node/2549139
https://www.drupal.org/node/2938929

mixed|null convert(mixed $value, mixed $definition, string $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.

protected RevisionableInterface getLatestTranslationAffectedRevision(RevisionableInterface $entity, string $langcode) deprecated

deprecated in drupal:8.7.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Entity\EntityRepositoryInterface::getActive() instead.

Returns the latest revision translation of the specified entity.

Parameters

RevisionableInterface $entity

The default revision of the entity being converted.

string $langcode

The language of the revision translation to be loaded.

Return Value

RevisionableInterface

The latest translation-affecting revision for the specified entity, or just the latest revision, if the specified entity is not translatable or does not have a matching translation yet.

protected RevisionableInterface loadRevision(RevisionableInterface $entity, string $revision_id) deprecated

deprecated in drupal:8.7.0 and is removed from drupal:9.0.0.

Loads the specified entity revision.

Parameters

RevisionableInterface $entity

The default revision of the entity being converted.

string $revision_id

The identifier of the revision to be loaded.

Return Value

RevisionableInterface

An entity revision object.

bool applies(mixed $definition, string $name, Route $route)

Determines if the converter applies to a specific route and variable.

Parameters

mixed $definition

The parameter definition provided in the route options.

string $name

The name of the parameter.

Route $route

The route to consider attaching to.

Return Value

bool

TRUE if the converter applies to the passed route and parameter, FALSE otherwise.

protected LanguageManagerInterface languageManager()

internal  
 

Returns a language manager instance.

Return Value

LanguageManagerInterface

The language manager.