W3cubDocs

/Drupal 8

protected function ProxyBuilder::buildMethodBody

protected ProxyBuilder::buildMethodBody(\ReflectionMethod $reflection_method)

Builds the body of a wrapped method.

Parameters

\ReflectionMethod $reflection_method: A reflection method for the method.

Return value

string

File

core/lib/Drupal/Component/ProxyBuilder/ProxyBuilder.php, line 291

Class

ProxyBuilder
Generates the string representation of the proxy service.

Namespace

Drupal\Component\ProxyBuilder

Code

protected function buildMethodBody(\ReflectionMethod $reflection_method) {
  $output = '';

  $function_name = $reflection_method->getName();

  if (!$reflection_method->isStatic()) {
    $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;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Component!ProxyBuilder!ProxyBuilder.php/function/ProxyBuilder::buildMethodBody/8.1.x