You are here

public function OpenApiParamConverter::convert in OpenAPI 8

Same name and namespace in other branches
  1. 8.2 src/ParamConverter/OpenApiParamConverter.php \Drupal\openapi\ParamConverter\OpenApiParamConverter::convert()

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 ParamConverterInterface::convert

File

src/ParamConverter/OpenApiParamConverter.php, line 36

Class

OpenApiParamConverter
Defines a ParamConverter for Openapi Plugins.

Namespace

Drupal\openapi\ParamConverter

Code

public function convert($value, $definition, $name, array $defaults) {
  try {
    $generator = $this->openApiGeneratorManager
      ->createInstance($value);
  } catch (PluginNotFoundException $e) {

    // Plugin Not found, we can't convert it the param.
    return NULL;
  }
  return $generator;
}