symfony - Injecting other service's parameters in my own service -
I would like to know if it is possible to inject service criteria in my service and if so, how?
I should put you in context I am using I know that by doing this it is possible to get those parameters through the But I would like to know if it is possible to take those parameters directly into my service definition, I have a service named Of course, this syntax does not work because the symphony is I am looking for a solution that should avoid injecting the container directly into my service, either by direct definition of my Regards, Matte In fact, it's really easy And I feel that I did not think about it before posting my question that I feel ashamed. I knew how to use the parameters in the In my service the So Simple :) Hope this will help anyone else. Regards, FOSFacebookBundle which loads some configuration from the
config.yml file. Those configuration settings (such as my Facebook
app_id ,
secret ,
cookies , etc.) are kept
FOSFacebookBundle this code With the following:
// FOS \ FacebookBundle \ DependencyInjection \ FOSFacebookExtension.php foreach (array ('file', 'APIID', 'secret', 'cookie', 'domain' , 'Culture', 'permissions')) $ $ containerbuilder- & gt; Setpalmator ('fb_bookbook $ $ $ attribute, $ config [$ attribute]); }
$ container :
$ Container-> GetParameter ('fos_facebook.app_id');
FacebookHelper for which this information will be required. So I would like to do something like this:
acme.helper.facebook: class: Application \ AcmeBundle \ Helper \ FacebookHelper argument: entityManager: "@ doctrine.orm.entity_manager" facebook: "@ Fos_facebook. Api "facebook attributes: -" @ fos_facebook.app_id "-" @ fos_facebook.secret "-" @ fos_facebook.cookie "
Fos_facebook.app_id The name is looking for service that does not exist.
services.yml file or your bundle Get the
FOSFacebookBundle parameter from the KD extension, which will do some work to define my custom service, and inject them into it.
config.yml file (for example,% using locale%) but I would like to use this syntax to inject the parameter into my service definition Not thought in
FOSFacebookBundle parameters are injected:
acme.helper.facebook: class: Application \ AcmeBundle \ Helper \ FacebookHelper logic : EntityManager: "@ doctrine.orm.entity_manager" facebook: "@ fos_facebook.api" FacebookAttup: APID: "% fos_facebook.app_id%" secret: "% fos_facebook.secret%" permissions: "% fos_facebook.permissions%"
Matt
Comments
Post a Comment