class EntityUuidConverter extends EntityConverter (View source)

internal  JSON:API maintains no PHP API since its API is the HTTP API. This class may change at any time and this will break any dependencies on it.
 

Parameter converter for upcasting entity UUIDs to full objects.

Remove when https://www.drupal.org/node/2353611 lands.

Traits

Provides a trait to replace dynamic entity types in routes.

Properties

protected EntityTypeManagerInterface $entityTypeManager

Entity type manager which performs the upcasting in the end.

from  EntityConverter
protected EntityRepositoryInterface $entityRepository

Entity repository.

from  EntityConverter
protected LanguageManagerInterface $languageManager

The language manager.

Methods

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)

Constructs a new EntityConverter.

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

Converts path variables to their corresponding objects.

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

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

setLanguageManager(LanguageManagerInterface $language_manager)

Injects the language manager.

Details

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)

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/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.

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.

setLanguageManager(LanguageManagerInterface $language_manager)

Injects the language manager.

Parameters

LanguageManagerInterface $language_manager

The language manager to get the current content language.