当前位置: 首页>>代码示例>>PHP>>正文


PHP Response::setRedirect方法代码示例

本文整理汇总了PHP中Symfony\Component\HttpFoundation\Response::setRedirect方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::setRedirect方法的具体用法?PHP Response::setRedirect怎么用?PHP Response::setRedirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\HttpFoundation\Response的用法示例。


在下文中一共展示了Response::setRedirect方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: start

 /**
  * {@inheritdoc}
  */
 public function start(Request $request, AuthenticationException $authException = null)
 {
     if ($this->useForward) {
         return $event->getSubject()->handle(Request::create($this->loginPath), HttpKernelInterface::SUB_REQUEST);
     }
     $response = new Response();
     $response->setRedirect(0 !== strpos($this->loginPath, 'http') ? $request->getUriForPath($this->loginPath) : $this->loginPath, 302);
     return $response;
 }
开发者ID:notbrain,项目名称:symfony,代码行数:12,代码来源:FormAuthenticationEntryPoint.php

示例2: handle

 /**
  * 
  *
  * @param Event $event An Event instance
  */
 public function handle(Event $event)
 {
     $request = $event->getParameter('request');
     if ($this->logoutPath !== $request->getPathInfo()) {
         return;
     }
     $this->securityContext->setToken(null);
     $request->getSession()->invalidate();
     $response = new Response();
     $response->setRedirect(0 !== strpos($this->targetUrl, 'http') ? $request->getUriForPath($this->targetUrl) : $this->targetUrl, 302);
     $event->setReturnValue($response);
     return true;
 }
开发者ID:rsky,项目名称:symfony,代码行数:18,代码来源:LogoutListener.php

示例3: handle

 /**
  * Performs the logout if requested
  *
  * @param Event $event An Event instance
  */
 public function handle(Event $event)
 {
     $request = $event->get('request');
     if ($this->logoutPath !== $request->getPathInfo()) {
         return;
     }
     $response = new Response();
     $response->setRedirect(0 !== strpos($this->targetUrl, 'http') ? $request->getUriForPath($this->targetUrl) : $this->targetUrl, 302);
     $token = $this->securityContext->getToken();
     foreach ($this->handlers as $handler) {
         $handler->logout($request, $response, $token);
     }
     $this->securityContext->setToken(null);
     $event->setReturnValue($response);
     return true;
 }
开发者ID:spf13,项目名称:symfony,代码行数:21,代码来源:LogoutListener.php

示例4: handle

 /**
  * Performs the logout if requested
  *
  * @param EventInterface $event An EventInterface instance
  */
 public function handle(EventInterface $event)
 {
     $request = $event->get('request');
     if ($this->logoutPath !== $request->getPathInfo()) {
         return;
     }
     $response = new Response();
     $response->setRedirect(0 !== strpos($this->targetUrl, 'http') ? $request->getUriForPath($this->targetUrl) : $this->targetUrl, 302);
     // handle multiple logout attempts gracefully
     if ($token = $this->securityContext->getToken()) {
         foreach ($this->handlers as $handler) {
             $handler->logout($request, $response, $token);
         }
     }
     $this->securityContext->setToken(null);
     $event->setProcessed();
     return $response;
 }
开发者ID:faridos,项目名称:ServerGroveLiveChat,代码行数:23,代码来源:LogoutListener.php

示例5: start

 public function start(Request $request, AuthenticationException $authException = null)
 {
     $scheme = $request->isSecure() ? 'http' : 'https';
     if ('http' === $scheme && 80 != $this->httpPort) {
         $port = ':' . $this->httpPort;
     } elseif ('https' === $scheme && 443 != $this->httpPort) {
         $port = ':' . $this->httpsPort;
     } else {
         $port = '';
     }
     $qs = $request->getQueryString();
     if (null !== $qs) {
         $qs = '?' . $qs;
     }
     $url = $scheme . '://' . $request->getHost() . $port . $request->getScriptName() . $request->getPathInfo() . $qs;
     $response = new Response();
     $response->setRedirect($url, 301);
     return $response;
 }
开发者ID:notbrain,项目名称:symfony,代码行数:19,代码来源:RetryAuthenticationEntryPoint.php

示例6: onSuccess

 protected function onSuccess(Request $request, TokenInterface $token)
 {
     if (null !== $this->logger) {
         $this->logger->debug('User has been authenticated successfully');
     }
     $this->securityContext->setToken($token);
     $session = $request->getSession();
     $session->remove(SecurityContext::AUTHENTICATION_ERROR);
     $session->remove(SecurityContext::LAST_USERNAME);
     $response = new Response();
     $path = $this->determineTargetUrl($request);
     $response->setRedirect(0 !== strpos($path, 'http') ? $request->getUriForPath($path) : $path, 302);
     return $response;
 }
开发者ID:rsky,项目名称:symfony,代码行数:14,代码来源:FormAuthenticationListener.php

示例7: handle

 /**
  * Handles digest authentication.
  *
  * @param Event $event An Event instance
  */
 public function handle(Event $event)
 {
     $request = $event->getParameter('request');
     if (!$request->get($this->usernameParameter)) {
         return;
     }
     if ('_exit' === $request->get($this->usernameParameter)) {
         $this->securityContext->setToken($this->attemptExitUser($request));
     } else {
         try {
             $this->securityContext->setToken($this->attemptSwitchUser($request));
         } catch (AuthenticationException $e) {
             if (null !== $this->logger) {
                 $this->logger->debug(sprintf('Switch User failed: "%s"', $e->getMessage()));
             }
         }
     }
     $response = new Response();
     $request->server->set('QUERY_STRING', '');
     $response->setRedirect($request->getUri(), 302);
     $event->setReturnValue($response);
     return true;
 }
开发者ID:rsky,项目名称:symfony,代码行数:28,代码来源:SwitchUserListener.php

示例8: onSuccess

 protected function onSuccess(EventInterface $event, Request $request, TokenInterface $token)
 {
     if (null !== $this->logger) {
         $this->logger->debug('User has been authenticated successfully');
     }
     $this->securityContext->setToken($token);
     $session = $request->getSession();
     $session->remove(SecurityContext::AUTHENTICATION_ERROR);
     $session->remove(SecurityContext::LAST_USERNAME);
     if (null !== $this->eventDispatcher) {
         $this->eventDispatcher->notify(new Event($this, 'security.interactive_login', array('request' => $request, 'token' => $token)));
     }
     if (null !== $this->successHandler) {
         $response = $this->successHandler->onAuthenticationSuccess($request, $token);
     } else {
         $response = new Response();
         $path = $this->determineTargetUrl($request);
         $response->setRedirect(0 !== strpos($path, 'http') ? $request->getUriForPath($path) : $path, 302);
     }
     if (null !== $this->rememberMeServices) {
         $this->rememberMeServices->loginSuccess($request, $response, $token);
     }
     return $response;
 }
开发者ID:faridos,项目名称:ServerGroveLiveChat,代码行数:24,代码来源:AbstractAuthenticationListener.php


注:本文中的Symfony\Component\HttpFoundation\Response::setRedirect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。