Skip to content

Commit

Permalink
Context: missing setOptions() throws exception [Closes nette#115]
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Nov 11, 2010
1 parent 87a7911 commit 531fdb7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Nette/Utils/Context.php
Expand Up @@ -123,8 +123,12 @@ public function getService($name, array $options = NULL)
throw new AmbiguousServiceException("Cannot instantiate service '$name', class '$factory' not found.");
}
$service = new $factory;
if ($options && method_exists($service, 'setOptions')) {
$service->setOptions($options); // TODO: better!
if ($options) {
if (method_exists($service, 'setOptions')) {
$service->setOptions($options); // TODO: better!
} else {
throw new \InvalidStateException("Unable to set options, method $factory::setOptions() is missing.");
}
}

} else { // factory callback
Expand Down

0 comments on commit 531fdb7

Please sign in to comment.