fixed the profiler when an uncalled listener throws an exception when instantiated
This commit is contained in:
parent
8a19b9ac08
commit
79540d4b6e
@ -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>
|
||||
@ -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 %}
|
||||
|
||||
|
@ -160,9 +160,19 @@ class TraceableEventDispatcher implements EventDispatcherInterface, TraceableEve
|
||||
*/
|
||||
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']])) {
|
||||
|
Reference in New Issue
Block a user