orderingService = new DependencyOrderingService(); } public function process(ContainerBuilder $container): void { if (!$container->hasDefinition(DefaultSystemResourcePublisher::class)) { // If there's no default system resource publisher registered to begin with, don't bother registering file system publishers with it. return; } $publishers = []; $unorderedPublishers = $this->collectPublishers($container); foreach ($this->orderingService->orderByDependencies($unorderedPublishers) as $publisher) { $publishers[] = $container->findDefinition($publisher['service']); } $publisherDefinition = $container->findDefinition(DefaultSystemResourcePublisher::class); $publisherDefinition->addArgument($publishers); } /** * Collects all listeners from the container. */ private function collectPublishers(ContainerBuilder $container): array { $unorderedPublishers = []; foreach ($container->findTaggedServiceIds($this->tagName) as $serviceName => $tags) { foreach ($tags as $attributes) { $publisherIdentifier = $attributes['identifier'] ?? $serviceName; $unorderedPublishers[$publisherIdentifier] = [ 'service' => $serviceName, 'before' => GeneralUtility::trimExplode(',', $attributes['before'] ?? '', true), 'after' => GeneralUtility::trimExplode(',', $attributes['after'] ?? '', true), ]; } } return $unorderedPublishers; } }