Hi there- What exactly are you trying to accomplish? I think Stof is right that this is probably better accomplished not in the way you're doing it (though it's of course possible to inject the entity manager into a Twig extension via the service container).
Thanks! Ryan Weaver US Office Head & Trainer - KnpLabs - Nashville, TN http://www.knplabs.com <http://www.knplabs.com/en> http://www.thatsquality.com Twitter: @weaverryan On Wed, May 11, 2011 at 11:31 AM, Christophe COEVOET <s...@notk.org> wrote: > Le 09/05/2011 11:11, hd_deman a écrit : > > Hi, >> Im trying to get entity manager inside entity or twig extension. >> i want something like this in twig extension >> >> <?php >> //Twig/CoreExtension.php >> foreach($item->getChildren() as $i){ >> print $i->getTitle(); >> } >> ?> >> >> <?php >> //Entity/Section.php >> public function getChildren() >> { >> $EntityManager->children($this); >> } >> ?> >> > getting the entity manager in the entity goes against the data-mapper > pattern implemented by doctrine2. You should read > http://symfony.com/doc/2.0/book/doctrine/model.html which explains it. > > or like this >> >> //Twig/CoreExtension.php >> <?php >> foreach($EntityManager->children($item) as $i){ >> print $i->getTitle(); >> } >> ?> >> >> but i cant get EntityManager. >> > this is even worse. The entity manager has nothing to do in the view logic. > > -- > 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 developers" group. > To post to this group, send email to symfony-devs@googlegroups.com > To unsubscribe from this group, send email to > symfony-devs+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/symfony-devs?hl=en > -- 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 developers" group. To post to this group, send email to symfony-devs@googlegroups.com To unsubscribe from this group, send email to symfony-devs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-devs?hl=en