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


PHP RedirectResponse::send方法代码示例

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


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

示例1: listener

 public static function listener(RequestEvent $requestEvent)
 {
     $request = $requestEvent->getRequest();
     $pathInfo = $request->getPathInfo();
     $session = $requestEvent->getSession();
     $configSecurity = $requestEvent->getSecurityConfig();
     $routes = $requestEvent->getRoutes();
     $context = new RequestContext();
     $matcher = new UrlMatcher($routes, $context);
     $context->fromRequest($request);
     $matching = $matcher->match($pathInfo);
     $matchedRoute = $matching['_route'];
     if (isset($configSecurity['protected'])) {
         $protected = $configSecurity['protected'];
         $protectedRoutes = $protected['routes'];
         $sessionKey = $protected['session'];
         $notLoggedRoute = $protected['not_logged'];
         $loggedRoute = $protected['logged'];
         $redirectRoute = null;
         if ($session->get($sessionKey) && $matchedRoute === $notLoggedRoute) {
             $redirectRoute = $routes->get($loggedRoute);
         }
         if (!$session->get($sessionKey) && in_array($matchedRoute, $protectedRoutes)) {
             $redirectRoute = $routes->get($notLoggedRoute);
         }
         if ($redirectRoute) {
             $redirectResponse = new RedirectResponse($request->getBaseUrl() . $redirectRoute->getPath());
             $redirectResponse->send();
         }
     }
 }
开发者ID:zyncro,项目名称:framework,代码行数:31,代码来源:Security.php

示例2: saveAction

 /**
  * @Route("/admin/asset/location-type/save")
  * @Method("POST")
  */
 public function saveAction(Request $request)
 {
     $this->denyAccessUnlessGranted('ROLE_SUPER_ADMIN', null, 'Unable to access this page!');
     $em = $this->getDoctrine()->getManager();
     $response = new Response();
     $locationTypes = [];
     $locationTypes['types'] = $em->getRepository('AppBundle\\Entity\\Asset\\LocationType')->findAll();
     $form = $this->createForm(LocationTypesType::class, $locationTypes, ['allow_extra_fields' => true]);
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $locationTypes = $form->getData();
         foreach ($locationTypes['types'] as $type) {
             $em->persist($type);
         }
         $em->flush();
         $this->addFlash('notice', 'common.success');
         $response = new RedirectResponse($this->generateUrl('app_admin_asset_locationtype_index', [], UrlGeneratorInterface::ABSOLUTE_URL));
         $response->prepare($request);
         return $response->send();
     } else {
         $errorMessages = [];
         $formData = $form->all();
         foreach ($formData as $name => $item) {
             if (!$item->isValid()) {
                 $errorMessages[] = $name . ' - ' . $item->getErrors(true);
             }
         }
         return $this->render('admin/asset/location_types.html.twig', array('location_types_form' => $form->createView(), 'base_dir' => realpath($this->container->getParameter('kernel.root_dir') . '/..')));
     }
 }
开发者ID:bgamrat,项目名称:crispy-octo-parakeet,代码行数:34,代码来源:LocationTypeController.php

示例3: themeAction

 /**
  * Переключение активной темы
  * @Route("/theme/{theme}", name="theme", defaults={"theme"="web"}, requirements={"theme"="web|phone"})
  */
 public function themeAction(Request $request, $theme)
 {
     $referer = $request->headers->get('referer');
     $response = new RedirectResponse($referer);
     $cookie = new Cookie('theme', $theme, 0, '/', null, false, false);
     $response->headers->setCookie($cookie);
     $response->send();
 }
开发者ID:Quiss,项目名称:Evrika,代码行数:12,代码来源:ThemeController.php

示例4: run

 public function run()
 {
     $user = $this->getUser();
     if (empty($user)) {
         $response = new RedirectResponse($this->getApp()->generateUrl('home'));
         $response->send();
         exit;
     }
 }
开发者ID:php-nik,项目名称:core,代码行数:9,代码来源:AdminComponent.php

示例5: redirect

 /**
  * Fast redirect in web environment
  * @param string $to
  * @param bool $full
  */
 public function redirect($to, $full = false)
 {
     $to = trim($to, '/');
     if (false === $full && !Str::startsWith(App::$Alias->baseUrl, $to)) {
         $to = App::$Alias->baseUrl . '/' . $to;
     }
     $redirect = new FoundationRedirect($to);
     $redirect->send();
     exit('Redirecting to ' . $to . ' ...');
 }
开发者ID:phpffcms,项目名称:ffcms-core,代码行数:15,代码来源:Response.php

示例6: submitForm

 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     if (isset($form)) {
         if (isset($form['#token'])) {
             $collection_name = Html::escape($form['searchblox_collection']['#value']);
             \Drupal::state()->set('searchblox_collection', $collection_name);
             $response = new RedirectResponse(\Drupal::url('searchblox.step3'));
             $response->send();
             return;
         }
     }
 }
开发者ID:searchblox,项目名称:drupal-searchblox,代码行数:12,代码来源:SecondStepForm.php

示例7: authorize

 public function authorize()
 {
     if ($this->request->has('code')) {
         $state = $this->request->get('state');
         // This was a callback request from linkedin, get the token
         return $this->wunderlistService->requestAccessToken($this->request->get('code'), $state);
     } else {
         $url = $this->wunderlistService->getAuthorizationUri();
         $response = new RedirectResponse($url);
         $response->send();
     }
 }
开发者ID:italolelis,项目名称:wunderlist,代码行数:12,代码来源:OAuthLibAuthentication.php

示例8: send

 public function send()
 {
     $cleared = \Cookie::getClearedCookies();
     foreach ($cleared as $cookie) {
         $this->headers->clearCookie($cookie);
     }
     // First, we see if we have any cookies to send along
     $cookies = \Cookie::getCookies();
     foreach ($cookies as $cookie) {
         $this->headers->setCookie($cookie);
     }
     parent::send();
 }
开发者ID:ceko,项目名称:concrete5-1,代码行数:13,代码来源:RedirectResponse.php

示例9: handle

 /**
  * Handles an access denied failure redirecting to home page
  *
  * @param Request               $request
  * @param AccessDeniedException $accessDeniedException
  *
  * @return Response may return null
  */
 public function handle(Request $request, AccessDeniedException $accessDeniedException)
 {
     $this->logger->error('User tried to access: ' . $request->getUri());
     if ($request->isXmlHttpRequest()) {
         return new JsonResponse(['message' => $accessDeniedException->getMessage(), 'trace' => $accessDeniedException->getTraceAsString(), 'exception' => get_class($accessDeniedException)], Response::HTTP_SERVICE_UNAVAILABLE);
     } else {
         $url = $request->getBasePath() !== "" ? $request->getBasePath() : "/";
         $response = new RedirectResponse($url);
         $response->setStatusCode(Response::HTTP_FORBIDDEN);
         $response->prepare($request);
         return $response->send();
     }
 }
开发者ID:QuangDang212,项目名称:roadiz,代码行数:21,代码来源:AccessDeniedHandler.php

示例10: exec

 public static function exec($url, $status = 302, $cookies = array())
 {
     trigger_error('deprecated since version 2.1 and will be removed in 2.3. A response can not be send before the end of the script. Please use RedirectResponse directly', E_USER_DEPRECATED);
     if (false == Tlog::getInstance()->showRedirect($url)) {
         $response = new RedirectResponse($url, $status);
         foreach ($cookies as $cookie) {
             if (!$cookie instanceof Cookie) {
                 throw new \InvalidArgumentException(sprintf('Third parameter is not a valid Cookie object.'));
             }
             $response->headers->setCookie($cookie);
         }
         $response->send();
     }
 }
开发者ID:alex63530,项目名称:thelia,代码行数:14,代码来源:Redirect.php

示例11: onKernelController

 public function onKernelController(FilterControllerEvent $event)
 {
     $controller = $event->getController();
     if (!is_array($controller)) {
         return;
     }
     //var_dump(get_class($controller[0]));
     //exit;
     if (!$controller[0] instanceof SecurityController) {
         $needRegister = $event->getRequest()->getSession()->get('needRegister');
         if ($needRegister === true) {
             $url = $this->router->generate('register');
             $redirect = new RedirectResponse($url);
             $redirect->send();
         }
     }
 }
开发者ID:nvvetal,项目名称:gnomek,代码行数:17,代码来源:AuthListener.php

示例12: submitForm

 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     if (isset($form)) {
         if (isset($form['#token'])) {
             $api = Html::escape($form['searchblox_api']['#value']);
             $location = rtrim(Html::escape($form['searchblox_location']['#value']), '/');
             $location = searchblox_addhttp($location);
             $port_no = intval(Html::escape($form['searchblox_portno']['#value']));
             \Drupal::state()->set('searchblox_apikey', $api);
             \Drupal::state()->set('searchblox_location', $location);
             \Drupal::state()->set('searchblox_portno', $port_no);
             $response = new RedirectResponse(\Drupal::url('searchblox.step2'));
             $response->send();
             return;
         }
     }
 }
开发者ID:searchblox,项目名称:drupal-searchblox,代码行数:17,代码来源:FirstStepForm.php

示例13: zen_redirect

/**
 * Redirect to a url (safely)
 *
 * This function safely shuts down Symfony by making sure the
 * response and terminate kernel events are called.
 *
 * @param string $url The url to redirect to
 * @param int $response_code http response code (defaults to 302)
 */
function zen_redirect($url, $responseCode = 302)
{
    // fix accidental ampersands
    $url = str_replace(array('&', '&&'), '&', $url);
    $container = Runtime::getContainer();
    $request = $container->get('request');
    if (ENABLE_SSL == 'true' && $request->isSecure()) {
        $url = str_replace('http://', 'https://', $url);
    }
    $response = new RedirectResponse($url, $responseCode);
    $httpKernel = $container->get('http_kernel');
    $event = new FilterResponseEvent($httpKernel, $request, HttpKernelInterface::MASTER_REQUEST, $response);
    $dispatcher = $container->get('event_dispatcher');
    $dispatcher->dispatch(KernelEvents::RESPONSE, $event);
    $response->send();
    $httpKernel->terminate($request, $response);
    exit;
}
开发者ID:zenmagick,项目名称:zenmagick,代码行数:27,代码来源:redirect.php

示例14: submitForm

 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     if (isset($form)) {
         if (isset($form['#token'])) {
             $collection_name = Html::escape($form['searchblox_collection']['#value']);
             $resp = searchblox_check_collection($collection_name);
             // check weather collection name is valid
             if ($resp !== true) {
                 $form_state->setErrorByName($resp);
             }
             if ($resp) {
                 \Drupal::state()->set('searchblox_collection', $collection_name);
                 $response = new RedirectResponse(\Drupal::url('searchblox.step3'));
                 $response->send();
                 return;
             }
         }
     }
 }
开发者ID:searchblox,项目名称:drupal-searchblox,代码行数:19,代码来源:ThirdStepForm.php

示例15: authorize

 public function authorize()
 {
     $request = $this->getRequest();
     $session = $request->getSession();
     if (!$request->query->has('code')) {
         // If we don't have an authorization code then get one
         $authUrl = $this->provider->getAuthorizationUrl();
         $session->set('oauth2state', $this->provider->state);
         $response = new RedirectResponse($authUrl);
         $response->send();
     } elseif (empty($request->query->get('state')) || $request->query->get('state') !== $session->get('oauth2state')) {
         $session->remove('oauth2state');
         throw new \InvalidArgumentException('Invalid State');
     } else {
         // Try to get an access token (using the authorization code grant)
         $this->token = $this->provider->getAccessToken('authorization_code', ['code' => $this->request->query->get('code')]);
     }
     return $this->token->accessToken;
 }
开发者ID:italolelis,项目名称:wunderlist,代码行数:19,代码来源:LeagueAuthentication.php


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