class ParamConverterManager implements ParamConverterManagerInterface (View source)

Manages converter services for converting request parameters to full objects.

A typical use case for this would be upcasting (converting) a node id to a node entity.

Properties

protected array $converters

Array of loaded converter services keyed by their ids.

Methods

$this
addConverter(ParamConverterInterface $param_converter, string $id)

Registers a parameter converter with the manager.

getConverter($converter)

Lazy-loads converter services.

setRouteParameterConverters(RouteCollection $routes)

Saves a list of applicable converters to each route.

array
convert(array $defaults)

Invokes the registered converter for each defined parameter on a route.

Details

$this addConverter(ParamConverterInterface $param_converter, string $id)

Registers a parameter converter with the manager.

Parameters

ParamConverterInterface $param_converter

The added param converter instance.

string $id

The parameter converter service id to register.

Return Value

$this

ParamConverterInterface getConverter($converter)

Lazy-loads converter services.

Parameters

$converter

Return Value

ParamConverterInterface

The loaded converter service identified by the given service id.

Exceptions

InvalidArgumentException

setRouteParameterConverters(RouteCollection $routes)

Saves a list of applicable converters to each route.

Parameters

RouteCollection $routes

A collection of routes to apply converters to.

array convert(array $defaults)

Invokes the registered converter for each defined parameter on a route.

Parameters

array $defaults

The route defaults array.

Return Value

array

The modified defaults.

Exceptions

ParamNotConvertedException