Skip to content

Commit

Permalink
fixed the profiler when an uncalled listener throws an exception when…
Browse files Browse the repository at this point in the history
… instantiated
  • Loading branch information
fabpot committed Mar 28, 2014
1 parent 8a19b9a commit 79540d4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
Expand Up @@ -36,9 +36,9 @@
{% endfor %}
</table>

{% if collector.notcalledlisteners %}
<h2>Not Called Listeners</h2>
<h2>Not Called Listeners</h2>

{% if collector.notcalledlisteners %}
<table>
<tr>
<th>Event name</th>
Expand All @@ -52,6 +52,17 @@
</tr>
{% endfor %}
</table>
{% else %}
<p>
<strong>No uncalled listeners</strong>.
</p>
<p>

All listeners were called for this request or an error occurred
when trying to collect uncalled listeners (in which case check the
logs to get more information).

</p>
{% endif %}
{% endblock %}

Expand Down
Expand Up @@ -160,9 +160,19 @@ public function getCalledListeners()
*/
public function getNotCalledListeners()
{
$notCalled = array();
try {
$allListeners = $this->getListeners();
} catch (\Exception $e) {
if (null !== $this->logger) {
$this->logger->info(sprintf('An exception was thrown while getting the uncalled listeners (%s)', $e->getMessage()), array('exception' => $e));
}

foreach ($this->getListeners() as $name => $listeners) {
// unable to retrieve the uncalled listeners
return array();
}

$notCalled = array();
foreach ($allListeners as $name => $listeners) {
foreach ($listeners as $listener) {
$info = $this->getListenerInfo($listener, null, $name);
if (!isset($this->called[$name.'.'.$info['pretty']])) {
Expand Down

0 comments on commit 79540d4

Please sign in to comment.