Symfony2: how to read parameters array in config.yml

trrrrrrm

my parameters.yml file has:

parameters:
     title:
          subtitle: value

i want to pass the value to a service in config.yml

my_service:
        class: the_class
        arguments: [ %title.subtitle%] //didn't work
        arguments: [ %title['subtitle']%] //didn't work

how can i do this?

user725408

The % notation doesn't work but it can be accomplished the following way:

my_service:
    class: the_class
    arguments: ["@=container.getParameter('title')['subtitle']"]

It works at least for symfony 2.7.3

More info about the expression language can be found in the cookbook: http://symfony.com/doc/current/book/service_container.html#using-the-expression-language

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Difference between parameters.yml and config.yml in Symfony2

From Dev

How can i send parameters to validators.lang.yml in symfony2 validator engine?

From Dev

Symfony2 - Import config.yml in services.xml

From Dev

Symfony2 is not using the config_prod.yml

From Dev

Symfony2 - Import config.yml in services.xml

From Dev

cache path variable in config.yml for symfony2

From Dev

Symfony2 get parameters.yml in entity, special case

From Dev

PHPUnit symfony2 faking parameters.yml

From Dev

A parameters.yml per bundle, symfony2

From Dev

PHPUnit symfony2 faking parameters.yml

From Dev

Number index in parameters.yml corrupted Symfony2

From Dev

How to read parameters from parameters.yml in a service?

From Dev

Symfony2 validation.yml for value of Array field type

From Dev

How to Hide parameters in URL in Symfony2

From Dev

How to declare both method in routing.yml Symfony2?

From Dev

How to set validation.yml for form with passwords (Symfony2)

From Dev

Call an .yml file located in app/config from inside a controller Symfony2

From Dev

Call an .yml file located in app/config from inside a controller Symfony2

From Dev

Symfony config.yml - How to pass constructor arguments by name?

From Dev

How does a Symfony pass parameters into a yaml config?

From Dev

Symfony2 get to the access_control parameters located in the security.yml

From Dev

Possible to modify / write to a custom parameters.yml file in symfony2?

From Dev

Symfony2 - where are all the places where the 'secret' key (parameters.yml) is used?

From Dev

Oracle database error in symfony2 (doctrine). Is parameters.yml setup correctly?

From Dev

Symfony yml parameters into doctrine yml mapping

From Dev

Symfony yml parameters into doctrine yml mapping

From Dev

yml pluralization symfony2

From Dev

Symfony2 how to inject request and get route parameters in controller

From Dev

How to access entity functions with parameters in TWIG - symfony2

Related Related

  1. 1

    Difference between parameters.yml and config.yml in Symfony2

  2. 2

    How can i send parameters to validators.lang.yml in symfony2 validator engine?

  3. 3

    Symfony2 - Import config.yml in services.xml

  4. 4

    Symfony2 is not using the config_prod.yml

  5. 5

    Symfony2 - Import config.yml in services.xml

  6. 6

    cache path variable in config.yml for symfony2

  7. 7

    Symfony2 get parameters.yml in entity, special case

  8. 8

    PHPUnit symfony2 faking parameters.yml

  9. 9

    A parameters.yml per bundle, symfony2

  10. 10

    PHPUnit symfony2 faking parameters.yml

  11. 11

    Number index in parameters.yml corrupted Symfony2

  12. 12

    How to read parameters from parameters.yml in a service?

  13. 13

    Symfony2 validation.yml for value of Array field type

  14. 14

    How to Hide parameters in URL in Symfony2

  15. 15

    How to declare both method in routing.yml Symfony2?

  16. 16

    How to set validation.yml for form with passwords (Symfony2)

  17. 17

    Call an .yml file located in app/config from inside a controller Symfony2

  18. 18

    Call an .yml file located in app/config from inside a controller Symfony2

  19. 19

    Symfony config.yml - How to pass constructor arguments by name?

  20. 20

    How does a Symfony pass parameters into a yaml config?

  21. 21

    Symfony2 get to the access_control parameters located in the security.yml

  22. 22

    Possible to modify / write to a custom parameters.yml file in symfony2?

  23. 23

    Symfony2 - where are all the places where the 'secret' key (parameters.yml) is used?

  24. 24

    Oracle database error in symfony2 (doctrine). Is parameters.yml setup correctly?

  25. 25

    Symfony yml parameters into doctrine yml mapping

  26. 26

    Symfony yml parameters into doctrine yml mapping

  27. 27

    yml pluralization symfony2

  28. 28

    Symfony2 how to inject request and get route parameters in controller

  29. 29

    How to access entity functions with parameters in TWIG - symfony2

HotTag

Archive