Attach listeners from array

@param array $listeners
481622
public static function configure(EventManagerInterface $eventManager, ServiceLocatorInterface $serviceLocator, array $listeners)
    {
        if (!empty($listeners)) {
            foreach ($listeners as $key => $value) {
        
                if ($value instanceof ListenerAggregateInterface) {
                    $listener = $value;
                } elseif(is_string($value) && $serviceLocator->has($value)) {
                    $listener = $serviceLocator->get($value);
                } elseif(is_string($value) && class_exists($value)) {
                    $listener = new $value();
                } else {
                    $listener = $value;
                }
        
                if ($listener instanceof ListenerAggregateInterface) {
                    $eventManager->attachAggregate($listener);
                } elseif (isset($listener['event']) && isset($listener['callback'])) {
                    $eventManager->attach($listener['event'], $listener['callback']);
                } else {
                    throw new InvalidListenerException(
                            sprintf("Listener for service ID %s doesn't implement ListenerAggregateInterface", $value));
                }
            }
        }
    }
846844
public function attach(EventManagerInterface $events)
    {
        $this->listeners[] = $events->attach(MvcEvent::EVENT_DISPATCH, 
            array(
                $this,
                'injectPlugin'
            ), 100);
        $this->listeners[] = $events->attach(MvcEvent::EVENT_FINISH, 
            array(
                $this,
                'storeRoute'
            ), - 100);
    }
509793
public void addListeners(Set<ScriptModuleListener> listeners) {
        Objects.requireNonNull(listeners);
        this.listeners.addAll(listeners);
    }
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;
        }
    }
73883
public static function registerListeners(array $listeners)
    {
        foreach ($listeners as $eventName => $eventListeners) {
            foreach ($eventListeners as $listenerClassName) {
                $listener = self::getBean($listenerClassName);
                self::addListener($eventName, $listener);
            }
        }
    }
481784
public function initialize(Listener $listener)
    {
        $this->tracker->initialize($listener);
        $this->wathedPaths = $listener->getPaths();
    }
1111178
public function listen($events, $listener, $priority = 0)
    {
        //$priority = sprintf('p:%s', str_pad($priority, 6, '0', STR_PAD_LEFT));

        foreach ((array) $events as $event) {
            $this->listeners[$event][$priority][] = $this->makeListener($listener);
        }
    }
214246
function attachListener (msg, listener) {
  var attached = msg.__onFinished

  // create a private single listener with queue
  if (!attached || !attached.queue) {
    attached = msg.__onFinished = createListener(msg)
    attachFinishedListener(msg, attached)
  }

  attached.queue.push(listener)
}
430239
protected function callListeners($abstract, $result, array $listeners)
    {
        if (isset($listeners[$abstract])) {
            $this->iterateListeners($listeners[$abstract], $result);
        }

        foreach ($listeners as $classOrInterface => $instanceListeners) {

            // We already called them above
            if ($classOrInterface == $abstract) {
                continue;
            }

            if (!$result instanceof $classOrInterface) {
                continue;
            }

            $this->iterateListeners($instanceListeners, $result);
        }
    }
1196585
static private function bindEventListenersEvents()
    {
    	if (self::$_eventListeners && !self::$_elInstances) {
    		foreach (self::$_eventListeners as $class => $listeners) {
    			if ($listeners) foreach ($listeners as $listener) {
    				
    				$listener = self::getListener($listener);
    				
    				$events = $listener->events();
    				
    				if ($events) foreach ($events as $name => $handler) {
    					Event::on($class, $name, is_string($handler) ? [$listener, $handler] : $handler);
    				}
    			}
    		}
    	}
    }
303482
public void setListeners(java.util.Collection<Listener> listeners) {
        if (listeners == null) {
            this.listeners = null;
            return;
        }

        this.listeners = new com.amazonaws.internal.SdkInternalList<Listener>(listeners);
    }
971091
protected function _callListeners($listeners, array $arguments)
    {
        $execCount = 0;

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

        return $execCount;
    }
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;
  }
1059494
public void setListeners(Collection<IWebSocketDataListener> listeners) {
        log.trace("setListeners: {}", listeners);
        this.listeners.addAll(listeners);
    }
161241
public function mergeEventListeners($eventListeners)
    {
        if ($eventListeners instanceof EventManagerInterface) {
            $eventListeners = $eventListeners->getEventListeners();
        }

        foreach (((array) $eventListeners) as $eventName => $listeners) {
            $queue = [];
            if (isset($this->eventListeners[$eventName])) {
                $innerListeners = clone $this->eventListeners[$eventName];
                $innerListeners->setExtractFlags(ListenerQueue::EXTR_DATA);
                foreach ($innerListeners as $callback) {
                    $queue[] = $callback;
                }
            }
            $listeners = clone $listeners;
            $listeners->setExtractFlags(ListenerQueue::EXTR_BOTH);
            foreach ($listeners as $listener) {
                if (!in_array($listener['data'], $queue)) {
                    $this->attach($eventName, $listener['data'], $listener['priority']);
                }
            }
        }

        return true;
    }
891134
public function attach(EventManagerInterface $events)
    {
        foreach ($this->eventMap as $eventName => $items) {
            if (!is_array($items)) {
                $errMsg = 'Handlers config not array';
                throw new Exception\RuntimeException($errMsg);
            }

            foreach ($items as $item) {
                if (!is_array($item)) {
                    $errMsg = 'Handler not array';
                    throw new Exception\RuntimeException($errMsg);
                }

                if (!array_key_exists('handler', $item)) {
                    $errMsg = 'Handler not found';
                    throw new Exception\RuntimeException($errMsg);
                }
                $handler = $item['handler'];

                $priority = 1;
                if (array_key_exists('priority', $item)) {
                    $priority = (integer)$priority;
                }

                $this->listeners[] = $events->attach($eventName, $handler, $priority);
            }
        }
    }
1273295
public function AttachObserver($listener)
	{
		if ($listener) {
			$this->_observers[] =& $listener;
			if ($this->_masterAdapter) $this->_masterAdapter->AttachObserver($listener);
		}
		
	}