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

Breadcrumb

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

function PhpDumper::addInlineRequires

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

File

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

Class

PhpDumper
PhpDumper dumps a service container as a PHP class.

Namespace

Symfony\Component\DependencyInjection\Dumper

Code

private function addInlineRequires(bool $hasProxyClasses) : string {
    $lineage = [];
    $hotPathServices = $this->hotPathTag && $this->inlineRequires ? $this->container
        ->findTaggedServiceIds($this->hotPathTag) : [];
    foreach ($hotPathServices as $id => $tags) {
        $definition = $this->container
            ->getDefinition($id);
        if ($definition->isLazy() && $this->hasProxyDumper) {
            continue;
        }
        $inlinedDefinitions = $this->getDefinitionsFromArguments([
            $definition,
        ]);
        foreach ($inlinedDefinitions as $def) {
            foreach ($this->getClasses($def, $id) as $class) {
                $this->collectLineage($class, $lineage);
            }
        }
    }
    $code = '';
    foreach ($lineage as $file) {
        if (!isset($this->inlinedRequires[$file])) {
            $this->inlinedRequires[$file] = true;
            $code .= \sprintf("\n            include_once %s;", $file);
        }
    }
    if ($hasProxyClasses) {
        $code .= "\n            include_once __DIR__.'/proxy-classes.php';";
    }
    return $code ? \sprintf("\n        \$this->privates['service_container'] = static function (\$container) {%s\n        };\n", $code) : '';
}
RSS feed
Powered by Drupal