Skip to content

Commit

Permalink
[Event] Collected data is about listener (not event) calls
Browse files Browse the repository at this point in the history
  • Loading branch information
vicb authored and fabpot committed Jan 11, 2011
1 parent 08c3a2b commit 9a2e053
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 40 deletions.
29 changes: 11 additions & 18 deletions src/Symfony/Bundle/FrameworkBundle/Debug/EventDispatcher.php
Expand Up @@ -39,11 +39,7 @@ public function __construct(LoggerInterface $logger = null)
}

/**
* Notifies all listeners of a given event.
*
* @param Event $event A Event instance
*
* @return Event The Event instance
* {@inheritDoc}
*/
public function notify(Event $event)
{
Expand All @@ -57,11 +53,7 @@ public function notify(Event $event)
}

/**
* 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)
{
Expand All @@ -87,12 +79,7 @@ public function notifyUntil(Event $event)
}

/**
* 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)
{
Expand All @@ -107,12 +94,18 @@ public function filter(Event $event, $value)
return $event;
}

public function getCalledEvents()
/**
* {@inheritDoc}
*/
public function getCalledListeners()
{
return $this->called;
}

public function getNotCalledEvents()
/**
* {@inheritDoc}
*/
public function getNotCalledListeners()
{
$notCalled = array();

Expand Down
Expand Up @@ -6,35 +6,35 @@ Events
{% endblock %}

{% block panel %}
<h2>Called Events</h2>
<h2>Called Listeners</h2>

<table>
<tr>
<th>Event</th>
<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>
Expand Down
Expand Up @@ -38,33 +38,33 @@ public function setEventDispatcher(EventDispatcher $dispatcher)
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'];
}

/**
Expand Down
Expand Up @@ -16,7 +16,17 @@
*/
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();
}

0 comments on commit 9a2e053

Please sign in to comment.