[ProfilerBundle] fixed page display when the profiler DB is not writable

This commit is contained in:
Fabien Potencier 2010-04-08 07:38:51 +02:00
parent 7d106aa80e
commit 9ebfdf24a5
2 changed files with 13 additions and 3 deletions

View File

@ -6,6 +6,7 @@ use Symfony\Components\DependencyInjection\ContainerInterface;
use Symfony\Components\EventDispatcher\Event;
use Symfony\Components\RequestHandler\Response;
use Symfony\Framework\ProfilerBundle\ProfilerStorage;
use Symfony\Foundation\LoggerInterface;
/*
* This file is part of the Symfony framework.
@ -31,7 +32,7 @@ class DataCollectorManager
protected $response;
protected $lifetime;
public function __construct(ContainerInterface $container, ProfilerStorage $profilerStorage, $lifetime = 86400)
public function __construct(ContainerInterface $container, LoggerInterface $logger, ProfilerStorage $profilerStorage, $lifetime = 86400)
{
$this->container = $container;
$this->lifetime = $lifetime;
@ -58,8 +59,16 @@ class DataCollectorManager
{
$data[$name] = $collector->getData();
}
$this->profilerStorage->write($data);
$this->profilerStorage->purge($this->lifetime);
try
{
$this->profilerStorage->write($data);
$this->profilerStorage->purge($this->lifetime);
}
catch (\Exception $e)
{
$this->logger->err('Unable to store the profiler information.');
}
return $response;
}

View File

@ -19,6 +19,7 @@
<service id="data_collector_manager" class="%data_collector_manager.class%">
<annotation name="kernel.listener" event="core.response" method="handle" />
<argument type="service" id="service_container" />
<argument type="service" id="logger" />
<argument type="service" id="data_collector_manager.storage" />
<argument>%data_collector_manager.lifetime%</argument>
</service>