/** @inheritdoc */ public function execute(Request $request, Router $router) { if ($this->getState()->getUserId()) { return new Redirect($router->getUrlFromAction(Index::class)); } /** @var LoginResponder $responder */ $responder = $this->prepareResponder(new LoginResponder()); if ($request->isMethod(Request::METHOD_POST)) { $responder->setMessage($this->translator->translate('wrong_credentials')); } $responder->setCredentials($request->getPostParam('username'), $request->getPostParam('password')); return $responder; }
/** * @expectedException \horses\UnknownRouteException */ public function testRouteUnknown() { $request = $this->getBasicMock('\\horses\\Request'); $request->query = $this->getBasicMock('\\Symfony\\Component\\HttpFoundation\\ParameterBag'); $request->expects($this->any())->method('getPathInfo')->will($this->returnValue('/unknown')); $this->router->route($request); }
/** @inheritdoc */ public function execute(Request $request, Router $router) { /** @var ArticleEditResponder $responder */ $responder = $this->prepareResponder(new ArticleEditResponder()); if ($request->isMethod(Request::METHOD_POST)) { // $responder->setArticle($article); // return $responder; } if ($request->getGetParam('id')) { $article = $this->entityManager->getRepository('stagecoach\\journal\\Article')->findOneBy(['id' => $request->getGetParam('id')]); if (!$article) { return new Redirect($router->getUrlFromAction(ArticleList::class), $this->translator->translate('article_not_found')); } } else { $article = new Article(); } $responder->setArticle($article); return $responder; }
/** * @param string $actionClassName * @param string[] $queryStringParameters * @return string */ public function linkToAction($actionClassName, array $queryStringParameters = []) { return $this->router->getUrlFromAction($actionClassName, $queryStringParameters); }
/** * Redirects to another module and action * @param string $route The "module/action" combo in one string * @param array $query Query string parameters, will be in the url itself * @param array $options Options for the router */ protected function redirect($route, array $query = array(), array $options = array()) { $this->router->redirect(new Route($route, $query, $options)); }