protected function addListenersFromArray(SharedEventManagerInterface $manager, $id, $name)
    {
        if (!isset($this->data[$id][$name]) || (!is_array($this->data[$id][$name])
          && !($this->data[$id][$name] instanceof \Traversable))) {
            return $this;
        }

        $objectManager = $this->getObjectManager();

        foreach ($this->data[$id][$name] as $listener) {
            if (!$listener) {
                continue;
            }

            $priority = 1;

            if (is_array($listener) && isset($listener['listener'])) {
                $priority = (isset($listener['priority']))? (int)$listener['priority'] : 1;
                $listener = $listener['listener'];
            }

            if (is_string($listener)) {
                $listener = $objectManager->get($listener);
            }

            $manager->attach($id, $name, $listener, $priority);
        }

        return $this;
    }