interface ParamConverterInterface (View source)

Interface for parameter converters.

Classes implementing this interface are responsible for converting a path parameter to the object it represents.

Here is an example path: /admin/structure/block/manage/{block}

In this case, '{block}' would be the path parameter which should be turned into a block object representing the block in question.

ParamConverters are defined as services tagged with 'paramconverter', and are managed by the 'paramconverter_manager' service.

Methods

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.

Details

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.