Attaches a listener to an event

@param string $event the event to attach too
@param callable $callback a callable function
@param int $priority the priority at which the $callback executed
@return bool true on success false on failure
553262
public function attach(string $event, callable $callback, int $priority = 0){
        if(!isset($this->listeners[$event])){
            $this->listeners[$event] = new Performer();
        }
        $this->listeners[$event]->add($callback, $priority);
    }
911382
public static function insert($eventName = NULL, $callback = NULL, $priority = NULL)
    { 
        if( $callback === NULL || is_int($callback) )
        {
            $priority  = $callback;
            $callback  = $eventName;
            $eventName = Properties::$startListenerName;
        }
        else
        {
            Properties::$startListenerName = $eventName;
        }

        $callback = self::callback($callback);
            
        if( ! is_callable($callback) )
        {
            throw new InvalidCallbackMethodException;
        }

        if( isset(Properties::$listeners[$eventName]) )
        {
            Properties::$listeners[$eventName][0][] = $priority;
			Properties::$listeners[$eventName][1][] = $callback;
        }
        else
        {
            Properties::$listeners[$eventName] = [[$priority], [$callback]];
        }
    }
1304146
public function on($eventName, $callback, $priority = 0)
    {
        if ($this->booted) {
            $this->container['event_dispatcher']->addListener($eventName, $this->container['callback_resolver']->resolveCallback($callback), $priority);

            return;
        }

        $this->container->extend('event_dispatcher', function ($dispatcher, $c) use ($callback, $priority, $eventName) {
            $dispatcher->addListener($eventName, $c['callback_resolver']->resolveCallback($callback), $priority);

            return $dispatcher;
        });
    }
1111178
public function listen($events, $listener, $priority = 0)
    {
        //$priority = sprintf('p:%s', str_pad($priority, 6, '0', STR_PAD_LEFT));

        foreach ((array) $events as $event) {
            $this->listeners[$event][$priority][] = $this->makeListener($listener);
        }
    }
495330
public function attach(EventManagerInterface $events, $priority = 1000)
    {
        if (PHP_SAPI === 'cli') {
            return;
        }

        $this->listeners[] = $events->getSharedManager()->attach(
            Application::class,
            MvcEvent::EVENT_ROUTE,
            [
                $this,
                'onRouteRemoveTrailingSlash'
            ],
            $priority
        );

        $this->listeners[] = $events->getSharedManager()->attach(
            Application::class,
            MvcEvent::EVENT_ROUTE,
            [
                $this,
                'onRouteNormalizeParameters'
            ],
            -$priority
        );
    }
178945
public function listen($events, $listener, $priority=0)
    {
        $this->dispatcher->listen($events, $listener, $priority);
    }
456681
public static function on($event, $callback){

        if( !isset(self::$observers[ $event ]) ){
            self::$observers[ $event ] = array();
        }

        self::$observers[ $event ][] = $callback;
    }
880076
public function before($callback, $priority = 0)
    {
        //        $app = $this;
        $container = $this->container;

        $this->on(KernelEvents::REQUEST, function (GetResponseEvent $event) use ($callback, $container) {
            if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
                return;
            }

            $ret = call_user_func($container['callback_resolver']->resolveCallback($callback), $event->getRequest(), $container);

            if ($ret instanceof Response) {
                $event->setResponse($ret);
            }
        }, $priority);
    }
241488
public function attach(EventManagerInterface $events, $priority = -500)
    {
        $this->listeners[] = $events->attach(
            AuthenticationEvent::AUTH,
            [
                $this,
                'onAuthentication'
            ],
            $priority
        );
    }
374766
public function listenTo($event, $listeners, $priority = 0)
    {
        /** @var \Rocketeer\Tasks\AbstractTask[] $listeners */
        $listeners = $this->builder->isCallable($listeners) ? [$listeners] : (array) $listeners;
        $listeners = $this->builder->buildTasks($listeners);
        $event = Str::contains($event, ['commands.', 'strategies.', 'tasks.']) ? $event : 'tasks.'.$event;

        // Register events
        foreach ($listeners as $key => $listener) {
            $handle = $this->getEventHandle(null, $event);
            $this->events->addListener($handle, $listener, $priority ?: -$key);
        }

        return $event;
    }
403447
public function listen($events, $listener, $priority = 0, $acceptedArgs = 1)
    {
        foreach ((array)$events as $event)
        {
            $this->listeners[$event][$priority][] = $this->makeListener($listener);

            unset($this->sorted[$event]);

            if ( ! isset($this->registeredWpActions[$event]))
            {
                $this->registeredWpActions[$event] = true;

                add_action(
                    $event,
                    function () use ($event)
                    {
                        return $this->fire($event, func_get_args());
                    },
                    $priority,
                    $acceptedArgs
                );
            }
        }
    }
1136699
public function bind(string $event, callable $callback) {
        // We can't bind to something that isn't callable
        if (!is_callable($callback)) {
            return false;
        }

        if (!isset($this->bindings[$event]) || !is_array($this->bindings[$event])) {
            $this->bindings[$event] = [];
        }

        // Check if this event is already registered
        $signature = $this->hash($callback);
        if (array_key_exists($signature, $this->bindings[$event])) {
            return $signature;
        }

        $this->bindings[$event][$signature] = $callback;
        return $signature;
    }
695162
public function detach($event, $callback)
    {
        if (!isset($this->eventListeners[$event]) || $this->eventListeners[$event]->isEmpty()) {
            return false;
        }

        $removed = false;
        $listeners = $this->eventListeners[$event];
        $newListeners = new ListenerQueue();

        $listeners->setExtractFlags(ListenerQueue::EXTR_BOTH);
        foreach ($listeners as $item) {
            if ($item['data'] === $callback) {
                $removed = true;
                continue;
            }

            $newListeners->insert($item['data'], $item['priority']);
        }
        $listeners->setExtractFlags(ListenerQueue::EXTR_DATA);

        $this->eventListeners[$event] = $newListeners;

        return $removed;
    }
256812
public static function listen($event, $callback)
	{
		if (!isset(self::$events[$event])) {
			self::$events[$event] = array();
		}
		
		self::$events[$event][] = $callback;
		return true;
	}
484647
public function listen($event, $callable, $priority = ListenerPriority::NORMAL)
    {
        $this->getDispatcher()->listen($event, $callable, $priority);

        return $this;
    }
664097
protected function addEventListener($name, $callback, $priority, $accepted_args)
    {
        $this->hooks[$name] = [$callback, $priority, $accepted_args];
        $this->addFilter($name, $callback, $priority, $accepted_args);
    }
1258705
protected function addEventListener($name, $callback, $priority, $accepted_args)
    {
        $this->hooks[$name] = [$callback, $priority, $accepted_args];
        $this->addAction($name, $callback, $priority, $accepted_args);
    }