Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ public function prepareRequest(Request $request)
{
if ( ! is_null($this['config']['session.driver']) && ! $request->hasSession())
{
$request->setSession($this['session']->driver());
$request->setLaravelSession($this['session']->driver());
}

return $request;
Expand Down
1 change: 0 additions & 1 deletion src/Illuminate/Foundation/Console/Optimize/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
$basePath.'/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Database/ConnectionResolverInterface.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Session/SessionInterface.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Session/Middleware.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Session/Store.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Session/SessionManager.php',
Expand Down
45 changes: 43 additions & 2 deletions src/Illuminate/Http/Request.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<?php namespace Illuminate\Http;

use Illuminate\Session\SymfonySessionDecorator;
use Illuminate\Support\Str;
use SplFileInfo;
use Symfony\Component\HttpFoundation\Exception\SessionNotFoundException;
use Symfony\Component\HttpFoundation\InputBag;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
use Symfony\Component\HttpFoundation\Session\SessionInterface;

class Request extends SymfonyRequest {

Expand Down Expand Up @@ -594,7 +597,34 @@ public static function createFromBase(SymfonyRequest $request)
}

/**
* Get the session associated with the request.
* Determine if the request contains a session instance.
*
* @param bool $skipIfUninitialized
* @return bool
*/
#[\Override]
public function hasSession(bool $skipIfUninitialized = false): bool
{
return $this->session instanceof SymfonySessionDecorator;
}

/**
* Get the Symfony session (decorator) associated with the request.
*
* @return \Symfony\Component\HttpFoundation\Session\SessionInterface
*
* @throws \Symfony\Component\HttpFoundation\Exception\SessionNotFoundException
*/
#[\Override]
public function getSession(): SessionInterface
{
return $this->hasSession()
? $this->session
: throw new SessionNotFoundException;
}

/**
* Get the session store associated with the request.
*
* @return \Illuminate\Session\Store
*
Expand All @@ -607,7 +637,18 @@ public function session()
throw new \RuntimeException("Session store not set on request.");
}

return $this->getSession();
return $this->session->store;
}

/**
* Set the session instance on the request.
*
* @param \Illuminate\Contracts\Session\Session $session
* @return void
*/
public function setLaravelSession($session)
{
$this->session = new SymfonySessionDecorator($session);
}

}
19 changes: 10 additions & 9 deletions src/Illuminate/Session/Middleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Closure;
use Carbon\Carbon;
use Illuminate\Contracts\Session\Session;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand Down Expand Up @@ -66,7 +67,7 @@ public function handle(Request $request, $type = HttpKernelInterface::MAIN_REQUE
{
$session = $this->startSession($request);

$request->setSession($session);
$request->setLaravelSession($session);
}

$response = $this->app->handle($request, $type, $catch);
Expand Down Expand Up @@ -105,7 +106,7 @@ public function checkRequestForArraySessions(Request $request)
* Start the session for the given request.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* @return \Illuminate\Session\SessionInterface
* @return \Illuminate\Contracts\Session\Session
*/
protected function startSession(Request $request)
{
Expand All @@ -119,10 +120,10 @@ protected function startSession(Request $request)
/**
* Close the session handling for the request.
*
* @param \Illuminate\Session\SessionInterface $session
* @param \Illuminate\Contracts\Session\Session $session
* @return void
*/
protected function closeSession(SessionInterface $session)
protected function closeSession(Session $session)
{
$session->save();

Expand All @@ -145,10 +146,10 @@ protected function getUrl(Request $request)
/**
* Remove the garbage from the session if necessary.
*
* @param \Illuminate\Session\SessionInterface $session
* @param \Illuminate\Contracts\Session\Session $session
* @return void
*/
protected function collectGarbage(SessionInterface $session)
protected function collectGarbage(Session $session)
{
$config = $this->manager->getSessionConfig();

Expand Down Expand Up @@ -183,10 +184,10 @@ protected function storeCurrentUrl(Request $request, $session)
* Add the session cookie to the application response.
*
* @param \Symfony\Component\HttpFoundation\Response $response
* @param \Symfony\Component\HttpFoundation\Session\SessionInterface $session
* @param \Illuminate\Contracts\Session\Session $session
* @return void
*/
protected function addCookieToResponse(Response $response, SessionInterface $session)
protected function addCookieToResponse(Response $response, Session $session)
{
$s = $session;

Expand Down Expand Up @@ -252,7 +253,7 @@ protected function sessionIsPersistent(?array $config = null)
* Get the session implementation from the manager.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* @return \Illuminate\Session\SessionInterface
* @return \Illuminate\Contracts\Session\Session
*/
public function getSession(Request $request)
{
Expand Down
30 changes: 0 additions & 30 deletions src/Illuminate/Session/SessionInterface.php

This file was deleted.

Loading
Loading