Count the number of registered listeners for the given event.

@param   EventInterface|string $event The event object or name.

@return  integer  The number of registered listeners for the given event.

@since   2.0
774332
public function countListeners($event)
    {
        if ($event instanceof EventInterface) {
            $event = $event->getName();
        }

        return isset($this->listeners[$event]) ? count($this->listeners[$event]) : 0;
    }
1149440
public function notify(Event $event)
    {
        $processed = false;
        foreach ($this->listeners as $listener) {
            if ($listener->match($event)) {
                $listener->handle($event);
                $processed = true;
                if ($event->isPropagationStopped()) {
                    break;
                }
            }
        }
        return $processed;
    }
1215012
public function dispatch(Event $event): int {
        /** @var array $listeners */
        $listeners = $this->_events["$event"] ?? [];
        $i = 0;
        foreach ($listeners as $listener) {
            $callback = $listener['callback'];
            if (is_callable($callback)) {
                $event->state = $listener['state'];
                $callback($event);
                $i++;
                if ($event->isAttachingStopped()) {
                    return $i;
                }
            }
        }

        return $i;
    }
274190
public function listenersOfEvent(Event $event)
    {
        $event_name = get_class($event);

        return isset($this->listeners[$event_name]) ? $this->listeners[$event_name] : [];
    }
1361756
public function onEventRegistration(Event $event)
    {
        $this->unitOfWork->publishEvent($event, $this->eventBus);

        return $this->unitOfWork->invokeEventRegistrationListeners($event);
    }
824673
public function listener(Event $event)
    {
        error_log(
            $event->context->get(0)->getRequestTarget() . PHP_EOL,
            3,
            RUNTIME_PATH . '/logs/example.log'
        );
    }
1343409
def num_listeners(self, event=None):
        
        if event is not None:
            return len(self._listeners[event])
        else:
            return sum(len(l) for l in self._listeners.values())
70123
public function has_events($event)
	{
		if (isset($this->_events[$event]) and count($this->_events[$event]) > 0)
		{
			return true;
		}
		return false;
	}
777691
public static function hasListeners(string $event) : bool
    {
        if (! isset(Event::$listeners[$event]) || count(Event::$listeners[$event]) === 0) {
            return false;
        }

        return true;
    }
1180817
public function trigger($event)
    {
        if ($this->has($event)) {
            return call_user_func($this->listeners[$event]);
        } else {
            throw new RuntimeException(sprintf(
                'Cannot trigger non-existing event "%s"', $event
            ));
        }
    }
319613
function removeListener(string $event, callable $listener) {
        if(isset($this->listeners[$event])) {
            $index = \array_search($listener, $this->listeners[$event], true);
            if($index !== false) {
                unset($this->listeners[$event][$index]);
                if(\count($this->listeners[$event]) === 0) {
                    unset($this->listeners[$event]);
                }
            }
        }
        
        if(isset($this->onceListeners[$event])) {
            $index = \array_search($listener, $this->onceListeners[$event], true);
            if($index !== false) {
                unset($this->onceListeners[$event][$index]);
                if(\count($this->onceListeners[$event]) === 0) {
                    unset($this->onceListeners[$event]);
                }
            }
        }
        
        return $this;
    }
41716
public function hasListeners($eventName = '')
    {
        $count = 0;

        if (empty($eventName)) {
            $count = count($this->listeners);
        } elseif (isset($this->listeners[$eventName])) {
            $count = count($this->listeners[$eventName]);
        }

        return (boolean) $count;
    }
901792
public function dispatch(EventInterface $event)
    {
        if (array_key_exists($event->getName(), $this->listeners)) {
            foreach ($this->listeners[$event->getName()] as $listener) {
                $listener($event);
            }
        }

        return $event;
    }
99148
public function getSubscribers($event)
    {
        $result = array();
        if(isset($this->__listeners[$event])) {
            $result = $this->__listeners[$event];
        }

        return $result;
    }
332915
public function hasListeners(string $eventName) : bool
    {
        return isset($this->events[$eventName]) && count($this->events[$eventName]) > 0;
    }
637509
public function getListeners(string $event) : array
    {
        if (empty($this->listeners[$event])) {
            return [];
        }

        if (! isset($this->sorted[$event])) {
            $this->sorted[$event] = $this->sortListeners($this->listeners[$event]);
        }

        return $this->sorted[$event];
    }
301901
public function addListener($event, $method)
    {
        if (!isset($this->listeners[$event])) {
            $this->listeners[$event] = array();
        }

        $this->listeners[$event][] = $method;
    }