Use Symfony Service deep in the code, is it possible without forwarding params [duplicate]
You can register ProcessorZ as a service (or any processor for that matter) the same way you register RedisService as a service. And just like you've bound $host and $port parameter to RedisService, you can bind RedisService to ProcessorZ class.
https://symfony.com/doc/current/service_container.html#service-parameters
In your case
services:
App\Service\ProcessorZ:
arguments:
# this is not a string, but a reference to a service
- '@App\Service\RedisService'
In your ProcessorZ.php
...
class ProcessorZ {
private RedisService $redisService;
public function __construct(RedisService $redisService) {
$this->redisService = $redisService;
}
public function process()
{
$this->redisService->call();
}
}
By utilizing autowiring and autoconfiguring this process can be much simpler and faster so you might want to check that out here: https://symfony.com/doc/current/service_container/autowiring.html