class OpenApiParamConverter in OpenAPI 8
Same name and namespace in other branches
- 8.2 src/ParamConverter/OpenApiParamConverter.php \Drupal\openapi\ParamConverter\OpenApiParamConverter
Defines a ParamConverter for Openapi Plugins.
Hierarchy
- class \Drupal\openapi\ParamConverter\OpenApiParamConverter implements ParamConverterInterface
Expanded class hierarchy of OpenApiParamConverter
1 string reference to 'OpenApiParamConverter'
1 service uses OpenApiParamConverter
File
- src/
ParamConverter/ OpenApiParamConverter.php, line 14
Namespace
Drupal\openapi\ParamConverterView source
class OpenApiParamConverter implements ParamConverterInterface {
/**
* Current openapi generator plugin manager.
*
* @var \Drupal\Component\Plugin\PluginManagerInterface
*/
public $openApiGeneratorManager;
/**
* Creates a new OpenApiParamConverter.
*
* @param \Drupal\Component\Plugin\PluginManagerInterface $open_api_generator_manager
* The current openapi generator plugin manager instance.
*/
public function __construct(PluginManagerInterface $open_api_generator_manager) {
$this->openApiGeneratorManager = $open_api_generator_manager;
}
/**
* {@inheritdoc}
*/
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;
}
/**
* {@inheritdoc}
*/
public function applies($definition, $name, Route $route) {
return !empty($definition['type']) && $definition['type'] == 'openapi_generator';
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
OpenApiParamConverter:: |
public | property | Current openapi generator plugin manager. | |
OpenApiParamConverter:: |
public | function |
Determines if the converter applies to a specific route and variable. Overrides ParamConverterInterface:: |
|
OpenApiParamConverter:: |
public | function |
Converts path variables to their corresponding objects. Overrides ParamConverterInterface:: |
|
OpenApiParamConverter:: |
public | function | Creates a new OpenApiParamConverter. |