class ComponentTypeConverter in RNG - Events and Registrations 8
Same name and namespace in other branches
- 8.2 src/ParamConverter/ComponentTypeConverter.php \Drupal\rng\ParamConverter\ComponentTypeConverter
- 3.x src/ParamConverter/ComponentTypeConverter.php \Drupal\rng\ParamConverter\ComponentTypeConverter
Provides upcasting for RNG event type rules components.
Hierarchy
- class \Drupal\rng\ParamConverter\ComponentTypeConverter implements ParamConverterInterface
Expanded class hierarchy of ComponentTypeConverter
1 string reference to 'ComponentTypeConverter'
1 service uses ComponentTypeConverter
File
- src/
ParamConverter/ ComponentTypeConverter.php, line 11
Namespace
Drupal\rng\ParamConverterView source
class ComponentTypeConverter implements ParamConverterInterface {
/**
* {@inheritdoc}
*/
public function convert($value, $definition, $name, array $defaults) {
if ($definition['type'] == 'rng_component_type') {
return in_array($value, [
'condition',
'action',
]) ? $value : NULL;
}
else {
if ($definition['type'] == 'rng_component_id') {
$event_type_rule = $defaults['rng_event_type_rule'];
$component_type = $defaults['component_type'];
$components = [];
if ($component_type == 'condition') {
$components = $event_type_rule
->getConditions();
}
else {
if ($component_type == 'action') {
$components = $event_type_rule
->getActions();
}
}
if (in_array($value, array_keys($components))) {
return $value;
}
}
}
}
/**
* {@inheritdoc}
*/
public function applies($definition, $name, Route $route) {
return !empty($definition['type']) && in_array($definition['type'], [
'rng_component_type',
'rng_component_id',
]);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ComponentTypeConverter:: |
public | function |
Determines if the converter applies to a specific route and variable. Overrides ParamConverterInterface:: |
|
ComponentTypeConverter:: |
public | function |
Converts path variables to their corresponding objects. Overrides ParamConverterInterface:: |