I have a FooService that retrieves some data from another configuration service.
I have this configuration service since the configuration is different depending on the request data. The configuration service has a RequestStack that is injected and builds the appropriate configuration array.
My FooService as follows:
class Foo { private $config; public function __construct(Config $config) { $this->config = $config->getData(); } }
However, instead of introducing the service, I prefer to enter only the result of the method call from getData , since it is easier for unit testing. I will not need to scoff at the configuration, I can just pass the array.
In my current service.yml there is a type definition:
config: ... foo: class: Kopernikus\LeBundle\Service\Foo arguments: - @config
I tried changing my definition of foo as factory methods with:
foo: class: Kopernikus\LeBundle\Service\Foo arguments: - [@config, getData]
but it also introduces the whole service.
How to insert the result of a service method as an argument to another service?
source share