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