我有以下推进收集路线:
api_offer:
class: sfPropelRouteCollection
options:
prefix_path: /api/offer
model: Offer
plural: offers
singluar: offer
actions: [ list ]
module: apiOffer
requirements:
sf_format: (?:html|json)
有谁知道如何将条件传递给操作中的
$this->getRoute()->getObjects()
方法?基本上,我需要根据路线中的现有参数从数据库中检索不同的对象。
sfPropelRouteCollection
有一个从 sfObjectRouteCollection
继承的选项,称为 model_methods
。这是它的使用方式:
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'])
)
}