Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. PhpDumper.php

function PhpDumper::addServiceMethodCalls

1 call to PhpDumper::addServiceMethodCalls()
PhpDumper::addInlineService in vendor/symfony/dependency-injection/Dumper/PhpDumper.php

File

vendor/symfony/dependency-injection/Dumper/PhpDumper.php, line 752

Class

PhpDumper
PhpDumper dumps a service container as a PHP class.

Namespace

Symfony\Component\DependencyInjection\Dumper

Code

private function addServiceMethodCalls(Definition $definition, string $variableName, ?string $sharedNonLazyId) : string {
    $lastWitherIndex = null;
    foreach ($definition->getMethodCalls() as $k => $call) {
        if ($call[2] ?? false) {
            $lastWitherIndex = $k;
        }
    }
    $calls = '';
    foreach ($definition->getMethodCalls() as $k => $call) {
        $arguments = [];
        foreach ($call[1] as $i => $value) {
            $arguments[] = (\is_string($i) ? $i . ': ' : '') . $this->dumpValue($value);
        }
        $witherAssignation = '';
        if ($call[2] ?? false) {
            if (null !== $sharedNonLazyId && $lastWitherIndex === $k && 'instance' === $variableName) {
                $witherAssignation = \sprintf('$container->%s[\'%s\'] = ', $definition->isPublic() ? 'services' : 'privates', $sharedNonLazyId);
            }
            $witherAssignation .= \sprintf('$%s = ', $variableName);
        }
        $calls .= $this->wrapServiceConditionals($call[1], \sprintf("        %s\$%s->%s(%s);\n", $witherAssignation, $variableName, $call[0], implode(', ', $arguments)));
    }
    return $calls;
}
RSS feed
Powered by Drupal