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


PHP RedirectResponse::setTargetUrl方法代碼示例

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


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

示例1: onRegistrationCompleted

 public function onRegistrationCompleted(FilterUserResponseEvent $event)
 {
     $user = $event->getUser();
     $tenantName = $this->_form->get('tenantName')->getData();
     $tenantSubdomain = $this->_form->get('tenantSubdomain')->getData();
     $tenant = $this->registrationManager->createTenant($user, $tenantName, $tenantSubdomain);
     // this referenced redirect response will be used
     $this->redirectResponse->setTargetUrl($this->tenantAwareRouter->generateUrl($tenant));
     unset($this->_form);
 }
開發者ID:adrianoaguiar,項目名稱:multi-tenancy-bundle,代碼行數:10,代碼來源:RegistrationSubscriber.php

示例2: setTargetUrl

 /**
  * {@inheritdoc}
  */
 public function setTargetUrl($url)
 {
     if (!$this->isSafe($url)) {
         throw new \InvalidArgumentException(sprintf('It is not safe to redirect to %s', $url));
     }
     return parent::setTargetUrl($url);
 }
開發者ID:HakS,項目名稱:drupal8_training,代碼行數:10,代碼來源:SecuredRedirectResponse.php

示例3: setTargetUrl

 public function setTargetUrl($url)
 {
     if ($url == '') {
         $url = '/';
     }
     return parent::setTargetUrl($url);
     // TODO: Change the autogenerated stub
 }
開發者ID:ppiedaderawnet,項目名稱:concrete5,代碼行數:8,代碼來源:RedirectResponse.php

示例4: handleNoBackendAccess

 /**
  * When redirecting to the backend dashboard (while logged in),
  * if the user does not have access change the redirect to the homepage.
  *
  * @param \Symfony\Component\HttpFoundation\RedirectResponse $response
  */
 protected function handleNoBackendAccess(RedirectResponse $response)
 {
     $authCookie = $this->session->get('authentication');
     if (!$this->authentication->isValidSession((string) $authCookie)) {
         return;
     }
     $dashboardPath = $this->urlGenerator->generate('dashboard');
     $dashboardAccess = $this->users->isAllowed('dashboard');
     if ($response->getTargetUrl() === $dashboardPath && !$dashboardAccess) {
         $this->session->getFlashBag()->clear();
         $response->setTargetUrl($this->urlGenerator->generate('homepage'));
     }
 }
開發者ID:nectd,項目名稱:nectd-web,代碼行數:19,代碼來源:RedirectListener.php

示例5: onKernelRequest

 /**
  * @param GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     if ($this->kernel->getEnvironment() == 'test' || HttpKernel::MASTER_REQUEST != $event->getRequestType()) {
         // don't do anything if it's not the master request
         return;
     }
     $request = $event->getRequest();
     if ($request->attributes->get('_route') != 'page_promotion' || $request->getHost() == 'stfalcon.de' || $request->query->has('_check')) {
         return;
     }
     $response = new RedirectResponse('/');
     $locale = $this->geoIpService->getLocaleByIp($request->getClientIp());
     if ($request->getLocale() == $locale) {
         return;
     }
     $currentRouteParams = array_replace($request->attributes->get('_route_params'), ['_locale' => $locale]);
     $redirectUrl = $this->router->generate($request->attributes->get('_route'), $currentRouteParams);
     $response->setTargetUrl($redirectUrl);
     $event->setResponse($response);
 }
開發者ID:alienpham,項目名稱:portfolio,代碼行數:23,代碼來源:LocaleListener.php

示例6: testSetTargetUrl

 public function testSetTargetUrl()
 {
     $response = new RedirectResponse('foo.bar');
     $response->setTargetUrl('baz.beep');
     $this->assertEquals('baz.beep', $response->getTargetUrl());
 }
開發者ID:newism,項目名稱:symfony,代碼行數:6,代碼來源:RedirectResponseTest.php

示例7: testSetTargetUrlNull

 /**
  * @expectedException \InvalidArgumentException
  */
 public function testSetTargetUrlNull()
 {
     $response = new RedirectResponse('foo.bar');
     $response->setTargetUrl(null);
 }
開發者ID:BusinessCookies,項目名稱:CoffeeMachineProject,代碼行數:8,代碼來源:RedirectResponseTest.php


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