public function JsCallbackBase::mapMethodParameters in JS Callback Handler 8.3
1 call to JsCallbackBase::mapMethodParameters()
- JsCallbackBase::call in src/
Plugin/ Js/ JsCallbackBase.php - Calls a method on the callback, providing necessary converted parameters.
File
- src/
Plugin/ Js/ JsCallbackBase.php, line 168
Class
- JsCallbackBase
- Base JsCallback class.
Namespace
Drupal\js\Plugin\JsCode
public function mapMethodParameters($method) {
$args = [];
$parameters = $this
->getParameters();
$reflection = new \ReflectionClass($this);
$function = $reflection
->getMethod($method);
foreach ($function
->getParameters() as $param) {
$default_value = $param
->isDefaultValueAvailable() ? $param
->getDefaultValue() : NULL;
$value = isset($parameters[$param->name]) ? $parameters[$param->name] : $default_value;
// Type case values if not an object.
if (isset($value) && !is_object($value) && ($type = gettype($default_value))) {
settype($value, $type);
}
$args[$param->name] = $value;
}
return $args;
}