I have a service in Symfony2 that looks like:
services:
MyCustomService:
class: MyClass
arguments: //Arguments aren't static, but dynamic based on application logic.
Is it possible to pass dynamic variables to a service's constructor?
There doesn't seem to be any extra parameters within a controller's $this->get('MyCustomService');
Is there something I'm missing?
To me, it sounds like, you do not understand what a word "service" really means. What you are trying to achieve, would not be a service anymore.
You can still define a setter method inside your "MyClass" for any custom arguments, while defining some default ones, which you basically override when you use setter method.
You would use something like this:
$this->get('MyCustomService')->setSomething($something);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With