<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation; /** * Request stack that controls the lifecycle of requests. * * @author Benjamin Eberlei <kontakt@beberlei.de> */ class RequestStack { /** * @var Request[] */ private $requests = array(); /** * Pushes a Request on the stack. * * This method should generally not be called directly as the stack * management should be taken care of by the application itself. */ public function push(Request $request) { $this->requests[] = $request; } /** * Pops the current request from the stack. * * This operation lets the current request go out of scope. * * This method should generally not be called directly as the stack * management should be taken care of by the application itself. * * @return Request|null */ public function pop() { if (!$this->requests) { return; } return array_pop($this->requests); } /** * @return Request|null */ public function getCurrentRequest() { return end($this->requests) ?: null; } /** * Gets the master Request. * * Be warned that making your code aware of the master request * might make it un-compatible with other features of your framework * like ESI support. * * @return Request|null */ public function getMasterRequest() { if (!$this->requests) { return; } return $this->requests[0]; } /** * Returns the parent request of the current. * * Be warned that making your code aware of the parent request * might make it un-compatible with other features of your framework * like ESI support. * * If current Request is the master request, it returns null. * * @return Request|null */ public function getParentRequest() { $pos = count($this->requests) - 2; if (!isset($this->requests[$pos])) { return; } return $this->requests[$pos]; } }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
Exception | Folder | 0755 |
|
|
File | Folder | 0755 |
|
|
Session | Folder | 0755 |
|
|
Tests | Folder | 0755 |
|
|
.gitignore | File | 34 B | 0644 |
|
AcceptHeader.php | File | 3.46 KB | 0644 |
|
AcceptHeaderItem.php | File | 4.58 KB | 0644 |
|
ApacheRequest.php | File | 930 B | 0644 |
|
BinaryFileResponse.php | File | 11.65 KB | 0644 |
|
CHANGELOG.md | File | 8.21 KB | 0644 |
|
Cookie.php | File | 7.87 KB | 0644 |
|
ExpressionRequestMatcher.php | File | 1.33 KB | 0644 |
|
FileBag.php | File | 3.91 KB | 0644 |
|
HeaderBag.php | File | 8.79 KB | 0644 |
|
IpUtils.php | File | 4.63 KB | 0644 |
|
JsonResponse.php | File | 7.2 KB | 0644 |
|
LICENSE | File | 1.04 KB | 0644 |
|
ParameterBag.php | File | 5.86 KB | 0644 |
|
README.md | File | 537 B | 0644 |
|
RedirectResponse.php | File | 2.89 KB | 0644 |
|
Request.php | File | 69.28 KB | 0644 |
|
RequestMatcher.php | File | 4.35 KB | 0644 |
|
RequestMatcherInterface.php | File | 687 B | 0644 |
|
RequestStack.php | File | 2.3 KB | 0644 |
|
Response.php | File | 37.02 KB | 0644 |
|
ResponseHeaderBag.php | File | 9.8 KB | 0644 |
|
ServerBag.php | File | 4.14 KB | 0644 |
|
StreamedResponse.php | File | 3.24 KB | 0644 |
|
composer.json | File | 958 B | 0644 |
|
phpunit.xml.dist | File | 892 B | 0644 |
|