Skip to content

Commit

Permalink
DI\ContainerBuilder: factory method must exists
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jun 17, 2013
1 parent ab5fd7d commit 7937421
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Nette/DI/ContainerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,12 @@ private function resolveClass($name, $recursive = array())
}
try {
$reflection = $factory->toReflection();
$def->class = preg_replace('#[|\s].*#', '', $reflection->getAnnotation('return'));
if ($def->class && !class_exists($def->class) && $def->class[0] !== '\\' && $reflection instanceof \ReflectionMethod) {
/**/$def->class = $reflection->getDeclaringClass()->getNamespaceName() . '\\' . $def->class;/**/
}
} catch (\ReflectionException $e) {
throw new Nette\InvalidStateException("Missing factory '$factory'.");
}
$def->class = preg_replace('#[|\s].*#', '', $reflection->getAnnotation('return'));
if ($def->class && !class_exists($def->class) && $def->class[0] !== '\\' && $reflection instanceof \ReflectionMethod) {
/**/$def->class = $reflection->getDeclaringClass()->getNamespaceName() . '\\' . $def->class;/**/
}

} elseif ($service = $this->getServiceName($factory)) { // alias or factory
Expand Down

0 comments on commit 7937421

Please sign in to comment.