Adds a DBListener to listen on some events of the DB class
@param DBListener $listener The listener object to register
@param string $name The name of the listener [optional]
771536
public function addListener(DBListener $listener, $name = null)
	{
		if($name !== null)
			$this->listeners->offsetSet($name, $listener);
		else
			$this->listeners->append($listener);
	}
116331
private function registerListener($event, callable $listener, $priority)
    {
        if (!isset($this->events[$event])) {
            $this->events[$event] = [];
        }

        if ($priority === null) {
            $this->events[$event][] = $listener;

            return;
        }

        array_splice($this->events[$event], (int) $priority, 0, [$listener]);
    }
1104578
public void addConnectionEventListener(ConnectionEventListener listener) {
    log.finest("addConnectionEventListener()");
    if (listener == null)
      throw new IllegalArgumentException("Listener is null");
    listeners.add(listener);
  }
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;
        }
    }
26004
public function listen($name, $listenerInterface)
    {

        $name = is_object($name) ? get_class($name) : $name;

        if ($listenerInterface instanceof EventListener && $listenerInterface instanceof SubscriberInterface) {
            $listeners = $listenerInterface->getSubscribedEvents();

            foreach ($listeners as $listener => $callback) {
                if (!$callback instanceof Closure) {
                    $callback = [$listenerInterface, $callback];
                }

                if(is_integer($listener)){
                    EventCollector::addListener($name, $callback);

                }else{
                    EventCollector::addListener($name.'.'.$listener, $callback);
                }
            }

        } else {
            EventCollector::addListener($name, $listenerInterface);
        }

        return $this;
    }
699779
public function addEventListener($eventName, callable $listener, $priority = Emitter::P_NORMAL)
    {
        $this->eventEmitter->addListener($eventName, $listener, $priority);
    }
628696
protected function makeEventAndListeners($event, $listeners)
    {
        if (! Str::contains($event, '\\')) {
            return;
        }

        $this->call('generate:event', ['name' => $event]);

        $this->makeListeners($event, $listeners);
    }
331301
protected function addEventListener($name, $callback)
    {
        if (Str::contains($name, '*')) {
            $callback = function ($name, array $data) use ($callback) {
                return $callback($data[0]);
            };
        }

        $this->events->listen($name, $callback);
    }
626094
public void addListener(BaseListener listener)
    {
        listener.setNextListener(null);  // Just being safe
        if ((this.getRecord() != null) && (this.getRecord().getTable() != null))
            this.getRecord().getTable().addListener((FieldListener)listener, this);   // Give the table a chance to clone this or whatever.
        else
            this.doAddListener((FieldListener)listener);
    }
375459
public function addListenerByClass(string $class, $listener)
    {
        $class = trim($class, '\\');

        if (!isset($this->classListeners[$class])) {
            $this->classListeners[$class] = [];
        }
        $this->classListeners[$class][] = $listener;
    }
572706
public function register(string $name, $callback) : Event
    {
        if (is_null($name)) {
            throw new \RuntimeException(sprintf('Event name cannot be empty in %s', __FUNCTION__));
        }

        if (is_null($callback)) {
            throw new \RuntimeException(sprintf('Empty parameter passed as callback in %s function', __FUNCTION__));
        }

        if (!isset($this->events[$name])) {
            $this->events[$name] = [];
        }

        if (!in_array($callback, $this->events[$name])) {
            $this->events[$name][] = $callback;
        }

        return $this;
    }
1232790
protected function callListenerBindings(Listener $listener, Event $event)
    {
        $binding = $listener->determineEventBinding($event);

        if ($listener->hasBinding($binding)) {
            foreach ($listener->getBindings($binding) as $callback) {
                $resource = $event->getResource();

                call_user_func($callback, $resource, $resource->getPath());
            }
        }

        // If a listener has a binding for anything we'll also spin through
        // them and call each of them.
        if ($listener->hasBinding('*')) {
            foreach ($listener->getBindings('*') as $callback) {
                $resource = $event->getResource();

                call_user_func($callback, $event, $resource, $resource->getPath());
            }
        }
    }
773522
function(eventName, listener) {
			if (typeof listener === "function" || listener.handleEvent) {
				this._namedListeners[eventName] = this._namedListeners[eventName] || [];
				this._namedListeners[eventName].push(listener);
			}
		}
972054
public function addListener( $event, EventListener $listener ) {

		if ( !is_string( $event ) ) {
			throw new InvalidArgumentException( "Expected a string" );
		}

		$event = strtolower( $event );

		if ( !isset( $this->dispatchableListeners[$event] ) ) {
			$this->dispatchableListeners[$event] = array();
		}

		$this->dispatchableListeners[$event][] = $listener;
	}
356875
public function add(Listener $listener) : void
    {
        if ($this->open) {
            $listener->listenOn($this->zeromq);
        }
    }
1258705
protected function addEventListener($name, $callback, $priority, $accepted_args)
    {
        $this->hooks[$name] = [$callback, $priority, $accepted_args];
        $this->addAction($name, $callback, $priority, $accepted_args);
    }
573511
public final synchronized void add(String name, L listener) {
        if (this.map == null) {
            this.map = new HashMap<>();
        }
        L[] array = this.map.get(name);
        int size = (array != null)
                ? array.length
                : 0;

        L[] clone = newArray(size + 1);
        clone[size] = listener;
        if (array != null) {
            System.arraycopy(array, 0, clone, 0, size);
        }
        this.map.put(name, clone);
    }