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

Breadcrumb

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

function GraphvizDumper::findEdges

Finds all edges belonging to a specific service id.

1 call to GraphvizDumper::findEdges()
GraphvizDumper::dump in vendor/symfony/dependency-injection/Dumper/GraphvizDumper.php
Dumps the service container as a graphviz graph.

File

vendor/symfony/dependency-injection/Dumper/GraphvizDumper.php, line 112

Class

GraphvizDumper
GraphvizDumper dumps a service container as a graphviz file.

Namespace

Symfony\Component\DependencyInjection\Dumper

Code

private function findEdges(string $id, array $arguments, bool $required, string $name, bool $lazy = false) : array {
    $edges = [];
    foreach ($arguments as $argument) {
        if ($argument instanceof Parameter) {
            $argument = $this->container
                ->hasParameter($argument) ? $this->container
                ->getParameter($argument) : null;
        }
        elseif (\is_string($argument) && preg_match('/^%([^%]+)%$/', $argument, $match)) {
            $argument = $this->container
                ->hasParameter($match[1]) ? $this->container
                ->getParameter($match[1]) : null;
        }
        if ($argument instanceof Reference) {
            $lazyEdge = $lazy;
            if (!$this->container
                ->has((string) $argument)) {
                $this->nodes[(string) $argument] = [
                    'name' => $name,
                    'required' => $required,
                    'class' => '',
                    'attributes' => $this->options['node.missing'],
                ];
            }
            elseif ('service_container' !== (string) $argument) {
                $lazyEdge = $lazy || $this->container
                    ->getDefinition((string) $argument)
                    ->isLazy();
            }
            $edges[] = [
                [
                    'name' => $name,
                    'required' => $required,
                    'to' => $argument,
                    'lazy' => $lazyEdge,
                ],
            ];
        }
        elseif ($argument instanceof ArgumentInterface) {
            $edges[] = $this->findEdges($id, $argument->getValues(), $required, $name, true);
        }
        elseif ($argument instanceof Definition) {
            $edges[] = $this->findEdges($id, $argument->getArguments(), $required, '');
            $edges[] = $this->findEdges($id, $argument->getProperties(), false, '');
            foreach ($argument->getMethodCalls() as $call) {
                $edges[] = $this->findEdges($id, $call[1], false, $call[0] . '()');
            }
        }
        elseif (\is_array($argument)) {
            $edges[] = $this->findEdges($id, $argument, $required, $name, $lazy);
        }
    }
    return array_merge([], ...$edges);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal