|
@@ -44,6 +44,7 @@ abstract class RESTController extends VoryxController
|
|
|
* @QueryParam(name="order_by", nullable=true, array=true, description="Order by fields. Must be an array ie. &order_by[name]=ASC&order_by[description]=DESC")
|
|
|
* @QueryParam(name="filters", nullable=true, array=true, description="Filter by fields. Must be an array ie. &filters[id]=3")
|
|
|
* &filters[qb-criteria] => Utilizará el matching con criteria donde los parámetros filters realizarán "field like %value%".
|
|
|
+ * &filters[qb-ids] => Require qb-criteria. This option filter by ids separated by ','. ie. &filters[qb-ids]=1,2,8,9.
|
|
|
*/
|
|
|
public function cgetAction(ParamFetcherInterface $paramFetcher)
|
|
|
{
|
|
@@ -75,11 +76,15 @@ abstract class RESTController extends VoryxController
|
|
|
unset($filters['qb-criteria']);
|
|
|
$criteria = new \Doctrine\Common\Collections\Criteria();
|
|
|
|
|
|
- foreach ($filters as $field => $value) {
|
|
|
- if ($orWhere) {
|
|
|
- $criteria->orWhere($criteria->expr()->contains("$field", "$value"));
|
|
|
- } else {
|
|
|
- $criteria->andWhere($criteria->expr()->contains("$field", "$value"));
|
|
|
+ if(isset($filters['qb-ids'])) {
|
|
|
+ $criteria->where($criteria->expr()->in('id', explode(",",$filters["qb-ids"])));
|
|
|
+ } else {
|
|
|
+ foreach ($filters as $field => $value) {
|
|
|
+ if ($orWhere) {
|
|
|
+ $criteria->orWhere($criteria->expr()->contains("$field", "$value"));
|
|
|
+ } else {
|
|
|
+ $criteria->andWhere($criteria->expr()->contains("$field", "$value"));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|