Add one or more callbacks

@param string $name The name of the handler that owns the callback
@param array $events Which events the callback will trigger for
@param array $users User filter for the events
@return self
493902
public function addCallbacks($name, array $events, array $users = []) {
        // Default priority
        $defaultPriority = 0;

        foreach ($events as $event => $callback) {
            if (!isset($this->callbacks[$event])) {
                // Create a priority queue for this event
                $this->callbacks[$event] = new PriorityQueue();
            }

            if (is_string($callback)) {
                // 'eventName' => 'someMethod'
                $this->callbacks[$event]->insert([
                    'handler' => $name,
                    'method' => $callback,
                    'users' => $users,
                ], $defaultPriority);
            } else if (is_array($callback)) {
                // 'eventName' => [ ... ]
                foreach ($callback as $method => $priority) {
                    if (is_int($method)) {
                        // 'eventName' => ['someMethod', ...]
                        $method = $priority;
                        $priority = $defaultPriority;
                    }

                    $this->callbacks[$event]->insert([
                        'handler' => $name,
                        'method' => $method,
                        'users' => $users,
                    ], $priority);
                }
            } else if (is_int($callback)) {
                // We have a closure as a callback, so $callback is the actual priority
                $this->callbacks[$event]->insert([
                    'handler' => $name,
                    'users' => $users,
                ], $callback);
            } else {
                throw new InvalidArgumentException('Invalid event definition for listener: ' . $name, 500);
            }
        }

        return $this;
    }
513760
protected function call(string $name, array $parameters)
    {
        $definition = $this->registrar->get($name);

        $parameters = array_prepend(array_values($parameters), $this);

        call_user_func_array($definition, $parameters);
    }
905850
public function addFilter($callback, $name = null)
    {
        $tuple = $this->createFilterTuple(func_get_args());

        $this->filters[] = $tuple;

        $this->handleChangedParameters();

        return $this;
    }
689805
private function addSubscribers(array $eventSubscribers)
    {
        foreach ($eventSubscribers as $eventSubscriber) {
            if (is_string($eventSubscriber)) {
                $eventSubscriber = new $eventSubscriber();
            } elseif (is_callable($eventSubscriber)) {
                $eventSubscriber = call_user_func($eventSubscriber, $this->dispatcher);
            }

            $this->dispatcher->addSubscriber($eventSubscriber);
        }

        return $this;
    }
936515
protected function addMethod($name, $parameters)
    {
        $methods = $this->methods();

        $parameters = is_array($parameters) ? $parameters : [$parameters];

        $methods[] = compact('name', 'parameters');

        $this->methods($methods);
    }
1040405
protected function registerClientEvents($name, $id)
    {
        if (!empty($this->clientEvents)) {
            $js = [];
            foreach ($this->clientEvents as $event => $handler) {
                if (isset($this->clientEventMap[$event])) {
                    $eventName = $this->clientEventMap[$event];
                } else {
                    $eventName = strtolower($name . $event);
                }
                $js[] = "jQuery('#$id').on('$eventName', $handler);";
            }
            $this->getView()->registerJs(implode("\n", $js));
        }
    }
909445
public function trigger($name, ...$args)
    {
        //we should deal with strings
        //then callables respectively
        //to allow overriding
        if (is_string($name)) {
            //is it a protocol?
            if (strpos($name, '://') !== false) {
                return $this->triggerProtocol($name, ...$args);
            }

            //they can call a class
            if (strpos($name, '@') !== false) {
                return $this->triggerController($name, ...$args);
            }

            //unless it's a static call
            if (strpos($name, '::') !== false && is_callable($name)) {
                call_user_func_array($name, $args);
                return $this;
            }

            return $this->triggerEvent($name, ...$args);
        }

        if (is_callable($name)) {
            if ($name instanceof Closure) {
                $name = $this->bindCallback($name);
            }

            call_user_func_array($name, $args);
        }

        //we can only deal with callable and strings
        //we don't want to throw an error
        //because it could just be a pseudo
        //placeholder
        return $this;
    }
693210
public function trigger($name, ...$args)
    {
        if ($this->addThisToEvents) {
            array_unshift($args, $this);
        }
        if (isset($this->eventHandlers[$name])) {
            $this->lastEventName = $name;
            foreach ($this->eventHandlers[$name] as $cb) {
                if ($cb(...$args) === true) {
                    return $this;
                }
            }
        }
        return $this;
    }
1067860
public function setEventsList(array $events)
    {
        $this->data->events = array_merge($this->data->events, $events);

        return $this;
    }
1109442
public function addEvents(array $events)
    {
        foreach ($events as $event) {
            if ($event instanceof EventInterface) {
                $this->addEvent($event);
            }
        }
        return $this;
    }
1247264
public function addEventListener($eventName, array $listeners)
    {
        if (!array_key_exists($eventName, $this->options['events'])) {
            $this->options['events'][$eventName] = [
                'object' =>BaseEvent::class,
                'listeners' => $listeners,
            ];
        }

        $this->options['events'][$eventName]['listeners'] = array_merge(
            $this->options['events'][$eventName]['listeners'],
            $listeners
        );

        return $this;
    }
142516
function(name) {
      var args = _.toArray(arguments);
      args.shift();

      if (this._events && this._events[name]) {
        _.each(this._events[name], function(subscription) {
          subscription.callback.apply(subscription.context || this, args);
        }, this);
      }
      return this;
    }
167045
public function events($events=array())
    {
        if (!isset($this->_events)) {
            $this->_events = new Events(array(), self::schema()->events());
            $this->_registerDefaultEventHandlers();
        }

        if(count($events))
            foreach($events as $event=>$callback)
                $this->_events->register($event, $callback);

        return $this->_events;
    }
1250514
public function callback(string $name, callable $callback): self
    {
        $this->data->callback($name, $callback);
        return $this;
    }
194195
protected function bindEvents(): void
    {
        $userConfig = $this->app['config'][static::$abstract];

        $handler = new EventHandler($this->app->events, $userConfig);

        $handler->subscribe();

        $handler->subscribeQueueEvents($this->app->queue);

        if (isset($userConfig['send_default_pii']) && $userConfig['send_default_pii'] !== false) {
            $handler->subscribeAuthEvents();
        }
    }
499237
public function triggerGroup(?array $events = [], ?array $args = null)
  {
    foreach($events as $callback) {
      if (is_callable($callback)) {
        call_user_func_array($callback, isset($args) ? $args : []);
      }
      else if (is_string($callback)) {
        $call = new $callback;
        call_user_func_array([$call, 'persist'], $args ?? []);
      }
    }
  }
1316138
public function addHandlers(array $handlers)
    {
        foreach ($handlers as $handler) {
            if (isset($this->know[$handler->getName()])) {
                throw new \RuntimeException(sprintf(
                    'Cannot add handler "%s", handler exists.',
                    $handler->getName()
                ));
            }
            if (!class_exists($handler->getClass())) {
                throw new \RuntimeException(sprintf(
                    'Cannot add handler "%s", command class not exists.',
                    $handler->getName()
                ));
            }
            $this->know[$handler->getName()] = $handler;
        }
    }