I recognize the purpose, but thought the actual behavior was: "$container->set('foo', 'bar');" will store just fine
With methods like "setDefinition", "setAlias", etc., it was assumed that treating it as a ParameterBag via "set" would behave as expected. Ideally, rather than failing silently, ContainerBuilder would throw an Exception when something besides Definition/Reference/Variable is passed in. If I have an ArrayCollection instantiated in services.xml <parameter key="my.great.collection.class">Doctrine\\Common\ \Collections\ArrayCollection</parameter> ... <service id="my.great.collection" class="%my.great.collection.class %" /> How can I get that service ID from the container by reference so I can append "addMethodCall"s to it? Thanks for the insight, Christophe! On Apr 7, 11:09 am, Christophe COEVOET <s...@notk.org> wrote: > Le 07/04/2011 17:54, ericclemmons a crit : > > > > > > > > > I have a very simple bundle where I parse a config to store objects in > > the DIC... > > > class MyGreatExtension extends Extension > > { > > > public function load(Array $config, ContainerBuilder $container) > > { > > ... > > $container->set('my.great.collection', new ArrayCollection); > > // var_dump($container->get('my.great.collection')); // It > > works here! > > } > > > ... > > > class DefaultController extends Controller > > { > > public function indexAction() > > { > > $this->container->get('my.great.collection'); // wth!? > > > Throws an Exception: "The service "my.great.collection" does not > > exist." > > > Is there *any* reason that setting a service in the Extension would > > somehow not be available in the container for the Controller? > > The second argument of $container->set() has to be an instance of > Symfony\Component\DependencyInjection\Definition. The DIC is not a cache > storage. It is about defining some services so you need to store the > definition, not the instance. > > -- > Christophe | Stof -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en