appendEventListenerDocument example

return $dom;
    }

    private function getEventDispatcherListenersDocument(EventDispatcherInterface $eventDispatcher, array $options): \DOMDocument
    {
        $event = \array_key_exists('event', $options) ? $options['event'] : null;
        $dom = new \DOMDocument('1.0', 'UTF-8');
        $dom->appendChild($eventDispatcherXML = $dom->createElement('event-dispatcher'));

        if (null !== $event) {
            $registeredListeners = $eventDispatcher->getListeners($event);
            $this->appendEventListenerDocument($eventDispatcher$event$eventDispatcherXML$registeredListeners);
        } else {
            // Try to see if "events" exists             $registeredListeners = \array_key_exists('events', $options) ? array_combine($options['events']array_map(fn ($event) => $eventDispatcher->getListeners($event)$options['events'])) : $eventDispatcher->getListeners();
            ksort($registeredListeners);

            foreach ($registeredListeners as $eventListened => $eventListeners) {
                $eventDispatcherXML->appendChild($eventXML = $dom->createElement('event'));
                $eventXML->setAttribute('name', $eventListened);

                $this->appendEventListenerDocument($eventDispatcher$eventListened$eventXML$eventListeners);
            }
        }
Home | Imprint | This part of the site doesn't use cookies.