Le 07/04/2011 12:17, Michel a écrit :
Hello,
I'm trying to migrate an application to sf2 and I don't know how to
solve the following problem:
When showing an item (route like /item/show/{id}), I want to be able
to directly go to previous and next items (according to sort order).
In symfony1, I had 2 methods in the Item class that returned the
corresponding id. So I was able to retrieve the ID directly in my
template.
With symfony2, this is no longer possible because the Item entity has
no link to the manager. I have migrated the methods into a dedicated
Item EntityRepository but I still need to connect the repository and
the entity. I can think of several solutions but I'd like to have
comments from others :-)
First idea is to retrieve the previous and next ids in the controller
action and hand them to the Twig template. This is simple but I'd like
something more encapsulated because this is more View than Controller
related…
Querying the DB for the ids is not related to the view but to the controller
Of course, at the opposite, I could provide the Entity Manager or
Repository to my template but this seems to be the worst solution. And
in between, I can provide the Manager to the freshly retrieved Item
instance. But this also sounds like a hack.
So all your comments are welcome.
Thanks
Michel
--
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