當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。