sfDoctrineRestGeneratorPlugin
sfDoctrineRestGeneratorPlugin copied to clipboard
Sorting by more than one field is not possible from generator.yml
If you want to sort on different fields (e.g. begintime ASC, endtime ASC) this is not possible. One way to do this is by overriding the query method:
public function query($params)
{
if (!array_key_exists('sort_by', $params)) {
$q = parent::query($params);
return $q->orderBy('endtime ASC');
}
return parent::query($params);
}
with [begintime, asc] in the sort_default field in generator.yml
.
A method that would be better is to allow multiple fields to sort by (by default):
sort_default:
- { field: begintime, order: asc }
- { field: endtime, order: asc }
However, this would break backwards compatibility. I would be glad to implement this.
@nederdirk, just go ahead, this feature seems to be useful and is a good idea. Thanks by the way for your work :-)