protected function normalizeListenerOptions($name, $options)
    {

        /*
         * $options is an array with following meta-syntax:
         *
         *  $options = [
         *      string:listener => string:event,
         *      string:listener => [ string|array:event{, string:methodName}{, int:priority}{, bool:lazy }],
         *      string:aggregate, // implies integer value as $name
         *      string:aggregate => int:priority,
         *      string:listener => [
         *          'events' => [ 'event', 'event' => priority, 'event' => 'method',
         *                        'event' => [ 'method' => method, 'priority' => priority ],
         *                        'event' => [ 'method' => [ 'method', 'method' => priority ], 'priority' => priority ]
         *                     ],
         *          'method' => method,
         *          'priority' => priority,
         *          'lazy' => bool
         * ]
         */

        $normalized = [
            'service' => $name,
            'attach' => null,
            'priority' => 1,
            'lazy' => false,
        ];

        if (is_int($name)) {
            /* $options must be the name of an aggregate service or class. */
            $normalized['service'] = $options;
            return $normalized;
        }

        if (is_int($options)) {
            /* $name must be the name of an aggregate and the priority is passed. */
            $normalized['priority'] = $options;
            return $normalized;
        }

        if (is_string($options)) {
            /* Only an event name is provided in config */
            $normalized['attach'] = [ [ 'event' => $options, 'method' => null, 'priority' => 1 ] ];
            return $normalized;
        }

        if (ArrayUtils::isHashTable($options)) {
            $normalized['attach'] = $this->normalizeEventsSpec($options);

            if (isset($options['lazy'])) {
                $normalized['lazy'] = $options['lazy'];
            }

            return $normalized;
        }

        $event = $method = null;
        $priority = 1;
        $lazy = false;

        foreach ($options as $opt) {
            if (is_array($opt)) {
                /* Must be event names */
                $event = $opt;
            } elseif (is_string($opt)) {
                if (null === $event) {
                    /* first string found is assumed to be the event name */
                    $event = [ $opt ];
                } else {
                    /* second string found must be a method name. */
                    $method = $opt;
                }
            } elseif (is_int($opt)) {
                /* Integer values must be priority */
                $priority = $opt;
            } elseif (is_bool($opt)) {
                /* Lazy option is passed. */
                $lazy = $opt;
            }
        }

        foreach ($event as &$eventSpec) {
            $eventSpec = [ 'event' => $eventSpec, 'method' => $method, 'priority' => $priority ];
        }

        $normalized['attach'] = $event;
        $normalized['lazy']   = $lazy;

        return $normalized;
    }