When you want use a service in your compilerpass and get "too few arguments" error, it means that needed service is not in container yet at custompass execution moment. In another words, custom pass executed earlier than service was added to container. To solve this situation, add this to Kernel.php/AppKernel.php:
protected function build(ContainerBuilder $container): void
{
$container->addCompilerPass(new CustomPass(), PassConfig::TYPE_AFTER_REMOVING);
}
Contstant TYPE_AFTER_REMOVING means that compilerpass with be added after not used services removing time.
protected function build(ContainerBuilder $container): void
{
$container->addCompilerPass(new CustomPass(), PassConfig::TYPE_AFTER_REMOVING);
}
Contstant TYPE_AFTER_REMOVING means that compilerpass with be added after not used services removing time.