开发者

Passing a propel criteria to the symfony routing function that retrieves the object

开发者 https://www.devze.com 2023-01-15 20:40 出处:网络
quick symfony / propel question. I have the following propel collection route: api_offer: class: sfPropelRouteCollection

quick symfony / propel question. I have the following propel collection route:

api_offer:
  class: sfPropelRouteCollection
  options:
    prefix_path: /api/offer
    model: Offer
    plural: offers
    singluar: offer
    actions: [ list ]
    module: apiOffer
  requirements:
    sf_format: (?:html|json)

My question is, does anyone know of a way to pass a Criteria to the $this->getRoute()->getObjects(); in the action? Basically I need开发者_如何学编程 to retrieve different objects from the database depending on existing parameters in the route.

Thanks for all you help.


sfPropelRouteCollection has an inherited option from sfObjectRouteCollection called model_methods. This is how it gets used:

protected function getRouteForList()
{
  return new $this->routeClass(
    sprintf('%s.:sf_format', $this->options['prefix_path']),
    array_merge(array('module' => $this->options['module'], 'action' => $this->getActionMethod('list'), 'sf_format' => 'html'), $this->options['default_params']),
    array_merge($this->options['requirements'], array('sf_method' => 'get')),
    array('model' => $this->options['model'], 'type' => 'list', 'method' => $this->options['model_methods']['list'])
  )
}
0

精彩评论

暂无评论...
验证码 换一张
取 消