2010-08-28 14:23:21 +01:00
|
|
|
<?php
|
|
|
|
|
2011-01-15 13:29:43 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the Symfony package.
|
|
|
|
*
|
2011-03-06 11:40:06 +00:00
|
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
2011-01-15 13:29:43 +00:00
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
2010-08-28 14:23:21 +01:00
|
|
|
namespace Symfony\Component\HttpKernel\DataCollector;
|
|
|
|
|
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
2011-03-13 18:16:56 +00:00
|
|
|
use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcherInterface;
|
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
2010-08-28 14:23:21 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* EventDataCollector.
|
|
|
|
*
|
2011-03-06 11:40:06 +00:00
|
|
|
* @author Fabien Potencier <fabien@symfony.com>
|
2010-08-28 14:23:21 +01:00
|
|
|
*/
|
|
|
|
class EventDataCollector extends DataCollector
|
|
|
|
{
|
2011-03-23 18:47:16 +00:00
|
|
|
private $dispatcher;
|
2010-08-28 14:23:21 +01:00
|
|
|
|
2011-03-13 18:16:56 +00:00
|
|
|
public function setEventDispatcher(EventDispatcherInterface $dispatcher)
|
2010-08-28 14:23:21 +01:00
|
|
|
{
|
2011-03-13 18:16:56 +00:00
|
|
|
if ($dispatcher instanceof TraceableEventDispatcherInterface) {
|
|
|
|
$this->dispatcher = $dispatcher;
|
2010-08-28 14:23:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function collect(Request $request, Response $response, \Exception $exception = null)
|
|
|
|
{
|
|
|
|
$this->data = array(
|
2011-03-13 18:16:56 +00:00
|
|
|
'called_listeners' => null !== $this->dispatcher ? $this->dispatcher->getCalledListeners() : array(),
|
|
|
|
'not_called_listeners' => null !== $this->dispatcher ? $this->dispatcher->getNotCalledListeners() : array(),
|
2010-08-28 14:23:21 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-01-09 10:25:50 +00:00
|
|
|
* Gets the called listeners.
|
2010-08-28 14:23:21 +01:00
|
|
|
*
|
2011-01-09 10:25:50 +00:00
|
|
|
* @return array An array of called listeners
|
2010-08-28 14:23:21 +01:00
|
|
|
*
|
2011-03-13 18:16:56 +00:00
|
|
|
* @see TraceableEventDispatcherInterface
|
2010-08-28 14:23:21 +01:00
|
|
|
*/
|
2011-01-09 10:25:50 +00:00
|
|
|
public function getCalledListeners()
|
2010-08-28 14:23:21 +01:00
|
|
|
{
|
2011-01-09 10:25:50 +00:00
|
|
|
return $this->data['called_listeners'];
|
2010-08-28 14:23:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-01-09 10:25:50 +00:00
|
|
|
* Gets the not called listeners.
|
2010-08-28 14:23:21 +01:00
|
|
|
*
|
2011-01-09 10:25:50 +00:00
|
|
|
* @return array An array of not called listeners
|
2010-08-28 14:23:21 +01:00
|
|
|
*
|
2011-03-13 18:16:56 +00:00
|
|
|
* @see TraceableEventDispatcherInterface
|
2010-08-28 14:23:21 +01:00
|
|
|
*/
|
2011-01-09 10:25:50 +00:00
|
|
|
public function getNotCalledListeners()
|
2010-08-28 14:23:21 +01:00
|
|
|
{
|
2011-01-09 10:25:50 +00:00
|
|
|
return $this->data['not_called_listeners'];
|
2010-08-28 14:23:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function getName()
|
|
|
|
{
|
|
|
|
return 'events';
|
|
|
|
}
|
|
|
|
}
|