Beispiel #1
0
 /**
  * Create a new redirect response.
  *
  * @param  string  $path
  * @param  int     $status
  * @param  array   $headers
  * @return \Illuminate\Http\RedirectResponse
  */
 protected function createRedirect($path, $status, $headers)
 {
     $redirect = new RedirectResponse($path, $status, $headers);
     $redirect->setRequest($this->app->make('request'));
     $redirect->setSession($this->app->make('session.store'));
     return $redirect;
 }
 /**
  * Create a new redirect response.
  *
  * @param  string  $path
  * @param  int     $status
  * @param  array   $headers
  * @return \Illuminate\Http\RedirectResponse
  */
 protected function createRedirect($path, $status, $headers)
 {
     $redirect = new RedirectResponse($path, $status, $headers);
     if (isset($this->session)) {
         $redirect->setSession($this->session);
     }
     $redirect->setRequest($this->generator->getRequest());
     return $redirect;
 }
Beispiel #3
0
 /**
  * Mock the http referer to allow redirections to the previous page
  *
  * @param  string  $urlReferer
  */
 protected function shouldRedirectBack($UrlReferer = '')
 {
     $redirection = new RedirectResponse('http://localhost/' . $UrlReferer, 302, array());
     $redirection->setRequest($request = m::mock('Illuminate\\Http\\Request'));
     $redirection->setSession($session = m::mock('Illuminate\\Session\\Store'));
     $request->shouldReceive('input')->andReturn(array());
     $session->shouldReceive('flash');
     $session->shouldReceive('flashInput');
     $session->shouldReceive('get')->with('errors', m::any())->andReturn(new ViewErrorBag());
     Redirect::shouldReceive('back')->andReturn($redirection);
 }
 /**
  *
  */
 public function setUp()
 {
     parent::setUp();
     $this->request = $this->getMockBuilder(Request::class)->getMock();
     $this->router = $this->getMockBuilder(Router::class)->disableOriginalConstructor()->getMock();
     $this->redirectResponse = $this->getMockBuilder(RedirectResponse::class)->disableOriginalConstructor()->getMock();
     $this->redirectResponse->expects($this->any())->method('withInput')->willReturnSelf();
     $this->redirector = $this->getMockBuilder(Redirector::class)->disableOriginalConstructor()->getMock();
     $this->redirector->expects($this->any())->method('route')->willReturn($this->redirectResponse);
     $this->redirector->expects($this->any())->method('action')->willReturn($this->redirectResponse);
     $this->redirector->expects($this->any())->method('withInput')->willReturnSelf();
     $this->validatorFactory = $this->app->make(Factory::class);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $params = explode('/', $request->path());
     $locale = $request->cookie('locale', false);
     if (count($params) > 0 && app('laravellocalization')->checkLocaleInSupportedLocales($params[0])) {
         return $next($request)->withCookie(cookie()->forever('locale', $params[0]));
     }
     if ($locale && app('laravellocalization')->checkLocaleInSupportedLocales($locale) && !(app('laravellocalization')->getDefaultLocale() === $locale && app('laravellocalization')->hideDefaultLocaleInURL())) {
         $redirection = app('laravellocalization')->getLocalizedURL($locale);
         $redirectResponse = new RedirectResponse($redirection, 302, ['Vary' => 'Accept-Language']);
         return $redirectResponse->withCookie(cookie()->forever('locale', $params[0]));
     }
     return $next($request);
 }
 /**
  * 요청 포멧이 html 이 아닐 경우 redirect 하지 않고 데이터 형식으로 결과 출력
  *
  * @param Request $request request
  * @return mixed
  */
 public function prepare(Request $request)
 {
     if ($request->getRequestFormat() === 'json') {
         return new JsonResponse(array_merge($this->data, ['links' => ['rel' => 'self', 'href' => $this->targetUrl]]));
     }
     return parent::prepare($request);
 }
 private function redirectWithMergedApprovals(array $approvals, \Illuminate\Http\RedirectResponse $route)
 {
     return $route->withApprovals(session()->has('approvals') ? collect(session('approvals'))->merge($approvals)->toArray() : $approvals);
 }
Beispiel #8
0
 /**
  * @param \Symfony\Component\HttpFoundation\Response $response
  * @param \Exception                                 $exception
  *
  * @return \Illuminate\Http\Response
  */
 protected function toIlluminateResponse($response, Exception $exception)
 {
     if ($response instanceof SymfonyRedirectResponse) {
         $response = new RedirectResponse($response->getTargetUrl(), $response->getStatusCode(), $response->headers->all());
     } else {
         $response = new Response($response->getContent(), $response->getStatusCode(), $response->headers->all());
     }
     return $response->withException($exception);
 }
Beispiel #9
0
 /**
  * @param \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse $response
  * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
  */
 public function storeCookie($response)
 {
     if (count($this->changingDataStore) > 0) {
         foreach ($this->changingDataStore as $key => $value) {
             $response->withCookie(cookie()->forever('settings_' . $key, $value));
         }
     }
     return $response;
 }
 /**
  * @param RedirectResponse $response
  * @return string
  */
 private function renderRedirectScript(RedirectResponse $response)
 {
     return '<script>window.location = "' . $response->getTargetUrl() . '"</script>';
 }