Beispiel #1
0
 /**
  * Create controller object
  *
  * @param \Janeiro\Request\AbstractRequest $request
  * @throws \Janeiro\Mvc\Exception
  * @return array
  */
 private function getController(AbstractRequest $request)
 {
     if (false === ($target = $this->getControllerClassAndMethod())) {
         throw new Exception('Resource not found', Exception::HTTP_NOT_FOUND);
     }
     list($class, $method) = $target;
     $controllerReflector = $this->container->getFactory($class)->getReflection();
     $methodAnnotation = $controllerReflector->getAnnotation('method', $method, $request->getMethod());
     if (false === in_array($request->getMethod(), explode(',', $methodAnnotation))) {
         throw new Exception(sprintf('%s method not allowed', $request->getMethod()), Exception::HTTP_METHOD_NOT_ALLOWED);
     }
     $this->view->init($class, $method);
     return [$this->container->resolve($class, null), $method];
 }