当前位置: 首页>>代码示例>>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;未经允许,请勿转载。