src/DependencyInjection/Compiler/CollectAsynchronousEventNames.php
public function process(ContainerBuilder $container)
    {
        $serviceId = 'simple_bus.asynchronous.publishes_predefined_messages_middleware';
        if (!$container->hasDefinition($serviceId)) {
            return;
        }

        $names = array();
        $this->collectServiceIds(
            $container,
            'asynchronous_event_subscriber',
            'subscribes_to',
            function ($key) use (&$names) {
                $names[] = $key;
            }
        );

        $container->getDefinition($serviceId)->replaceArgument(2, array_unique($names));
    }
public function process(ContainerBuilder $container)
    {
        $serviceId = 'simple_bus.asynchronous.publishes_predefined_messages_middleware';
        if (!$container->hasDefinition($serviceId)) {
            return;
        }

        $names = array();
        $this->collectServiceIds(
            $container,
            'asynchronous_event_subscriber',
            'subscribes_to',
            function ($key) use (&$names) {
                $names[] = $key;
            }
        );

        $container->getDefinition($serviceId)->replaceArgument(2, array_unique($names));
    }
Get all asynchronous event subscribers and save the name of the event they are listening to.

@param ContainerBuilder $container