private function registerTaggedServices(
        ContainerBuilder $container,
        string $definitionId,
        string $tagName,
        $argumentIndex = 0
    ): bool {
        if (!$container->has($definitionId)) {
            return false;
        }

        $definition       = $container->findDefinition($definitionId);
        $taggedServiceIds = $container->findTaggedServiceIds($tagName);
        $services         = (array) $definition->getArgument($argumentIndex);

        foreach (array_keys($taggedServiceIds) as $serviceId) {
            $services[] = new Reference($serviceId);
        }

        $definition->replaceArgument(0, $services);

        return true;
    }