function _requestUrl() { return Gongo_Str::startsWith($this->requestPath, '/') ? $this->requestPath : '/' . $this->requestPath; }
public function executeController($app, $controller, $e = array()) { $eAction = isset($e['action']) ? $e['action'] : $app->args->__action__; $eMethod = strtolower(isset($e['method']) ? $e['method'] : $app->server->REQUEST_METHOD); $request = array(); if ($eMethod === 'get') { $request = $app->get->_(); } else { if ($eMethod === 'post') { $request = $app->post->_(); } } $eRequest = isset($e['submit']) ? array_merge($request, array($e['submit'] => '')) : $request; $eSecure = isset($e['https']) ? $e['https'] : $app->env()->path->https; $this->currentAction = $eAction; $methodName = $this->makeControllerMethodName($eAction, $eMethod, $eRequest); if ($this->buttonName) { if ($eMethod === 'get') { unset($app->get->{$this->buttonName}); } else { if ($eMethod === 'post') { unset($app->post->{$this->buttonName}); } } } $methodName .= $eSecure ? $this->options->secureMethod : ''; if (!method_exists($controller, $methodName)) { return $app->error('404'); } $this->controller = $controller; $this->methodName = $methodName; $argStr = $app->args->__args__; if ($this->options->useExtension && preg_match('/^(\\.(?:' . $this->options->extension . '))/', $argStr, $m)) { $argStr = substr($argStr, strlen($m[1])); $app->args->__args__ = $argStr; $this->currentExtension = $m[1]; } $this->currentArgs = $argStr; $sep = $this->options->argSeparator; $refl = new ReflectionMethod($controller, $methodName); $numOfRequiredParams = $refl->getNumberOfRequiredParameters(); if ($argStr == '') { if ($numOfRequiredParams != 1) { return $app->error('404'); } return call_user_func(array($controller, $methodName), $app); } if (!Gongo_Str::startsWith($argStr, $sep)) { return $app->error('404'); } $argArr = array_map('urldecode', explode($sep, substr($argStr, 1))); $args = array_merge(array($app), $argArr); if (count($args) < $numOfRequiredParams) { return $app->error('404'); } foreach ($refl->getParameters() as $p) { $pos = $p->getPosition(); if ($pos !== 0) { $name = $p->getName(); $app->args->{$name} = isset($args[$pos]) ? $args[$pos] : null; $this->currentArgMaps[$pos] = ':' . $name; } } ksort($this->currentArgMaps); return call_user_func_array(array($controller, $methodName), $args); }