/**
  * @param User $user
  * @throws InvalidStateException
  * @throws AbortException
  */
 public function onLoggedIn(User $user)
 {
     if (!$this->presenter) {
         throw new InvalidStateException('Presenter not set');
     }
     if ($this->presenter instanceof Presenter && $this->presenter->getSession(OAuth2Presenter::SESSION_NAMESPACE)->authorizationRequest) {
         $this->presenter->redirect(...$this->redirectConfig->getApproveDestination());
     }
 }
Пример #2
0
 /**
  * @param $signal
  */
 public function signalReceived($signal)
 {
     $params = $this->presenter->popGlobalParameters($this->lookupPath('Nette\\Application\\UI\\Presenter', TRUE));
     if ($signal === 'remote') {
         $this->handleRemote($params);
     }
 }
Пример #3
0
 /**
  * Restores current request to session.
  * @param  string key
  * @return void
  */
 public function restoreRequest($key)
 {
     $session = $this->context->session->getSection('Nette.Application/requests');
     if (isset($session[$key])) {
         $request = clone $session[$key];
         unset($session[$key]);
         $request->setFlag(Request::RESTORED, TRUE);
         $this->presenter->sendResponse(new Responses\ForwardResponse($request));
     }
 }
Пример #4
0
 /**
  * @return void
  */
 public function processException(\Exception $e)
 {
     if (!$this->httpResponse->isSent()) {
         $this->httpResponse->setCode($e instanceof BadRequestException ? $e->getCode() ?: 404 : 500);
     }
     $args = array('exception' => $e, 'request' => end($this->requests) ?: NULL);
     if ($this->presenter instanceof UI\Presenter) {
         try {
             $this->presenter->forward(":{$this->errorPresenter}:", $args);
         } catch (AbortException $foo) {
             $this->processRequest($this->presenter->getLastCreatedRequest());
         }
     } else {
         $this->processRequest(new Request($this->errorPresenter, Request::FORWARD, $args));
     }
 }
Пример #5
0
 protected function checkAjaxForm($destination, $formName, $post = [], $path = FALSE)
 {
     if (is_string($path)) {
         $this->checkForm($destination, $formName, $post, $path);
         Assert::false($this->__testbench_presenter->isAjax());
     }
     $this->__testbench_presenter = NULL;
     //FIXME: not very nice, but performance first
     $this->__testbench_ajaxMode = TRUE;
     $response = $this->check($destination, ['do' => $formName . '-submit'], $post);
     Assert::true($this->__testbench_presenter->isAjax());
     if (!$this->__testbench_exception) {
         Assert::same(200, $this->getReturnCode());
         Assert::type('Nette\\Application\\Responses\\JsonResponse', $response);
     }
     $this->__testbench_presenter = NULL;
     $this->__testbench_ajaxMode = FALSE;
     return $response;
 }
Пример #6
0
 /** @deprecated */
 function restoreRequest($key)
 {
     trigger_error(__METHOD__ . '() is deprecated; use $presenter->restoreRequest() instead.', E_USER_DEPRECATED);
     return $this->presenter->restoreRequest($key);
 }
Пример #7
0
 /** @deprecated */
 function restoreRequest($key)
 {
     return $this->presenter->restoreRequest($key);
 }
Пример #8
0
 public function register(Application\Application $application, Application\IPresenter $presenter)
 {
     if (!$this->parent && $presenter instanceof Application\UI\PresenterComponent) {
         $presenter->addComponent($this, "_fakeLogin");
     }
 }
Пример #9
0
 /**
  * @param  Application\IPresenter $presenter
  * @param  string                 $presenterName is fully qualified presenter name (module:module:presenter)
  * @param  string                 $action
  * @param  string                 $method
  * @param  array                  $params
  * @param  array                  $post
  * @return Application\IResponse
  */
 private function processRequest(Application\IPresenter $presenter, $presenterName, $action, $method, $params, $post)
 {
     $params['action'] = $action;
     $req = new Application\Request($presenterName, $method, $params, $post);
     return $presenter->run($req);
 }
Пример #10
0
 /**
  * Creates payload structure for HATEOAS link
  *
  * @param string rel
  * @param string target
  * @param array parameters
  *
  * @return array
  * @throws Nette\InvalidArgumentException
  */
 public function hateoasLink($rel = 'self', $target = NULL, array $params = array())
 {
     list($class, $method) = $this->parseLinkTarget($target);
     list($httpMethod, $path, $addtionalParams) = $this->presenter->requestRouter->createUrl($class, $method, $params);
     return array('rel' => $rel, 'href' => $this->presenter->link($path, $addtionalParams), 'method' => $httpMethod);
 }
Пример #11
0
 public function request($method, $params, $post = [], $files = [], $flags = [])
 {
     $request = new Request(static::$presenterName, $method, $params, $post, $files, $flags);
     $response = $this->presenter->run($request);
     return $response;
 }