Skip to content

Commit

Permalink
[DependencyInjection] fixes a bug when requesting a definition that u…
Browse files Browse the repository at this point in the history
…ses property injection
  • Loading branch information
schmittjoh committed May 3, 2011
1 parent 807c1d8 commit 2c28767
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Symfony/Component/DependencyInjection/ContainerBuilder.php
Expand Up @@ -698,6 +698,20 @@ private function createService(Definition $definition, $id)
}
}

$properties = $this->resolveServices($this->getParameterBag()->resolveValue($definition->getProperties()));
$outsideClass = new \ReflectionClass($service);
foreach ($properties as $name => $value) {
$class = $outsideClass;
do {
if ($class->hasProperty($name)) {
$property = $class->getProperty($name);
$property->setAccessible(true);
$property->setValue($service, $value);
continue 2;
}
} while (false !== $class = $class->getParentClass());
}

if ($callable = $definition->getConfigurator()) {
if (is_array($callable) && is_object($callable[0]) && $callable[0] instanceof Reference) {
$callable[0] = $this->get((string) $callable[0]);
Expand Down

0 comments on commit 2c28767

Please sign in to comment.