/** * Redirect to another URL and ends presenter execution. * @param string * @param int HTTP error code * @return void * @throws Nette\Application\AbortException */ public function redirectUrl($url, $code = NULL) { if ($this->isAjax()) { $this->payload->redirect = (string) $url; $this->sendPayload(); } elseif (!$code) { $code = $this->httpRequest->isMethod('post') ? Http\IResponse::S303_POST_GET : Http\IResponse::S302_FOUND; } $this->sendResponse(new Responses\RedirectResponse($url, $code)); }
/** * Tries to match request * * @param \Nette\Http\IRequest $httpRequest * * @return \Nette\Application\Request|NULL */ public function match(\Nette\Http\IRequest $httpRequest) { foreach ($this->methods as $method) { // method is not matched, return null if ($httpRequest->isMethod($method)) { return parent::match($httpRequest); } } return null; }
/** * Signal for receive a response from gateway. */ public function handleResponse() { $data = $this->httpRequest->isMethod(IRequest::POST) ? $this->httpRequest->getPost() : $this->httpRequest->getQuery(); $response = NULL; try { $response = $this->client->receiveResponse($data); } catch (Csob\Exception $e) { if ($response === NULL && $e instanceof Csob\ExceptionWithResponse) { $response = $e->getResponse(); } $this->onError($this, $e, $response); return; } $this->onResponse($this, $response); }
/** * Handles incoming request and sets translations. */ private function processRequest() { if ($this->httpRequest->isMethod('post') && $this->httpRequest->isAjax() && $this->httpRequest->getHeader(self::XHR_HEADER)) { $data = json_decode(file_get_contents('php://input')); if ($data) { $this->translator->setCurrentLang($data->{self::LANGUAGE_KEY}); if ($data->{self::NAMESPACE_KEY}) { $this->translator->setNamespace($data->{self::NAMESPACE_KEY}); } unset($data->{self::LANGUAGE_KEY}, $data->{self::NAMESPACE_KEY}); foreach ($data as $string => $translated) { $this->translator->setTranslation($string, $translated); } } exit; } }
/** * @inheritdoc */ public function isMethod($method) { return $this->current->isMethod($method); }