Example #1
0
 /**
  * Method injection resolver
  *
  * @param $action
  * @param $params
  * @return mixed
  */
 protected function resolve($action, $params)
 {
     if ($action instanceof Closure) {
         return $action($params);
     }
     list($controller, $method) = $action;
     $reflect = new ReflectionClass($controller);
     foreach (array_filter($reflect->getMethod($method)->getParameters(), $this->getParams()) as $param) {
         array_unshift($params, $this->registry->make($param->getClass()->getName()));
     }
     return $reflect->getMethod($method)->invokeArgs($this->registry->make($controller), $params);
 }
Example #2
0
 public function testAutoResolvesMultipleTypeHints()
 {
     $registry = Registry::init();
     $instance = $registry->make('RegistryWithMultipleDependencies');
     $this->assertInstanceOf('Foo', $instance->getFoo());
     $this->assertInstanceOf('Bar', $instance->getBar());
 }
Example #3
0
 /**
  * @return Collection
  */
 protected function loadRoutes()
 {
     $router = $this->container->make('routes');
     $routes = realpath($this->getPath() . '/app/routes.php');
     if (file_exists($routes)) {
         require $routes;
     }
     return $router;
 }