From 26ddd2b1f11f925cb943558b5a190eaadaf4f737 Mon Sep 17 00:00:00 2001 From: Axel Rutz Date: Fri, 3 Mar 2017 01:48:58 +0100 Subject: [PATCH] Issue #2857490: Filter by bundle --- restws.entity.inc | 7 ++++++- restws.formats.inc | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/restws.entity.inc b/restws.entity.inc index 1d49cc8..b87506b 100644 --- a/restws.entity.inc +++ b/restws.entity.inc @@ -365,9 +365,14 @@ class RestWSEntityResourceController implements RestWSQueryResourceControllerInt } } + // The bundle key is a special case. + if ($property === 'bundle') { + $operation = 'entity' . $operation; + $query->$operation($property, $value); + } // If field is not set, then the filter is a property and we can extract // the schema field from the property array. - if (empty($properties[$property]['field'])) { + elseif (empty($properties[$property]['field'])) { $column = $properties[$property]['schema field']; $operation = 'property' . $operation; $query->$operation($column, $value); diff --git a/restws.formats.inc b/restws.formats.inc index a5243af..7a401b6 100644 --- a/restws.formats.inc +++ b/restws.formats.inc @@ -372,7 +372,7 @@ abstract class RestWSBaseFormat implements RestWSFormatInterface { // If the parameter doesn't exist, we can not filter for and need to // notify the client about it. - if (!isset($properties[$parameter])) { + if (!isset($properties[$parameter]) && $parameter !== 'bundle') { throw new RestWSException('Not a valid filter: ' . $parameter, 412); } $filters[$parameter] = $value; -- 2.7.4