Skip to content
This repository has been archived by the owner on Jan 1, 2023. It is now read-only.

Commit

Permalink
fix request in DefaultValueSupplier
Browse files Browse the repository at this point in the history
  • Loading branch information
albert-gonzalez authored and stof committed Dec 28, 2015
1 parent d444bd0 commit 29198ae
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions DefaultValueSupplier.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,32 @@ public function __construct(ContainerInterface $container)

public function getValues()
{
if (!$this->container->isScopeActive('request')) {
$request = $this->getCurrentRequest();

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

$request = $this->container->get('request');

return array(
'locale' => $request->getLocale(),
'env' => $this->container->getParameter('kernel.environment'),
);
}

/**
* @return null|\Symfony\Component\HttpFoundation\Request
*/
private function getCurrentRequest()
{
$request = null;
$requestStack = $this->container->get('request_stack', ContainerInterface::NULL_ON_INVALID_REFERENCE);

if ($requestStack) {
$request = $requestStack->getCurrentRequest();
} elseif ($this->container->isScopeActive('request')) {
$request = $this->container->get('request');
}

return $request;
}
}

0 comments on commit 29198ae

Please sign in to comment.