private function PhpDumper::wrapServiceConditionals in Service Container 7
Same name and namespace in other branches
- 7.2 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php \Symfony\Component\DependencyInjection\Dumper\PhpDumper::wrapServiceConditionals()
Wraps the service conditionals.
Parameters
string $value:
string $code:
Return value
string
2 calls to PhpDumper::wrapServiceConditionals()
- PhpDumper::addServiceMethodCalls in modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ DependencyInjection/ Dumper/ PhpDumper.php - Adds method calls to a service definition.
- PhpDumper::addServiceSynchronizer in modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ DependencyInjection/ Dumper/ PhpDumper.php - Adds synchronizer methods.
File
- modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ DependencyInjection/ Dumper/ PhpDumper.php, line 1134
Class
- PhpDumper
- PhpDumper dumps a service container as a PHP class.
Namespace
Symfony\Component\DependencyInjection\DumperCode
private function wrapServiceConditionals($value, $code) {
if (!($services = ContainerBuilder::getServiceConditionals($value))) {
return $code;
}
$conditions = array();
foreach ($services as $service) {
$conditions[] = sprintf("\$this->has('%s')", $service);
}
// re-indent the wrapped code
$code = implode("\n", array_map(function ($line) {
return $line ? ' ' . $line : $line;
}, explode("\n", $code)));
return sprintf(" if (%s) {\n%s }\n", implode(' && ', $conditions), $code);
}