[Event] Collected data is about listener (not event) calls

This commit is contained in:
Victor Berchet 2011-01-09 11:25:50 +01:00 committed by Fabien Potencier
parent 08c3a2b40b
commit 9a2e053cbc
4 changed files with 43 additions and 40 deletions

View File

@ -39,11 +39,7 @@ class EventDispatcher extends BaseEventDispatcher implements EventDispatcherTrac
}
/**
* Notifies all listeners of a given event.
*
* @param Event $event A Event instance
*
* @return Event The Event instance
* {@inheritDoc}
*/
public function notify(Event $event)
{
@ -57,11 +53,7 @@ class EventDispatcher extends BaseEventDispatcher implements EventDispatcherTrac
}
/**
* Notifies all listeners of a given event until one returns a non null value.
*
* @param Event $event A Event instance
*
* @return Event The Event instance
* {@inheritDoc}
*/
public function notifyUntil(Event $event)
{
@ -87,12 +79,7 @@ class EventDispatcher extends BaseEventDispatcher implements EventDispatcherTrac
}
/**
* Filters a value by calling all listeners of a given event.
*
* @param Event $event A Event instance
* @param mixed $value The value to be filtered
*
* @return Event The Event instance
* {@inheritDoc}
*/
public function filter(Event $event, $value)
{
@ -107,12 +94,18 @@ class EventDispatcher extends BaseEventDispatcher implements EventDispatcherTrac
return $event;
}
public function getCalledEvents()
/**
* {@inheritDoc}
*/
public function getCalledListeners()
{
return $this->called;
}
public function getNotCalledEvents()
/**
* {@inheritDoc}
*/
public function getNotCalledListeners()
{
$notCalled = array();

View File

@ -6,7 +6,7 @@ Events
{% endblock %}
{% block panel %}
<h2>Called Events</h2>
<h2>Called Listeners</h2>
<table>
<tr>
@ -14,27 +14,27 @@ Events
<th>Caller</th>
<th>Listener</th>
</tr>
{% for event in collector.calledevents %}
{% for elements in collector.calledlisteners %}
<tr>
<td><code>{{ event.event }}</code></td>
<td><code>{{ event.caller|abbr_class }}</code></td>
<td><code>{{ event.listener|abbr_method }}()</code></td>
<td><code>{{ elements.event }}</code></td>
<td><code>{{ elements.caller|abbr_class }}</code></td>
<td><code>{{ elements.listener|abbr_method }}()</code></td>
</tr>
{% endfor %}
</table>
{% if collector.notcalledevents %}
<h2>Not Called Events</h2>
{% if collector.notcalledlisteners %}
<h2>Not Called Listeners</h2>
<table>
<tr>
<th>Event</th>
<th>Listener</th>
</tr>
{% for event in collector.notcalledevents %}
{% for elements in collector.notcalledlisteners %}
<tr>
<td><code>{{ event.event }}</code></td>
<td><code>{{ event.listener|abbr_method }}()</code></td>
<td><code>{{ elements.event }}</code></td>
<td><code>{{ elements.listener|abbr_method }}()</code></td>
</tr>
{% endfor %}
</table>

View File

@ -38,33 +38,33 @@ class EventDataCollector extends DataCollector
public function collect(Request $request, Response $response, \Exception $exception = null)
{
$this->data = array(
'called_events' => null !== $this->dispatcher ? $this->dispatcher->getCalledEvents() : array(),
'not_called_events' => null !== $this->dispatcher ? $this->dispatcher->getNotCalledEvents() : array(),
'called_listeners' => null !== $this->dispatcher ? $this->dispatcher->getCalledListeners() : array(),
'not_called_listeners' => null !== $this->dispatcher ? $this->dispatcher->getNotCalledListeners() : array(),
);
}
/**
* Gets the called events.
* Gets the called listeners.
*
* @return array An array of called events
* @return array An array of called listeners
*
* @see EventDispatcherTraceableInterface
*/
public function getCalledEvents()
public function getCalledListeners()
{
return $this->data['called_events'];
return $this->data['called_listeners'];
}
/**
* Gets the not called events.
* Gets the not called listeners.
*
* @return array An array of not called events
* @return array An array of not called listeners
*
* @see EventDispatcherTraceableInterface
*/
public function getNotCalledEvents()
public function getNotCalledListeners()
{
return $this->data['not_called_events'];
return $this->data['not_called_listeners'];
}
/**

View File

@ -16,7 +16,17 @@ namespace Symfony\Component\HttpKernel\Debug;
*/
interface EventDispatcherTraceableInterface
{
function getCalledEvents();
/**
* Gets the called listeners.
*
* @return array An array of called listeners
*/
function getCalledListeners();
function getNotCalledEvents();
/**
* Gets the not called listeners.
*
* @return array An array of not called listeners
*/
function getNotCalledListeners();
}