本文整理汇总了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);
}
示例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);
}
示例3: setTargetUrl
public function setTargetUrl($url)
{
if ($url == '') {
$url = '/';
}
return parent::setTargetUrl($url);
// TODO: Change the autogenerated stub
}
示例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'));
}
}
示例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);
}
示例6: testSetTargetUrl
public function testSetTargetUrl()
{
$response = new RedirectResponse('foo.bar');
$response->setTargetUrl('baz.beep');
$this->assertEquals('baz.beep', $response->getTargetUrl());
}
示例7: testSetTargetUrlNull
/**
* @expectedException \InvalidArgumentException
*/
public function testSetTargetUrlNull()
{
$response = new RedirectResponse('foo.bar');
$response->setTargetUrl(null);
}