Skip to content
This repository has been archived by the owner on Jul 12, 2019. It is now read-only.

Commit

Permalink
Rewrite code for service with parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
ovr committed Sep 9, 2014
1 parent a5553f5 commit 3ea927f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Application.php
Expand Up @@ -122,7 +122,13 @@ public function registerServices()
$service = $class;
} else if (isset($serviceParameters['__construct'])) {
$shared = true;
$service = new $class($serviceParameters['__construct']);

if (!is_array($serviceParameters)) {
throw new \Exception('Parameters for service : "' . $serviceName . '" must be array');
}

$reflector = new \ReflectionClass($class);
$service = $reflector->newInstanceArgs($serviceParameters);
} else {
if ($shared) {
$service = new $class();
Expand Down

0 comments on commit 3ea927f

Please sign in to comment.