public function ComponentTypeConverter::convert in RNG - Events and Registrations 8
Same name and namespace in other branches
- 8.2 src/ParamConverter/ComponentTypeConverter.php \Drupal\rng\ParamConverter\ComponentTypeConverter::convert()
- 3.x src/ParamConverter/ComponentTypeConverter.php \Drupal\rng\ParamConverter\ComponentTypeConverter::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/ ComponentTypeConverter.php, line 16
Class
- ComponentTypeConverter
- Provides upcasting for RNG event type rules components.
Namespace
Drupal\rng\ParamConverterCode
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;
}
}
}
}