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