Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 630213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:49:52+00:00 2026-05-13T19:49:52+00:00

I have several models with translations. When I load $this->tour = $this->getRoute()->getObject(); por example,

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T19:49:52+00:00Added an answer on May 13, 2026 at 7:49 pm

    You need to specify in your route definition what method to use when retrieving the object through the methodoption:

    my_route
      url: /tour/:id
      options:
        model: Tour
        type: object
        method: getTourForRoute
    

    (params section skipped for brevity sake)

    Be aware that the method will not receive the id directly as a parameter but an array of parameters passed to the route, thus you would write a method like that:

    public function getTourForRoute($parameters)
    {
      return self::getTour($parameters['id']);
    }
    

    Final note: this option is only available if you use either a sfDoctrineRoute or a sfPropelRoute 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several models grouped in a module like this: #/app/models/blobs/small_text.rb class Blobs::SmallText <
I have several models: ContactEmail, ContactLetter, ContactCall My controller doesn't know what is being
I have several models that belong_to :status . Statuses are: Active Hidden Banned I
In my project, I have several models that use a number of scopes that
I have several doctrine models that have relationships to other models. Let's call those
If you have several view models on one page, how do you ensure that
I have several 'lookup' fields in my models where I don't want nulls, but
I have several small classes that are in a single file in /app/models, similar
I have several models: Email Letter Call All three belong to a model Campaign.
So, maybe a bit of a silly question, but say I have several models

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.