Giancarlo Ventura
Giancarlo Ventura

Reputation: 857

Use paramater value in a custom class (Symfony2)

I have some parameter values in app/config/parameters.yml

parameters:
    database_host: 127.0.0.1
    database_port: null
    database_name: database_name
    ...
    igv: 0.18
    isc: 0.18

Now, I want to use the parameters in a Custom class in AppBundle/CustomClass.php. How can I use this parameters? I try $this->container->get('igv') but not works.

Upvotes: 0

Views: 39

Answers (1)

geoB
geoB

Reputation: 4716

In services.yml:

my_app.customclass:
    class:  AppBundle\CustomClass
    arguments: ['%igv%', '%isc%']

Add the arguments to the constructor of AppBundle\CustomClass.

Upvotes: 4

Related Questions