[symfony-users] Re: Tweaking generated routes with the admin generator

2009-08-26 Thread Marc

I already gave a small answer on twitter but I repost here...

If I correctly understand the problem you have:
You can add custom parameters (ex: myParameter) to routes as long as  
there is a method in your model named (in this case) getMyParameter().

Please tell me if it does fix your problem :-)





Le 26 août 09 à 13:02, Nicolas Perriault a écrit :


 Hi all,

 I'm trying to figure how I could benefit from the great features
 provided by the admin generator (I'm using symfony 1.3 right now)
 while using specific urls ; let me explain a bit.

 I have two models: Project and Story. A project can have many stories,
 and a story has one project. I would like to generate a an
 admin-generated module to handle the stories related to a given
 project by using a sexy url like this one: /project/:project/backlog,
 where the :project parameter would be a slug or a pk, no matter.

 I tried to use the prefix_path setting of the route collection in the
 routing.yml file, by setting this:

 story:
  class: sfDoctrineRouteCollection
  options:
model:story
module:   story
prefix_path:  project/:project/backlog
column:   id
with_wildcard_routes: true
  requirements:
project: \d

 But when the route matches, an InvalidArgumentException is thrown when
 the admin generated templates try to generate the links to the other
 module actions, because it lacks the :project parameter:

 The /project/:project/backlog/:action/action.:sf_format route has
 some missing mandatory parameters (:project).

 I also tried to play with the route_prefix setting from the
 generator.yml file but with no luck so far.

 Usually I dive into code to find a path to solve this kind of
 problems, but today I'm unfortunately into such a hurry that I just
 can't loose time on this; so I'd be glad to got some help from the
 community if you've been ever exposed to an approaching situation or
 have an idea to solve it ;)

 Cheers,

 -- 
 Nicolas Perriault
 http://prendreuncafe.com - http://symfonians.net
 Mobile: +33 660 92 08 67

 


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[symfony-users] Re: Tweaking generated routes with the admin generator

2009-08-26 Thread Marc
I just checked in other projects and I figured that I override the  
generated route with a custom one...
It's a bit messy but it works.

I got it to work in frontend using normal modules. Hope it works  
with generated admin modules.

--
board:
   class:  sfDoctrineRouteCollection
   options:
 model:BoardThread
 module:   board
 object_actions: { reply: post }
 prefix_path:  /forum

board_show:
   url:/forum/:year/:month/:day/:slug.:sf_format
   class:  sfDoctrineRoute
   options:
 model:BoardThread
 module:   board
 type: object
 prefix_path:  /forum
   param:  { module: board, action: show, sf_format: html }
   requirements:
 year: \d+
 month:\d+
 day:  \d+
 sf_method:[GET]
 sf_format:(?:html|atom)



Le 26 août 09 à 13:02, Nicolas Perriault a écrit :


 Hi all,

 I'm trying to figure how I could benefit from the great features
 provided by the admin generator (I'm using symfony 1.3 right now)
 while using specific urls ; let me explain a bit.

 I have two models: Project and Story. A project can have many stories,
 and a story has one project. I would like to generate a an
 admin-generated module to handle the stories related to a given
 project by using a sexy url like this one: /project/:project/backlog,
 where the :project parameter would be a slug or a pk, no matter.

 I tried to use the prefix_path setting of the route collection in the
 routing.yml file, by setting this:

 story:
  class: sfDoctrineRouteCollection
  options:
model:story
module:   story
prefix_path:  project/:project/backlog
column:   id
with_wildcard_routes: true
  requirements:
project: \d

 But when the route matches, an InvalidArgumentException is thrown when
 the admin generated templates try to generate the links to the other
 module actions, because it lacks the :project parameter:

 The /project/:project/backlog/:action/action.:sf_format route has
 some missing mandatory parameters (:project).

 I also tried to play with the route_prefix setting from the
 generator.yml file but with no luck so far.

 Usually I dive into code to find a path to solve this kind of
 problems, but today I'm unfortunately into such a hurry that I just
 can't loose time on this; so I'd be glad to got some help from the
 community if you've been ever exposed to an approaching situation or
 have an idea to solve it ;)

 Cheers,

 -- 
 Nicolas Perriault
 http://prendreuncafe.com - http://symfonians.net
 Mobile: +33 660 92 08 67

 


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[symfony-users] Re: Tweaking generated routes with the admin generator

2009-08-26 Thread Thomas Rabaix
Just add a custom method into the model as Marc suggest ! (well I hope the
admin gen use sfDoctrineRoute behind the scene)

On Wed, Aug 26, 2009 at 3:10 PM, Marc mweistr...@uneviemoinschere.comwrote:

 I just checked in other projects and I figured that I override the
 generated route with a custom one...
 It's a bit messy but it works.

 I got it to work in frontend using normal modules. Hope it works with
 generated admin modules.

 --
 board:
   class:  sfDoctrineRouteCollection
   options:
 model:BoardThread
 module:   board
 object_actions: { reply: post }
 prefix_path:  /forum

 board_show:
   url:/forum/:year/:month/:day/:slug.:sf_format
   class:  sfDoctrineRoute
   options:
 model:BoardThread
 module:   board
 type: object
 prefix_path:  /forum
   param:  { module: board, action: show, sf_format: html }
   requirements:
 year: \d+
 month:\d+
 day:  \d+
 sf_method:[GET]
 sf_format:(?:html|atom)
 


 Le 26 août 09 à 13:02, Nicolas Perriault a écrit :


 Hi all,

 I'm trying to figure how I could benefit from the great features
 provided by the admin generator (I'm using symfony 1.3 right now)
 while using specific urls ; let me explain a bit.

 I have two models: Project and Story. A project can have many stories,
 and a story has one project. I would like to generate a an
 admin-generated module to handle the stories related to a given
 project by using a sexy url like this one: /project/:project/backlog,
 where the :project parameter would be a slug or a pk, no matter.

 I tried to use the prefix_path setting of the route collection in the
 routing.yml file, by setting this:

 story:
  class: sfDoctrineRouteCollection
  options:
model:story
module:   story
prefix_path:  project/:project/backlog
column:   id
with_wildcard_routes: true
  requirements:
project: \d

 But when the route matches, an InvalidArgumentException is thrown when
 the admin generated templates try to generate the links to the other
 module actions, because it lacks the :project parameter:

 The /project/:project/backlog/:action/action.:sf_format route has
 some missing mandatory parameters (:project).

 I also tried to play with the route_prefix setting from the
 generator.yml file but with no luck so far.

 Usually I dive into code to find a path to solve this kind of
 problems, but today I'm unfortunately into such a hurry that I just
 can't loose time on this; so I'd be glad to got some help from the
 community if you've been ever exposed to an approaching situation or
 have an idea to solve it ;)

 Cheers,

 --
 Nicolas Perriault
 http://prendreuncafe.com - http://symfonians.net
 Mobile: +33 660 92 08 67





 



-- 
Thomas Rabaix
http://rabaix.net

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---