src/Application/Messaging/Event/ServiceAwareEventDispatcher.php
public function registerService(string $className, string $serviceId): void
    {
        assert(
            Validate::implementsInterface($className, EventSubscriber::class),
            sprintf('Invalid subscriber class: %s', $className)
        );
        /** @var EventSubscriber $className The subscriber class name */
        foreach ($className::eventRegistration() as $eventType => $params) {
            $eventType = ClassName::underscore($eventType);
            if (is_string($params)) {
                $this->addHandlerService($eventType, $serviceId, $params);
            } elseif (is_string($params[0])) {
                $priority = isset($params[1]) ? (int) $params[1] : 0;
                $this->addHandlerService($eventType, $serviceId, $params[0], $priority);
            } else {
                foreach ($params as $handler) {
                    $priority = isset($handler[1]) ? (int) $handler[1] : 0;
                    $this->addHandlerService($eventType, $serviceId, $handler[0], $priority);
                }
            }
        }
    }
public function registerService(string $className, string $serviceId): void
    {
        assert(
            Validate::implementsInterface($className, EventSubscriber::class),
            sprintf('Invalid subscriber class: %s', $className)
        );
        /** @var EventSubscriber $className The subscriber class name */
        foreach ($className::eventRegistration() as $eventType => $params) {
            $eventType = ClassName::underscore($eventType);
            if (is_string($params)) {
                $this->addHandlerService($eventType, $serviceId, $params);
            } elseif (is_string($params[0])) {
                $priority = isset($params[1]) ? (int) $params[1] : 0;
                $this->addHandlerService($eventType, $serviceId, $params[0], $priority);
            } else {
                foreach ($params as $handler) {
                    $priority = isset($handler[1]) ? (int) $handler[1] : 0;
                    $this->addHandlerService($eventType, $serviceId, $handler[0], $priority);
                }
            }
        }
    }
public function registerService ( string $ className , string $ serviceId ) : void { assert ( Validate :: implementsInterface ( $ className , EventSubscriber :: class ) , sprintf ( 'Invalid subscriber class: %s' , $ className ) ) ; /** @var EventSubscriber $className The subscriber class name */ foreach ( $ className :: eventRegistration ( ) as $ eventType => $ params ) { $ eventType = ClassName :: underscore ( $ eventType ) ; if ( is_string ( $ params ) ) { $ this -> addHandlerService ( $ eventType , $ serviceId , $ params ) ; } elseif ( is_string ( $ params [ 0 ] ) ) { $ priority = isset ( $ params [ 1 ] ) ? ( int ) $ params [ 1 ] : 0 ; $ this -> addHandlerService ( $ eventType , $ serviceId , $ params [ 0 ] , $ priority ) ; } else { foreach ( $ params as $ handler ) { $ priority = isset ( $ handler [ 1 ] ) ? ( int ) $ handler [ 1 ] : 0 ; $ this -> addHandlerService ( $ eventType , $ serviceId , $ handler [ 0 ] , $ priority ) ; } } } }
Registers a subscriber service to handle events

The subscriber class must implement:
Novuso\Common\Domain\Messaging\Event\EventSubscriber

@param string $className The subscriber class name
@param string $serviceId The subscriber service ID

@return void
Registers a subscriber service to handle events