src/Service/EntityEraser/EntityEraserEvents.php
protected function triggerListeners(EventInterface $event, callable $callback = null)
    {
        if (!$event instanceof DependencyResultEvent) {
            throw new \InvalidArgumentException('This event manager only accepts events of the type ' . DependencyResultEvent::class);
        }

        $results = parent::triggerListeners($event, $callback);

        $dependencies = $event->getDependencyResultCollection();

        foreach ($results as $result) {
            if (null !== $result) {
                try {
                    $dependencies->add($result);
                }
                /* silently ignore all invalid results */
                catch (\UnexpectedValueException $e) {
                } catch (\InvalidArgumentException $e) {
                }
            }
        }

        return $results;
    }
protected function triggerListeners(EventInterface $event, callable $callback = null)
    {
        if (!$event instanceof DependencyResultEvent) {
            throw new \InvalidArgumentException('This event manager only accepts events of the type ' . DependencyResultEvent::class);
        }

        $results = parent::triggerListeners($event, $callback);

        $dependencies = $event->getDependencyResultCollection();

        foreach ($results as $result) {
            if (null !== $result) {
                try {
                    $dependencies->add($result);
                }
                /* silently ignore all invalid results */
                catch (\UnexpectedValueException $e) {
                } catch (\InvalidArgumentException $e) {
                }
            }
        }

        return $results;
    }
Triggers listeners.

Loops over the responses and tries to add any non empty response as a DepnendecyResult to the collection.

@param EventInterface $event
@param callable|null  $callback

@return \Zend\EventManager\ResponseCollection
@throws \InvalidArgumentException if the event is not an instance of DependencyResultEvent