#630: Fix web routing to allow passing of objects as gen() parametersb
----------------------+-----------------------------------------------------
 Reporter:  MikeSeth  |       Owner:  dominik                                   
     Type:  defect    |      Status:  new                                       
 Priority:  normal    |   Milestone:  0.11.1                                    
Component:  routing   |     Version:  0.11.0                                    
 Severity:  trivial   |    Keywords:  bugfix routing callback gen url generation
----------------------+-----------------------------------------------------
 This small patch eliminates the indiscriminate rawurlencode() call when
 processing routing parameters. Before this patch, AgaviWebRouting::gen()
 would attempt to coerce an object into a string implicitly. After this
 patch, objects are passed to AgaviRouting::gen() as is, allowing the
 callback to receive them.

 This patch enables callbacks to reduce objects passed as parameters into
 their URL representation. This means it is now possible to truly map
 object instances to URLs in both directions. For instance:

 {{{
 <route name="page" pattern="^/(page_name:.+)" module="Public"
 callback="WikiPageCallback" cut="true" stop="false">
  <!--  If the request URL is just the page itself, show the page. -->
  <route pattern="^$" action="Page"/>
  <!--  If the request URL has /edit appended, edit the page instead -->
  <route name=".edit" pattern="/edit$" action="EditPage" constraint="read"
 />
 </route>

 public function onGenerate(array $defaultParameters, array
 &$userParameters, array &$userOptions)
 {
         $userParameters['page_name'] = $userParameters['page']->title;
         unset($userParameters['page']);

         return true;
 }
 }}}

-- 
Ticket URL: <http://trac.agavi.org/ticket/630>
Agavi <http://www.agavi.org/>
An MVC Framework for PHP5


_______________________________________________
Agavi Tickets Mailing List
[email protected]
http://lists.agavi.org/mailman/listinfo/tickets

Reply via email to