Skip to content

Commit

Permalink
Merge pull request #21 from martinlutter/requeststack
Browse files Browse the repository at this point in the history
get request from stack only when it is needed
  • Loading branch information
klinec committed Mar 18, 2019
2 parents 08d3169 + 90d81dc commit 013b012
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/Bridge/Item/RequestAttributesContainer.php
Expand Up @@ -14,20 +14,22 @@
*/
class RequestAttributesContainer implements RequestAttributesContainerInterface
{
/** @var Request */
private $request;
/** @var RequestStack */
private $requestStack;

public function __construct(RequestStack $requestStack)
{
$this->request = $requestStack->getMasterRequest();
$this->requestStack = $requestStack;
}

public function get(string $name, string $default = ''): string
{
if (!$this->request) {
$request = $this->requestStack->getMasterRequest();

if (!$request) {
return '';
}

return $this->request->get($name, $default);
return $request->get($name, $default);
}
}

0 comments on commit 013b012

Please sign in to comment.