6

For example, in my services.yml file next code:

parameters:
    social:
        facebook:
            app_id: 123456789
            secret: dkl41a5dw1daw11d1wa135451awwlflaw
        google:
            id: 12548411654

services:
    bw.user.social:
        class: BW\UserBundle\Service\SocialService
        arguments: [%social.facebook%]

This method does not work. I can use this:

services:
    bw.user.social:
        class: BW\UserBundle\Service\SocialService
        arguments: [%social%]

But it's not exactly what I need. How can I pass only facebook value without google and , it's very important, not change parameters structure?

0

1 Answer 1

2

You have to write your parameters like this :

parameters:
    social.facebook:
        app_id: 123456789
        secret: dkl41a5dw1daw11d1wa135451awwlflaw
    social.google:
        id: 12548411654

Then you can use :

services:
    bw.user.social:
        class: BW\UserBundle\Service\SocialService
        arguments: [%social.facebook%]
Sign up to request clarification or add additional context in comments.

2 Comments

Yes, it's work, but the parameters structure is changed. And without changing the structure can not be done?
You cannot use a "tree-browsing syntax" to get some sub-parameters. All parameters have to be on the first level because each parameter is supposed to be a injected dependance. Using sub-level parameters injection would be like inject "half-dependencies", so it's impossible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.