You are here

private function TraceableEventDispatcher::getListenerInfo in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php \Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher::getListenerInfo()

Returns information about the listener.

Parameters

object $listener The listener:

string $eventName The event name:

Return value

array Information about the listener

4 calls to TraceableEventDispatcher::getListenerInfo()
TraceableEventDispatcher::getCalledListeners in vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php
Gets the called listeners.
TraceableEventDispatcher::getNotCalledListeners in vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php
Gets the not called listeners.
TraceableEventDispatcher::postProcess in vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php
TraceableEventDispatcher::preProcess in vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php

File

vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php, line 284

Class

TraceableEventDispatcher
Collects some data about event listeners.

Namespace

Symfony\Component\EventDispatcher\Debug

Code

private function getListenerInfo($listener, $eventName) {
  $info = array(
    'event' => $eventName,
  );
  if ($listener instanceof \Closure) {
    $info += array(
      'type' => 'Closure',
      'pretty' => 'closure',
    );
  }
  elseif (is_string($listener)) {
    try {
      $r = new \ReflectionFunction($listener);
      $file = $r
        ->getFileName();
      $line = $r
        ->getStartLine();
    } catch (\ReflectionException $e) {
      $file = null;
      $line = null;
    }
    $info += array(
      'type' => 'Function',
      'function' => $listener,
      'file' => $file,
      'line' => $line,
      'pretty' => $listener,
    );
  }
  elseif (is_array($listener) || is_object($listener) && is_callable($listener)) {
    if (!is_array($listener)) {
      $listener = array(
        $listener,
        '__invoke',
      );
    }
    $class = is_object($listener[0]) ? get_class($listener[0]) : $listener[0];
    try {
      $r = new \ReflectionMethod($class, $listener[1]);
      $file = $r
        ->getFileName();
      $line = $r
        ->getStartLine();
    } catch (\ReflectionException $e) {
      $file = null;
      $line = null;
    }
    $info += array(
      'type' => 'Method',
      'class' => $class,
      'method' => $listener[1],
      'file' => $file,
      'line' => $line,
      'pretty' => $class . '::' . $listener[1],
    );
  }
  return $info;
}