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

Breadcrumb

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

function PhpDumper::getServiceConditionals

2 calls to PhpDumper::getServiceConditionals()
PhpDumper::dumpValue in vendor/symfony/dependency-injection/Dumper/PhpDumper.php
PhpDumper::wrapServiceConditionals in vendor/symfony/dependency-injection/Dumper/PhpDumper.php

File

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

Class

PhpDumper
PhpDumper dumps a service container as a PHP class.

Namespace

Symfony\Component\DependencyInjection\Dumper

Code

private function getServiceConditionals(mixed $value) : string {
    $conditions = [];
    foreach (ContainerBuilder::getInitializedConditionals($value) as $service) {
        if (!$this->container
            ->hasDefinition($service)) {
            return 'false';
        }
        $conditions[] = \sprintf('isset($container->%s[%s])', $this->container
            ->getDefinition($service)
            ->isPublic() ? 'services' : 'privates', $this->doExport($service));
    }
    foreach (ContainerBuilder::getServiceConditionals($value) as $service) {
        if ($this->container
            ->hasDefinition($service) && !$this->container
            ->getDefinition($service)
            ->isPublic()) {
            continue;
        }
        $conditions[] = \sprintf('$container->has(%s)', $this->doExport($service));
    }
    if (!$conditions) {
        return '';
    }
    return implode(' && ', $conditions);
}
RSS feed
Powered by Drupal