0

In other words, I have different bundles for each of my fb apps and want to load app_id and app secret depending on the bundle being used.

I am also using FOSFacebook Bundle

My config.yml:

parameters:
    # facebook
    my_app_id: test
    my_app_secret: test
fos_facebook:
    file:   %kernel.root_dir%/../vendor/facebook/src/base_facebook.php
    alias:  facebook
    app_id: %my_app_id%
    secret: %my_app_secret%
    cookie: true

Trying to do:

$this->container->setParameter("my_app_id", "99999999999");

gives me the "Impossible to call set() on a frozen ParameterBag." error.

And this: http://groups.google.com/group/symfony2/browse_thread/thread/6f09df702f656874 says that I have to explicitly getParameter first for it to work or use yet another bundle.

So question is, what is the relatively simple and less time consuming way to do this?

j0k
  • 22,600
  • 28
  • 79
  • 90
Rishi
  • 667
  • 1
  • 6
  • 13
  • Where do you make this call: `$this->container->setParameter("my_app_id", "99999999999");`? In a controller or from your dependency injection extension? – Matt Apr 20 '12 at 12:27
  • Inside my first facebook app bundle's controller – Rishi Apr 21 '12 at 11:19

1 Answers1

1

I think parameters are frozen once the dependency injection container has been built. This means you cannot change parameters in a controller directly.

What you could possibly do is to create a bundle extension that will set the parameter. In the bundle extension, parameters can be set an changed. Check this cookbook section to learn how to create bundle extension.

Also, you may take a look at this cookbook recipe that shows how to set parameters from external source.

Good luck with your use case.

Regards,
Matt

Matt
  • 10,633
  • 3
  • 46
  • 49