Skip to content

Commit

Permalink
[WebProfilerBundle] Fixed errors if the session is not configured
Browse files Browse the repository at this point in the history
  • Loading branch information
francisbesset committed Apr 13, 2011
1 parent a6d790f commit 8193913
Showing 1 changed file with 20 additions and 12 deletions.
Expand Up @@ -129,8 +129,10 @@ public function toolbarAction($token, $position = null)
{
$request = $this->container->get('request');

// keep current flashes for one more request
$request->getSession()->setFlashes($request->getSession()->getFlashes());
if ($session = $request->getSession()) {
// keep current flashes for one more request
$session->setFlashes($request->getSession()->getFlashes());
}

if (null === $token) {
return new Response();
Expand Down Expand Up @@ -175,17 +177,20 @@ public function searchBarAction()
$profiler = $this->container->get('profiler');
$profiler->disable();

$session = $this->container->get('request')->getSession();
$ip = $session->get('_profiler_search_ip');
$url = $session->get('_profiler_search_url');
if (!$session = $this->container->get('request')->getSession()) {
return new Response(null, 200);
}

$ip = $session->get('_profiler_search_ip');
$url = $session->get('_profiler_search_url');
$limit = $session->get('_profiler_search_limit');
$token = $session->get('_profiler_search_token');

return $this->container->get('templating')->renderResponse('WebProfilerBundle:Profiler:search.html.twig', array(
'token' => $token,
'ip' => $ip,
'url' => $url,
'limit' => $limit,
'token' => $token,
'ip' => $ip,
'url' => $url,
'limit' => $limit,
));
}

Expand All @@ -201,9 +206,12 @@ public function searchResultsAction($token)

$pofiler = $profiler->loadFromToken($token);

$session = $this->container->get('request')->getSession();
$ip = $session->get('_profiler_search_ip');
$url = $session->get('_profiler_search_url');
if (!$session = $this->container->get('request')->getSession()) {
throw new \RuntimeException('To access to search, activate the session in your configuration.');
}

$ip = $session->get('_profiler_search_ip');
$url = $session->get('_profiler_search_url');
$limit = $session->get('_profiler_search_limit');

return $this->container->get('templating')->renderResponse('WebProfilerBundle:Profiler:results.html.twig', array(
Expand Down

0 comments on commit 8193913

Please sign in to comment.