I have several models with translations. When I load
$this->tour = $this->getRoute()->getObject();
por example, it gets me the Tour Object. However, it doesn’t join to the tour_translation table; so when after i try to get it’s title; symfony makes another sql query.
How I can override something, so in the Tour model when I ask for the object, it returns me the object with its translation in the current culture.
I’ve been looking at the sfObjectRoute class to see if I can override any method, but I’m not sure right now
I know I can do the following, but I prefer the first option as it’s more transparent and elegant:
$this->tour = Tour::getTour($request->getParameter('id'), $lang);
thanks!
You need to specify in your route definition what method to use when retrieving the object through the
methodoption:(
paramssection skipped for brevity sake)Be aware that the method will not receive the
iddirectly as a parameter but an array of parameters passed to the route, thus you would write a method like that:Final note: this option is only available if you use either a
sfDoctrineRouteor asfPropelRoute🙂