Call list of listeners

@param array $listeners
@param array $arguments
@return int|string
971091
protected function _callListeners($listeners, array $arguments)
    {
        $execCount = 0;

        foreach ($listeners as $listener) {
            if ($result = $this->_callListener($listener, $arguments)) {
                return $result;
            }
            $execCount++;
        }

        return $execCount;
    }
495016
protected function invokeListeners($name, EventInterface $event, array $arguments)
    {
        $listeners = $this->getListeners($name);

        foreach ($listeners as $listener) {
            if ($event->isPropagationStopped()) {
                break;
            }

            call_user_func_array([$listener, 'handle'], $arguments);
        }
    }
120627
private function callCountBy(string $method, array $arguments)
    {
        $whereByWithUpper = lcfirst(substr($method, 7, mb_strlen($method)));
        $whereBy = Str::convertCamelCaseToSnakeCase($whereByWithUpper);

        $column = (isset($arguments[1])) ? $arguments[1] : '*';

        return $this->where($whereBy, '=', $arguments[0])->count($column);
    }
150371
public function setEventListeners($listeners)
	{
		$this->ensureEventListeners();
		
		foreach ($listeners as $listener) {
			$this->_eventListeners[Ioc::resolveClassName($listener)] = $listener;
		}
		
		return $this;
	}
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;
    }
1345418
public function getListeners($event): array
    {
        $event = $this->getEventName($event);

        if (! $this->hasListener($event)) {
            return [];
        }

        if (! array_key_exists($event, $this->sortedListeners)) {
            $listeners = $this->listeners[$event];

            krsort($listeners);

            $listeners = call_user_func_array(
                'array_merge',
                $listeners
            );
            $this->sortedListeners[$event] = $listeners;

            unset($listeners);
        }

        return $this->sortedListeners[$event];
    }
819708
public function addListener($callback)
	{
		$index = count($this->listeners);
		$this->listeners[] = $callback;
		return $index;
	}
95382
protected function removeEventListeners(array $listeners)
  {
    try
    {
      foreach ($listeners as $listener)
      {
        $this->dispatcher->removeListener(
          $listener['event'],
          array(
            $listener['class'],
            $listener['method']
          )
        );
      }
    }
    catch (\Exception $e)
    {
      throw new TransformerException($e->getMessage());
    }

    return $this;
  }
37415
private static function getArguments(array $arguments = [])
    {
        $args = [];

        foreach ($arguments as $argument) {
            $args[] = $argument instanceof self ? $argument->getMoney() : $argument;
        }

        return $args;
    }
335376
function triggerListeners(listeners, event, args)
  {
    if (listeners && event in listeners)
    {
      var eventListeners = listeners[ event ];
      var triggerGroup = ++triggerId;
      var next, node = eventListeners.next;

      while (node !== eventListeners)
      {
        next = node.next;
        node.trigger( triggerGroup, args, false );
        node = next;
      }

      node = eventListeners.next;

      while (node !== eventListeners)
      {
        next = node.next;
        node.trigger( triggerGroup, args, true );
        node = next;
      }
    }
  }
175388
private function triggerCallback($callback, $arguments)
    {
        if (is_array($callback)) {
            $this->import($callback[0]);
            return call_user_func_array(array($this->{$callback[0]}, $callback[1]), $arguments);
        } elseif (is_callable($callback)) {
            return call_user_func_array($callback, $arguments);
        }

        return null;
    }
869785
public function setListeners(array $listeners)
    {
        $this->listeners = [];

        foreach ($listeners as $name => $listener) {
            $this->addListener($name, $listener);
        }
    }
761095
protected function callAllListeners($args = [])
    {
        $args = (array) $args;
        array_map(function ($event) use ($args) {
            $this->callListeners($event, $args);
        }, array_keys($this->listeners));
    }
977903
public function createClassListener($listener)
	{
		$container = $this->container;

		return function() use ($listener, $container)
		{
			// If the listener has an @ sign, we will assume it is being used to delimit
			// the class name from the handle method name. This allows for handlers
			// to run multiple handler methods in a single class for convenience.
			$segments = explode('@', $listener);

			$method = count($segments) == 2 ? $segments[1] : 'handle';

			$callable = array($container->make($segments[0]), $method);

			// We will make a callable of the listener instance and a method that should
			// be called on that instance, then we will pass in the arguments that we
			// received in this method into this listener class instance's methods.
			$data = func_get_args();

			return call_user_func_array($callable, $data);
		};
	}
755183
protected function callListener(callable $listener, array $args = [])
    {
        switch (count($args)) {
            case 0:
                return call_user_func($listener);
            case 1:
                return call_user_func($listener, $args[0]);
            case 2:
                return call_user_func($listener, $args[0], $args[1]);
            case 3:
                return call_user_func($listener, $args[0], $args[1], $args[2]);
            case 4:
                return call_user_func($listener, $args[0], $args[1], $args[2], $args[3]);
        }

        return call_user_func_array($listener, $args);
    }
1094386
protected function ensureListener($listener)
    {
        if ($listener instanceof ListenerInterface) {
            return $listener;
        }

        if (is_callable($listener)) {
            return CallbackListener::fromCallable($listener);
        }

        throw new InvalidArgumentException('Listeners should be be ListenerInterface, Closure or callable. Received type: '.gettype($listener));
    }
542103
public function getListeners($name)
    {
        $result = array();
        if (isset($this->_listeners[$name])) {
            $result = $this->_listeners[$name];
        }
        
        return $result;
    }