mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 18:48:51 +02:00
migration symfony 5 4 (#300)
* symfony 5.4 (diff dev) * symfony 5.4 (working) * symfony 5.4 (update autoload) * symfony 5.4 (remove swiftmailer mailer implementation) * symfony 5.4 (php doc and split Global accessor class) ### Impacted packages: composer require php:">=7.2.5 <8.0.0" symfony/console:5.4.* symfony/dotenv:5.4.* symfony/framework-bundle:5.4.* symfony/twig-bundle:5.4.* symfony/yaml:5.4.* --update-with-dependencies composer require symfony/stopwatch:5.4.* symfony/web-profiler-bundle:5.4.* --dev --update-with-dependencies
This commit is contained in:
@@ -11,6 +11,9 @@
|
||||
|
||||
namespace Symfony\Component\HttpFoundation;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Exception\SessionNotFoundException;
|
||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||
|
||||
/**
|
||||
* Request stack that controls the lifecycle of requests.
|
||||
*
|
||||
@@ -62,15 +65,13 @@ class RequestStack
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the master Request.
|
||||
* Gets the main request.
|
||||
*
|
||||
* Be warned that making your code aware of the master request
|
||||
* Be warned that making your code aware of the main request
|
||||
* might make it un-compatible with other features of your framework
|
||||
* like ESI support.
|
||||
*
|
||||
* @return Request|null
|
||||
*/
|
||||
public function getMasterRequest()
|
||||
public function getMainRequest(): ?Request
|
||||
{
|
||||
if (!$this->requests) {
|
||||
return null;
|
||||
@@ -79,6 +80,20 @@ class RequestStack
|
||||
return $this->requests[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the master request.
|
||||
*
|
||||
* @return Request|null
|
||||
*
|
||||
* @deprecated since symfony/http-foundation 5.3, use getMainRequest() instead
|
||||
*/
|
||||
public function getMasterRequest()
|
||||
{
|
||||
trigger_deprecation('symfony/http-foundation', '5.3', '"%s()" is deprecated, use "getMainRequest()" instead.', __METHOD__);
|
||||
|
||||
return $this->getMainRequest();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parent request of the current.
|
||||
*
|
||||
@@ -86,7 +101,7 @@ class RequestStack
|
||||
* might make it un-compatible with other features of your framework
|
||||
* like ESI support.
|
||||
*
|
||||
* If current Request is the master request, it returns null.
|
||||
* If current Request is the main request, it returns null.
|
||||
*
|
||||
* @return Request|null
|
||||
*/
|
||||
@@ -94,10 +109,20 @@ class RequestStack
|
||||
{
|
||||
$pos = \count($this->requests) - 2;
|
||||
|
||||
if (!isset($this->requests[$pos])) {
|
||||
return null;
|
||||
return $this->requests[$pos] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current session.
|
||||
*
|
||||
* @throws SessionNotFoundException
|
||||
*/
|
||||
public function getSession(): SessionInterface
|
||||
{
|
||||
if ((null !== $request = end($this->requests) ?: null) && $request->hasSession()) {
|
||||
return $request->getSession();
|
||||
}
|
||||
|
||||
return $this->requests[$pos];
|
||||
throw new SessionNotFoundException();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user