/** * Dispatch a remote method call. * * @param Neton\DirectBundle\Router\Call $call * @return Mixed */ private function dispatch($call) { $controller = $this->resolveController($call->getAction()); $method = $call->getMethod() . "Action"; if (!is_callable(array($controller, $method))) { //todo: throw an execption method not callable } if ('form' == $this->request->getCallType()) { $result = $call->getResponse($controller->{$method}($call->getData(), $this->request->getFiles())); } else { $result = $call->getResponse($controller->{$method}($call->getData())); } return $result; }
/** * Dispatch a remote method call. * * @param Neton\DirectBundle\Router\Call $call * @return Mixed */ private function dispatch($call) { $api = new ControllerApi($this->container, $this->getControllerClass($call->getAction())); $controller = $this->resolveController($call->getAction()); $method = $call->getMethod() . "Action"; $accessType = $api->getMethodAccess($method); if (!is_callable(array($controller, $method))) { //todo: throw an execption method not callable return false; } else { if ($this->defaultAccess == 'secure' && $accessType != 'anonymous') { if (!$this->session) { $result = $call->getException(new \Exception('Access denied!')); } } else { if ($accessType == 'secure') { if (!$this->session) { $result = $call->getException(new \Exception('Access denied!')); } } else { if ('form' == $this->request->getCallType()) { $result = $call->getResponse($controller->{$method}($call->getData(), $this->request->getFiles())); } } } } if (!isset($result)) { try { //$result = call_user_func_array(array($controller, $method), $call->getData()); $result = $controller->{$method}($call->getData()); $result = $call->getResponse($result); } catch (\Exception $e) { $result = $call->getException($e); } } return $result; }