[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. * {@inheritDoc}
*
* @param Event $event A Event instance
*
* @return Event The Event instance
*/ */
public function notify(Event $event) 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. * {@inheritDoc}
*
* @param Event $event A Event instance
*
* @return Event The Event instance
*/ */
public function notifyUntil(Event $event) 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. * {@inheritDoc}
*
* @param Event $event A Event instance
* @param mixed $value The value to be filtered
*
* @return Event The Event instance
*/ */
public function filter(Event $event, $value) public function filter(Event $event, $value)
{ {
@ -107,12 +94,18 @@ class EventDispatcher extends BaseEventDispatcher implements EventDispatcherTrac
return $event; return $event;
} }
public function getCalledEvents() /**
* {@inheritDoc}
*/
public function getCalledListeners()
{ {
return $this->called; return $this->called;
} }
public function getNotCalledEvents() /**
* {@inheritDoc}
*/
public function getNotCalledListeners()
{ {
$notCalled = array(); $notCalled = array();

View File

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

View File

@ -38,33 +38,33 @@ class EventDataCollector extends DataCollector
public function collect(Request $request, Response $response, \Exception $exception = null) public function collect(Request $request, Response $response, \Exception $exception = null)
{ {
$this->data = array( $this->data = array(
'called_events' => null !== $this->dispatcher ? $this->dispatcher->getCalledEvents() : array(), 'called_listeners' => null !== $this->dispatcher ? $this->dispatcher->getCalledListeners() : array(),
'not_called_events' => null !== $this->dispatcher ? $this->dispatcher->getNotCalledEvents() : 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 * @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 * @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 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();
} }