/** * Get and serve the controller * * @param Route $route * @return mixed * @throws \Exception */ public function dispatch(Route $route) { $callback = $route->getCallback(); $params = array_values($route->getData()); if ($callback instanceof Closure) { return $this->container->resolveClosure($callback, $params); } $class = $this->container->make($callback[0]); return $this->container->resolveMethod($class, $callback[1], $params); }
public function testResolveClassWithPrimitivesAndInterfaces() { $c = new Container(); $c->bind('IUnitTestSomeRepo', 'UnitTestSomeRepo'); $class = $c->make('UTestController', [10, 20]); $this->assertEquals(10, $class->x); $this->assertEquals(20, $class->y); $this->assertInstanceOf('UnitTestSomeRepo', $class->repo); }