Installs a listener on a subscribable (not bus) source.

@param string $targetEventName
321977
protected function listenToSubscribable($targetEventName)
    {
        foreach ($this->sourcePatterns as $event) {
            $listener = $this->newSubscribableListener($event, $targetEventName);
            $this->source->on($event, $listener);
        }
        $this->isFixed = true;
    }
1070379
public function addListener($name, $listener, $priority = 0)
    {
        if (! isset($this->listeners[$name])) $this->listeners[$name] = [];
        $this->listeners[$name][$priority][] = $listener;
    }
773522
function(eventName, listener) {
			if (typeof listener === "function" || listener.handleEvent) {
				this._namedListeners[eventName] = this._namedListeners[eventName] || [];
				this._namedListeners[eventName].push(listener);
			}
		}
323642
public function remove($targetName)
    {
        if (InstallTarget::DEFAULT_TARGET === $targetName && $this->defaultTarget) {
            $targetName = $this->defaultTarget->getName();
        }

        unset($this->targets[$targetName]);

        if ($this->defaultTarget && $targetName === $this->defaultTarget->getName()) {
            $this->defaultTarget = $this->targets ? reset($this->targets) : null;
        }
    }
1366161
public function install($filename, $target)
    {
        if (!file_exists($filename))
        {
            throw new RuntimeException('Template file not found: ' . $filename);
        }

        $target = $this->rootDir . '/' . $target;
        if (!file_exists($target))
        {
            try
            {
                $umask = umask(0000);
                mkdir($target, 0777, true);
                umask($umask);
            }
            catch (Exception $e)
            {
                throw new RuntimeException(
                    'Can not create target directory: ' . $target, null, $e);
            }
        }

        $target .= '/' . basename($filename);

        if (file_exists($target))
        {
            throw new RuntimeException(sprintf('Template "%s" is already installed', $target));
        }

        if (!copy($filename, $target))
        {
            throw new RuntimeException(sprintf('Failed to copy "%s" to "%s"', $filename, $target));
        }
    }
951849
public function addTarget($targetName, $target)
    {
        if (isset($this->targets[$targetName])) {
            throw new BuildException("Duplicate target: $targetName");
        }
        $this->addOrReplaceTarget($targetName, $target);
    }
1357886
protected function lazyLoad($eventName)
    {
        if (isset($this->listenerIds[$eventName])) {
            foreach ($this->listenerIds[$eventName] as $args) {
                list($serviceId, $method, $priority) = $args;
                $listener = $this->container->get($serviceId);

                $key = $serviceId.'.'.$method;
                if (!isset($this->listeners[$eventName][$key])) {
                    $this->addListener($eventName, array($listener, $method), $priority);
                } elseif ($listener !== $this->listeners[$eventName][$key]) {
                    parent::removeListener($eventName, array($this->listeners[$eventName][$key], $method));
                    $this->addListener($eventName, array($listener, $method), $priority);
                }

                $this->listeners[$eventName][$key] = $listener;
            }
        }
    }
664097
protected function addEventListener($name, $callback, $priority, $accepted_args)
    {
        $this->hooks[$name] = [$callback, $priority, $accepted_args];
        $this->addFilter($name, $callback, $priority, $accepted_args);
    }
926651
public function attach($eventName, $callback, $priority = 1): void
    {
        if (!isset($this->listeners[$eventName])) {
            $this->listeners[$eventName] = [];
        }
        if (!isset($this->listeners[$eventName][$priority])) {
            $this->listeners[$eventName][$priority] = [];
        }
        $this->listeners[$eventName][$priority][] = $callback;
    }
317587
public function contains($targetName)
    {
        if (InstallTarget::DEFAULT_TARGET === $targetName) {
            return null !== $this->defaultTarget;
        }

        return isset($this->targets[$targetName]);
    }
682314
public function subscribeEvent($eventName)
    {
        if (!isset($this->subscribedEvents[$eventName])) {
            throw new InvalidArgumentException("Event $eventName doesn't exists in client context");
        }

        $this->subscribedEvents[$eventName] = true;
    }
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;
    }
769119
public function subListen($name, $event, $callable, $priority = ListenerPriority::NORMAL)
    {
        return $this->addSubListener($name, $callable, [$event => $priority]);
    }
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;
        });
    }
9573
function addEvent(target, name, callback, capture) {
      if (target.addEventListener) {
        target.addEventListener(name, callback, capture || false);
      } else if (target.attachEvent) {
        target.attachEvent('on' + name, callback);
      }
    }
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];
    }
207029
public function fire($eventName, $subject = null)
    {
        if (!isset($this->events[$eventName])) {
            return $subject;
        }

        $event = new Event($eventName, $subject);

        foreach ($this->events[$eventName] as $listener) {
            if ($event->isStopped()) {
                break;
            }

            $listener($event);
        }

        return $event->getSubject();
    }