private function _callControllerMethod(AppRequest $appRequest, ControllerRoute $route) { if (!method_exists($this->calledController, $route->getRoutePointer()->getMethodName())) { throw new AemosCriticalException("unknown page method", HttpStatusCode::notFound()); } call_user_func_array(array($this->calledController, $route->getRoutePointer()->getMethodName()), $route->getParameters($appRequest->getRequestUrl())); }
/** * @param string $action_name * @param array $args */ function doAction($action_name = null, $args = array()) { // todo: this probably belongs somewhere else if ($this->isRestful()) { $has_id = false; if ((string) (int) $action_name === (string) $action_name) { array_unshift($args, $action_name); $action_name = null; $has_id = true; } if (!$action_name) { switch ($this->route->getHttpVerb()) { case 'POST': case 'PUT': $action_name = 'save'; break; case 'GET': if ($has_id) { $action_name = 'show'; } break; case 'DELETE': if ($has_id) { $action_name = 'delete'; } break; } } } if (!$action_name) { $action_name = DEFAULT_CONTROLLER; } $method_name = str_replace(array('-', '_', ' '), '', $action_name); $view = $this->getView($action_name); if (!is_array($args) && !$args instanceof ArrayObject) { $args = array($args); } if (!method_exists($this, $method_name) && !method_exists($this, '__call') || strpos($action_name, '_') === 0) { file_not_found($view); } $result = call_user_func_array(array($this, $method_name), $args); if (!$this->loadView) { return; } if ($this->isRestful()) { $this->loadView($view, $result); } else { $this->loadView($view); } }
public function equals(ControllerRoute $otherRoute) { if (!$otherRoute instanceof ControllerRoute) { return false; } if ($otherRoute == null) { return false; } if ($otherRoute->getRoot() != $this->getRoot()) { return false; } if ($otherRoute->getLength() != $this->getLength()) { return false; } return $this->compareVariables($otherRoute) && $this->compareMethods($otherRoute); }
public function testSetRequestParamsDetectsJsonPCallback() { $this->route->setRequestParams(array('callback' => 'myCallback')); $this->assertEquals('jsonp', $this->route->getExtension()); $this->assertEquals('myCallback', $this->route->getJsonPCallback()); }