function ProxyBuilder::buildMethodBody
Same name in other branches
- 8.9.x core/lib/Drupal/Component/ProxyBuilder/ProxyBuilder.php \Drupal\Component\ProxyBuilder\ProxyBuilder::buildMethodBody()
- 10 core/lib/Drupal/Component/ProxyBuilder/ProxyBuilder.php \Drupal\Component\ProxyBuilder\ProxyBuilder::buildMethodBody()
- 11.x core/lib/Drupal/Component/ProxyBuilder/ProxyBuilder.php \Drupal\Component\ProxyBuilder\ProxyBuilder::buildMethodBody()
Builds the body of a wrapped method.
Parameters
\ReflectionMethod $reflection_method: A reflection method for the method.
Return value
string
1 call to ProxyBuilder::buildMethodBody()
- ProxyBuilder::buildMethod in core/
lib/ Drupal/ Component/ ProxyBuilder/ ProxyBuilder.php - Generates the string representation of a single method: signature, body.
File
-
core/
lib/ Drupal/ Component/ ProxyBuilder/ ProxyBuilder.php, line 305
Class
- ProxyBuilder
- Generates the string representation of the proxy service.
Namespace
Drupal\Component\ProxyBuilderCode
protected function buildMethodBody(\ReflectionMethod $reflection_method) {
$output = '';
$function_name = $reflection_method->getName();
if (!$reflection_method->isStatic()) {
if ($reflection_method->getReturnType() && $reflection_method->getReturnType()
->getName() === 'void') {
$output .= ' $this->lazyLoadItself()->' . $function_name . '(';
}
else {
$output .= ' return $this->lazyLoadItself()->' . $function_name . '(';
}
}
else {
$class_name = $reflection_method->getDeclaringClass()
->getName();
$output .= " \\{$class_name}::{$function_name}(";
}
// Add parameters;
$parameters = [];
foreach ($reflection_method->getParameters() as $parameter) {
$parameters[] = '$' . $parameter->getName();
}
$output .= implode(', ', $parameters) . ');';
return $output;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.