Reputation: 16445
I have a class that doesn't have access to the service container (because it does not extends the Controler class).
How can I get access to the parameters from parameters.ini in that class?
Upvotes: 0
Views: 1692
Reputation: 25305
There are two ways I can think of:
Define your class as a service and inject the parameters into it. This is the cleanest solution.
Ex:
// parameters.ini
my_param: fooBar
// services.yml
tests.example:
class: some\class
arguments: [%my_param%]
fooBar
will now be passed to your class constructor.
Define your class as a service and inject the container
service into it. This is not recommended and I'm only listing it because it's technically possible.
Upvotes: 3