Decrease number of queries for admin generated module: the better way

Posted: [Source]
Tags:  admin generator php query symfony

Recently I saw two posts in the symfony blogosphere about decreasing number of queries in admin generated module (in January on Techie Corner, and today on Symfony world - which prompted me to write this post). And both bloggers seemed to be happy with overwriting buildQuery method of the module's action class. But generator.yml provides more elegant solution for admin generated modules.

When I first saw that solution on techiecorner, I thought: "hmmm.. that could be useful", but then, I looked at my generator.yml file and saw table_method i placed there long time ago...

generator:
  param:
    config:
      list:
        table_method: getAdminNotes

And while both, overwriting buildQuery and setting table_method can achieve same goal, I think table_method is more elegant, as it keeps your query in your ModelTable, and can be reused in other part of your project as well.

See The symfony Reference Book.

Comments powered by Disqus