Get the listener priority for a given event.

Lower priority listeners are evaluated earlier.

@since 1.0

@param string   $event_name The fully-qualified event name.
@param callable $listener   The listener to check against.

@return int|null
15422
public function get_listener_priority( $event_name, $listener ) {

		if ( ! is_callable( $listener, true ) ) {
			throw new InvalidListenerException( '$listener must be callable.' );
		}

		$priority = has_filter( $event_name, $listener );

		if ( false === $priority ) {
			return null;
		}

		return $priority;
	}
560272
private function orderByPriority($eventListeners)
    {
        /**
         * @param int $a
         * @param int $b
         *
         * @return int
         */
        $comparisonFunction = function ($a, $b) {
            if ($a->getPriority() == $b->getPriority()) {
                // This will keep the order of same priority listeners in the order of subscribing
                return 1;
            }

            return ($a->getPriority() > $b->getPriority()) ? -1 : 1;
        };

        return $this->arr($eventListeners)->sortUsingFunction($comparisonFunction)->val();
    }
476882
public function getListenerPriority($listener, $event)
	{
		$event = $this->resolveEventName($event);

		if (isset($this->listeners[$event]))
		{
			return $this->listeners[$event]->getPriority($listener);
		}

		return null;
	}
1247722
protected function listen(string $event, string $methodName, int $priority = 0): EventListener
    {
        return new EventListener($event, [$this, $methodName], $priority);
    }
345918
function(event_name, event_args) {

		if (Lava.schema.DEBUG && typeof(event_name) == "undefined") Lava.t();

		if (this._listeners[event_name] != null) {

			this._callListeners(this._listeners[event_name], event_args);

		}

	}
847213
def get_event_from_name(self, event_name):
        
        return next((e for e in self.events if e.name == event_name), None)
690181
public function trigger($event_name, $default_handler_callback = "", $event_properties = array())
    {
        $event = null;
        if (isset($this->event_queue[$event_name])) { //if the event already exists, use the handler callback for the event instead of the default handler callback
            $event = $this->event_queue[$event_name];
            $event->setProperties($event_properties);

            $handler_callback = $event->getHandlerCallback();
            if (is_callable($handler_callback)) { 
                $result = call_user_func_array($handler_callback, array($event));
                $event->setHandlerCallbackReturnValue($result);
            }
        }
        else{ //event does not exist yet, use the default handler callback
            $event = new Event($event_name);
            $event->setProperties($event_properties);
            if (is_callable($default_handler_callback)) {
                $event->setHandlerCallback($default_handler_callback);
                $result = call_user_func_array($default_handler_callback, array($event));
                $event->setHandlerCallbackReturnValue($result);
                $this->event_queue[$event_name] = $event;
            }
        }

        $result = $event->getHandlerCallbackReturnValue();

        return $result;
    }
627809
protected function addEventListener($name, $callback, $priority = null)
    {
        if (is_null($priority)) {
            $this->events->listen($name, $callback);
        } else {
            $this->events->listen($name, $callback, $priority);
        }
    }
213846
public function removeListener(string $eventName, callable $listener): bool
    {
        // If it ends with a wildcard, we use the wildcardListeners array
        if ('*' === $eventName[\strlen($eventName) - 1]) {
            $eventName = \substr($eventName, 0, -1);
            $listeners = &$this->wildcardListeners;
        } else {
            $listeners = &$this->listeners;
        }

        if (!isset($listeners[$eventName])) {
            return false;
        }

        foreach ($listeners[$eventName] as $index => $check) {
            if ($check[1] === $listener) {
                // Remove listener
                unset($listeners[$eventName][$index]);
                // Reset index
                $this->listenerIndex = [];

                return true;
            }
        }

        return false;
    }
641488
public function removeEventListener(string $name, callable $listener): self
    {
        if (isset($this->internalEventListenersData[$name])) {
            foreach ($this->internalEventListenersData[$name] as $i => $value) {
                if ($value === $listener) {
                    unset($this->internalEventListenersData[$name][$i]);
                    if (empty($this->internalEventListenersData[$name])) {
                        unset($this->internalEventListenersData[$name]);
                    }
                    break;
                }
            }
        }
        return $this;
    }
603634
public function removeListener($eventName, $listener = null)
    {
        $eventName = $this->cleanEventName($eventName);

        if (!array_key_exists($eventName, $this->_list)) {
            return false;
        }

        foreach ($this->_list[$eventName] as $index => $eventData) {

            if ($eventData[1] === $listener) {
                unset($this->_list[$eventName][$index]);
                return true;
            }
        }

        return false;
    }
774332
public function countListeners($event)
    {
        if ($event instanceof EventInterface) {
            $event = $event->getName();
        }

        return isset($this->listeners[$event]) ? count($this->listeners[$event]) : 0;
    }
589973
protected static function getListenersSortByPriority(String $eventName) : Array
    {
        if ( ! isset(Properties::$listeners[$eventName]))
		{
			return [];
        }
        
        array_multisort(Properties::$listeners[$eventName][0], SORT_NUMERIC, Properties::$listeners[$eventName][1]);

        return Properties::$listeners[$eventName][1];
    }
593724
public function on(string $eventName, callable $callBack, int $priority = 100)
    {
        // If it ends with a wildcard, we use the wildcardListeners array
        if ('*' === $eventName[\strlen($eventName) - 1]) {
            $eventName = \substr($eventName, 0, -1);
            $listeners = &$this->wildcardListeners;
        } else {
            $listeners = &$this->listeners;
        }

        // Always fully reset the listener index. This is fairly sane for most
        // applications, because there's a clear "event registering" and "event
        // emitting" phase, but can be slow if there's a lot adding and removing
        // of listeners during emitting of events.
        $this->listenerIndex = [];

        if (!isset($listeners[$eventName])) {
            $listeners[$eventName] = [];
        }
        $listeners[$eventName][] = [$priority, $callBack];
    }
1286557
function(event, name) {
            var that = this;

            if (!(event in that.__events)) {
                that.__events[event] = {};
            }

            if (!_.isUndefined(name)) {
                if (!that.__hasEventListener(event, name)) {
                    throw new Error('There is no "' + event +  (name ? '"::"' + name : '') + '" event callback!');
                }

                that.__events[event][name] = undefined;
            }
            else {

                _.each(that.__getEventListeners(event), function(listener, name) {
                    that.__events[event][name] = undefined;
                });
            }

            return that;
        }
1135083
public function listen($event,$listener){
        $listers_of_event = isset($this->listeners[$event]) ? $this->listeners[$event] : array();
        if (!in_array($listener,$listers_of_event,true)){
            $listers_of_event[] = $listener;
            $this->listeners[$event] = $listers_of_event;
        }
    }
691992
public function dispatch( $event_name, Event $event = null ) {

		if ( is_null( $event ) ) {
			$event = new Event();
		}

		do_action( $this->get_action_name_for_event( $event_name ), $event, $event_name, $this );

		return $event;
	}