Adds a subscription.

@param string   $event    The unique name of the event.
@param string   $listener The unique name of the listener.
@param callable $callback The closure or invokable object.
761575
public function subscribe(string $event, string $listener, callable $callback)
    {
        $callbackKey = $event . ' ' . $listener;
        $this->events[$event][] = $callbackKey;
        $this->subscriptions[$callbackKey] = $callback;
    }
1281974
public function onBefore($event, callable $listener)
    {
        if ($this->markFilters) {
            $listener = $this->wrap($listener, '*', $this->markFilters);
        }

        $this->root->onBefore($event, $listener);

        return $this;

    }
228858
void register(Object listener) {
    Multimap<Class<?>, Subscriber> listenerMethods = findAllSubscribers(listener);

    for (Map.Entry<Class<?>, Collection<Subscriber>> entry : listenerMethods.asMap().entrySet()) {
      Class<?> eventType = entry.getKey();
      Collection<Subscriber> eventMethodsInListener = entry.getValue();

      CopyOnWriteArraySet<Subscriber> eventSubscribers = subscribers.get(eventType);

      if (eventSubscribers == null) {
        CopyOnWriteArraySet<Subscriber> newSet = new CopyOnWriteArraySet<Subscriber>();
        eventSubscribers =
            MoreObjects.firstNonNull(subscribers.putIfAbsent(eventType, newSet), newSet);
      }

      eventSubscribers.addAll(eventMethodsInListener);
    }
  }
451556
public function listen($event, $listener){
        if (!$this->emitter){
            return $this;
        }
        $this->emitter->listen($event, $listener);
        return $this;
    }
301901
public function addListener($event, $method)
    {
        if (!isset($this->listeners[$event])) {
            $this->listeners[$event] = array();
        }

        $this->listeners[$event][] = $method;
    }
1019365
public function removeListener($event, $listener)
    {
        // shortcut to only remove a listener if they exist
        // having this allows us to simplify calling code
        if( !isset($listener) ) {
            return $this;
        }

        // listeners
        if (isset($this->listeners[$event])) {
            if (false !== ($key = array_search($listener, $this->listeners[$event]))) {
                unset($this->listeners[$event][$key]);
            }
            if( !$this->listeners[$event] ) {
                unset( $this->listeners[$event] );
            }
        }
        // listeners once
        if (isset($this->listenersOnce[$event])) {
            if (false !== ($key = array_search($listener, $this->listenersOnce[$event]))) {
                unset($this->listenersOnce[$event][$key]);
            }
            if( !$this->listenersOnce[$event] ) {
                unset( $this->listenersOnce[$event] );
            }
        }
        return $this;
    }
864866
public static function addListener($name, $listener)
    {
        if (!isset(static::$listeners[$name])) {
            static::$listeners[$name] = [];
        }
        if(!is_array($listener)){
            static::$listeners[$name][] = $listener;
        }else{
            static::$listeners[$name] = array_merge(static::$listeners[$name], $listener);
        }

    }
1361291
public function attachListener(EventListener $listener)
    {
        foreach ($listener->getEventHandlers() as $name => $method) {
            if (! is_string($name)) {
                $name = $method;
                if (strpos($method, '.') !== false) {
                    $splits = explode('.', $method);
                    $method = $splits[count($splits) - 1];
                }
            }
            $this->attachHandler($name, array(
                $listener,
                $method
            ));
        }
    }
190132
public function add_listener($event) {
		if (strpos('::', $event) === false) {
			$classname = get_called_class();
			$method = $event;
		} else {
			list($classname, $method) = explode('::', $event);
		}
		$event_name = strtolower(str_replace('\\', '_', $classname . '_' . $method));

		$dispatcher = \Skeleton\Event\Dispatcher::get();
		$dispatcher->add_listener($event_name, [ '\\Event\\' . $classname, $method ]);
	}
1301737
public void subscribeToEvent(final EventListener eventListener, final Class<? extends AbstractTaskEvent> eventType) {

		synchronized (this.subscriptions) {

			List<EventListener> subscribers = this.subscriptions.get(eventType);
			if (subscribers == null) {
				subscribers = new ArrayList<EventListener>();
				this.subscriptions.put(eventType, subscribers);
			}
			subscribers.add(eventListener);
		}

	}
790458
function (object, event, callback) {
        var index = this.indexOf(object);
        var listener = this.listeners[index];
        if (!listener) {
            listener = {
                'object': object,
                'events': {}
            };
            this.listeners.push(listener);
        }

        var callbacks = listener.events[event];
        if (!callbacks) {
            callbacks = [];
            listener.events[event] = callbacks;
        }

        // add the callback if it does not yet exist
        if (callbacks.indexOf(callback) == -1) {
            callbacks.push(callback);
        }
    }
1190756
public function on($event, $callback)
    {
        $this->router->removeAllListeners($event);
        $this->router->on($event, $callback);
    }
1036853
public function addEventListener($events, $listener)
    {
        if (\is_string($listener)) {
            if ($this->initialized) {
                throw new \RuntimeException('Adding lazy-loading listeners after construction is not supported.');
            }

            $hash = '_service_'.$listener;
        } else {
            // Picks the hash code related to that listener
            $hash = spl_object_hash($listener);
        }

        foreach ((array) $events as $event) {
            // Overrides listener if a previous one was associated already
            // Prevents duplicate listeners on same event (same instance only)
            $this->listeners[$event][$hash] = $listener;
        }
    }
107912
public function register($event, callable $listener, $priority = null)
    {
        foreach ((array) $event as $e) {
            $this->registerListener($e, $listener, $priority);
        }

        return $this;
    }
1168413
public function listen($event, $callback)
    {
        if (!isset($this->listeners[$event])) {
            $this->listeners[$event] = [];
        }

        $this->listeners[$event][] = $callback;
    }
248083
protected function makeListeners($event, $listeners)
    {
        foreach ($listeners as $listener) {
            $listener = preg_replace('/@.+$/', '', $listener);

            $this->callSilent('make:listener', array_filter(
                ['name' => $listener, '--event' => $event]
            ));
        }
    }
1003046
public function removeListener( $event, EventListener $listener = null ) {

		$event = strtolower( $event );

		if ( !$this->hasEvent( $event ) ) {
			return;
		}

		if ( $listener !== null ) {
			foreach ( $this->dispatchableListeners[$event] as $key => $dispatchableListener ) {
				if ( $dispatchableListener == $listener ) {
					unset( $this->dispatchableListeners[$event][$key] );
				}
			}
		}

		if ( $listener === null || $this->dispatchableListeners[$event] === array() ) {
			unset( $this->dispatchableListeners[$event] );
		}
	}