當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ResponseInterface::withRedirect方法代碼示例

本文整理匯總了PHP中Psr\Http\Message\ResponseInterface::withRedirect方法的典型用法代碼示例。如果您正苦於以下問題:PHP ResponseInterface::withRedirect方法的具體用法?PHP ResponseInterface::withRedirect怎麽用?PHP ResponseInterface::withRedirect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Psr\Http\Message\ResponseInterface的用法示例。


在下文中一共展示了ResponseInterface::withRedirect方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: callback

 /**
  *
  * @param Request $request            
  * @param Response $response            
  * @param array $args            
  */
 public function callback(Request $request, Response $response, $args)
 {
     // cleanup the session
     $this->session->clear();
     if ($this->facebook->getAccessToken()) {
         return $response->withRedirect($this->router->pathFor('home'));
     }
     return $response->withRedirect($this->router->pathFor('login'));
 }
開發者ID:mattimatti,項目名稱:fbconnectquiz,代碼行數:15,代碼來源:AuthController.php

示例2: postSignin

 public function postSignin(Request $request, Response $response, $args)
 {
     $req = $request->getParsedBody();
     $hashed_password = hash('sha1', $req['password']);
     $query = "SELECT * FROM users WHERE email =:email AND password=:password";
     $stmt = $this->db->prepare($query);
     $stmt->execute(['email' => $req['email'], 'password' => $hashed_password]);
     $isExist = $stmt->rowCount();
     $userData = $stmt->fetch(\PDO::FETCH_OBJ);
     if ($isExist == 1) {
         $this->session->set('auth', $userData);
         $this->flash->addMessage('success', 'Login Successful');
         return $response->withRedirect($this->router->pathFor('admin'));
     } else {
         $this->flash->addMessage('error', 'Data Not Found');
         return $response->withRedirect($this->router->pathFor('admin/signup'));
     }
 }
開發者ID:dda2,項目名稱:Pamit,代碼行數:18,代碼來源:AuthController.php

示例3: login

 public function login(Request $req, Response $res, $args)
 {
     $this->logger->info('Login page request');
     if (isset($_POST) && isset($_POST['username']) && isset($_POST['password'])) {
         $user = $this->userManager->getByUsername($_POST['username']);
         $password = hash('sha512', $_POST['password']);
         if ($user && $password == $user->getPassword()) {
             $this->logger->notice('Login succeed [' . $user->getUsername() . ']');
             $_SESSION['login'] = $user->getUsername();
             return $res->withRedirect($this->router->pathFor('login'));
         } else {
             $this->logger->error('Login failed');
             $this->flash->addMessage('error', 'Authentification failed.');
             return $res->withRedirect($this->router->pathFor('login'));
         }
     }
     $this->view->render($res, 'Default/home.html.twig');
     return $res;
 }
開發者ID:jlagneau,項目名稱:Tinda,代碼行數:19,代碼來源:UserController.php

示例4: __invoke

 /**
  * Example middleware invokable class
  *
  * @param  \Psr\Http\Message\ServerRequestInterface $request  PSR7 request
  * @param  \Psr\Http\Message\ResponseInterface      $response PSR7 response
  * @param  callable                                 $next     Next middleware
  *
  * @return \Psr\Http\Message\ResponseInterface
  */
 public function __invoke($request, $response, $next)
 {
     // check if user is authenticated, otherwise return 401/ redirect/ etc
     if (!$this->auth->isAuthenticated()) {
         // return $response->withStatus(401);
         return $response->withRedirect('/session/login', 401);
     }
     // pass onto the next callable
     $response = $next($request, $response);
     return $response;
 }
開發者ID:martynbiz,項目名稱:slim-mvc,代碼行數:20,代碼來源:Auth.php

示例5: get

 /**
  *
  */
 public function get(ServerRequestInterface $request, ResponseInterface $response)
 {
     if (!$this->auth->check()) {
         return $this->auth->redirectToLogin();
     } elseif (!$this->auth->hasAccess(['admin'])) {
         return $response->withRedirect($this->url['root']);
     }
     parent::preparePage();
     $this->importView('Main:sb2/dashboard as content');
     return parent::withBody($response);
 }
開發者ID:a3gz,項目名稱:boilerplate-sb2,代碼行數:14,代碼來源:MainController.php

示例6: put

 /**
  *
  */
 public function put(ServerRequestInterface $request, ResponseInterface $response)
 {
     if (!$this->auth->check()) {
         return $this->auth->redirectToLogin();
     } elseif (!$this->auth->hasAccess(['admin'])) {
         return $response->withRedirect($this->url['root']);
     }
     $data = $request->getParsedBody();
     // Process the input data and generate proper response, specific to each application.
     $responseData = json_encode(['method' => 'PUT', 'data' => $data]);
     return parent::withBody($response, $responseData);
 }
開發者ID:a3gz,項目名稱:boilerplate-sb2,代碼行數:15,代碼來源:Sb2FormsController.php

示例7: __invoke

 /**
  * Remove trailing slash from any request.
  *
  * @param  \Psr\Http\Message\ServerRequestInterface $request
  * @param  \Psr\Http\Message\ResponseInterface      $response
  * @param  callable                                 $next
  *
  * @return \Psr\Http\Message\ResponseInterface
  */
 public function __invoke(Request $request, Response $response, callable $next)
 {
     $uri = $request->getUri();
     $path = $uri->getPath();
     if ($path != '/' && substr($path, -1) == '/') {
         // permanently redirect paths with a trailing slash
         // to their non-trailing counterpart
         $uri = $uri->withPath(substr($path, 0, -1));
         return $response->withRedirect((string) $uri, 301);
     }
     return $next($request, $response);
 }
開發者ID:lchski,項目名稱:api.lucascherkewski.com,代碼行數:21,代碼來源:TrailingSlashMiddleware.php

示例8: get

 /**
  *
  */
 public function get(ServerRequestInterface $request, ResponseInterface $response)
 {
     if (!$this->auth->check()) {
         return $this->auth->redirectToLogin();
     } elseif (!$this->auth->hasAccess(['admin'])) {
         return $response->withRedirect($this->url['root']);
     }
     parent::preparePage();
     $args = func_get_arg(2);
     $this->importView("Sb2:{$args['view']} as content");
     return parent::withBody($response);
 }
開發者ID:a3gz,項目名稱:boilerplate-sb2,代碼行數:15,代碼來源:Sb2GeneralController.php

示例9: __invoke

 /**
  * @param  Container         $container A DI (Pimple) container.
  * @param  RequestInterface  $request   A PSR-7 compatible Request instance.
  * @param  ResponseInterface $response  A PSR-7 compatible Response instance.
  * @return ResponseInterface
  */
 public function __invoke(Container $container, RequestInterface $request, ResponseInterface $response)
 {
     $config = $this->config();
     // Handle explicit redirects
     if (!empty($config['redirect'])) {
         $uri = $this->parseRedirect($config['redirect'], $request);
         if ($uri) {
             return $response->withRedirect($uri, $config['redirect_mode']);
         }
     }
     $templateContent = $this->templateContent($container, $request);
     $response->write($templateContent);
     return $response;
 }
開發者ID:locomotivemtl,項目名稱:charcoal-app,代碼行數:20,代碼來源:TemplateRoute.php

示例10: listAll

 /**
  * 
  */
 public function listAll(ServerRequestInterface $request, ResponseInterface $response)
 {
     if (!$this->auth->check()) {
         return $this->auth->redirectToLogin();
     } elseif (!$this->auth->hasAccess($this->requiredPermissions)) {
         return $response->withRedirect($this->app['urlRoot']);
     }
     parent::preparePage();
     $rolesModel = new Models\Roles();
     $rst = $rolesModel->selectAll();
     $this->importView("Auth:roles/list-all as content");
     $url_Roles = Auth::getUrlRoot() . "/auth/roles";
     $this->template->setData(['rst' => $rst, 'txt_pageTitle' => $this->locale->say('roles page title'), 'txt_th_Name' => $this->locale->say('roles table title name'), 'txt_th_Slug' => $this->locale->say('roles table title slug'), 'txt_th_Permissions' => $this->locale->say('roles table title permissions'), 'txt_btn_NewRole' => $this->locale->say('roles table btn new role'), 'url_Roles' => $url_Roles, 'url_NewRole' => "{$url_Roles}/0"]);
     return parent::withBody($response);
 }
開發者ID:a3gz,項目名稱:bp-auth,代碼行數:18,代碼來源:RolesController.php

示例11: __invoke

 public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
 {
     $path = $request->getUri()->getPath();
     if ($path == '/install') {
         if (file_exists(DATABASE . DS . 'config.yml')) {
             return $response->withRedirect('/');
         }
         return $next($request, $response);
     } elseif ($path == '/api/v1/install') {
         return $next($request, $response);
     } elseif ($path != '/install') {
         if (!file_exists(DATABASE . DS . 'config.yml')) {
             return $response->withRedirect('install');
         }
         return $next($request, $response);
     }
     return $next($request, $response);
 }
開發者ID:fdisotto,項目名稱:fcbr,代碼行數:18,代碼來源:InstallMiddleware.php

示例12: logoutAndRediret

 private function logoutAndRediret(Response $res, $message)
 {
     $this->authService->clearIdentity();
     $this->flash->addMessage('danger', $message);
     return $res->withRedirect($this->unitNotFoundRedirectUrl);
 }
開發者ID:eellak,項目名稱:gredu_labs,代碼行數:6,代碼來源:CreateSchool.php

示例13: resultsdelete

 /**
  *
  * @param Request $request            
  * @param Response $response            
  * @param unknown $args            
  */
 public function resultsdelete(Request $request, Response $response, $args)
 {
     $id = $args['id'];
     $record = R::load(USER, $id);
     if ($record) {
         R::trash($record);
     }
     return $response->withRedirect($this->router->pathFor('results'));
 }
開發者ID:mattimatti,項目名稱:fbconnectquiz,代碼行數:15,代碼來源:AdminController.php

示例14: deallocate_action

 /**
  * Deallocate a user's current resource
  *
  * @param  \Psr\Http\Message\ServerRequestInterface $request  PSR7 request
  * @param  \Psr\Http\Message\ResponseInterface      $response PSR7 response
  * @param  array                                    $args     Args passed in from URL
  * @return \Psr\Http\Message\ResponseInterface                Final PSR7 response
  */
 public function deallocate_action($request, $response, $args)
 {
     $resource_id = $request->getParsedBody()['resource_id'];
     $this->resource_action->destroy_resource($resource_id);
     return $response->withRedirect($this->router->pathFor('list-resources'));
 }
開發者ID:drakenya,項目名稱:resource-allocation,代碼行數:14,代碼來源:ResourceController.php

示例15: delete

 public function delete(Request $request, Response $response, $args)
 {
     $kpi_entity = $this->em->getRepository('App\\Entity\\Kpi')->findOneById($args['id']);
     $this->em->remove($kpi_entity);
     $this->em->flush();
     return $response->withRedirect($this->router->pathFor('kpi'));
 }
開發者ID:andrearruda,項目名稱:kpi,代碼行數:7,代碼來源:KpiController.php


注:本文中的Psr\Http\Message\ResponseInterface::withRedirect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。