private function PhpDumper::addServiceSynchronizer in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/dependency-injection/Dumper/PhpDumper.php \Symfony\Component\DependencyInjection\Dumper\PhpDumper::addServiceSynchronizer()
Adds synchronizer methods.
Parameters
string $id A service identifier:
Definition $definition A Definition instance:
Return value
string|null
Deprecated
since version 2.7, will be removed in 3.0.
1 call to PhpDumper::addServiceSynchronizer()
- PhpDumper::addServices in vendor/
symfony/ dependency-injection/ Dumper/ PhpDumper.php - Adds multiple services.
File
- vendor/
symfony/ dependency-injection/ Dumper/ PhpDumper.php, line 701
Class
- PhpDumper
- PhpDumper dumps a service container as a PHP class.
Namespace
Symfony\Component\DependencyInjection\DumperCode
private function addServiceSynchronizer($id, Definition $definition) {
if (!$definition
->isSynchronized(false)) {
return;
}
if ('request' !== $id) {
@trigger_error('Synchronized services were deprecated in version 2.7 and won\'t work anymore in 3.0.', E_USER_DEPRECATED);
}
$code = '';
foreach ($this->container
->getDefinitions() as $definitionId => $definition) {
foreach ($definition
->getMethodCalls() as $call) {
foreach ($call[1] as $argument) {
if ($argument instanceof Reference && $id == (string) $argument) {
$arguments = array();
foreach ($call[1] as $value) {
$arguments[] = $this
->dumpValue($value);
}
$call = $this
->wrapServiceConditionals($call[1], sprintf("\$this->get('%s')->%s(%s);", $definitionId, $call[0], implode(', ', $arguments)));
$code .= <<<EOF
if (\$this->initialized('{<span class="php-variable">$definitionId</span>}')) {
{<span class="php-variable">$call</span>}
}
EOF;
}
}
}
}
if (!$code) {
return;
}
return <<<EOF
/**
* Updates the '{<span class="php-variable">$id</span>}' service.
*/
protected function synchronize{<span class="php-variable">$this</span>
-><span class="php-function-or-constant function member-of-self">camelize</span>(<span class="php-variable">$id</span>)}Service()
{
{<span class="php-variable">$code</span>} }
EOF;
}