Skip to content

Commit

Permalink
Fixing a really nasty bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier Lorenzana committed Nov 22, 2014
1 parent 085e42a commit 36dd899
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions JsonApi/Request/FilterParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
*/
class FilterParser
{
/**
* @var array
*/
private static $reserved = ['include', 'fields', 'sort', 'page', 'size'];
/**
* @var MetadataMinerInterface
*/
Expand Down Expand Up @@ -58,16 +62,16 @@ public function parse(Request $request, Params $params)
$metadata = $this->metadataMiner->mine($params->primaryClass);
$add = function($param, $value, $type) use (&$filters) {
$property = Inflector::camelize($param);
$values = explode(',', $value);
$filters[$type][$property] = $values;
if (is_string($value)) $value = explode(',', $value);
$filters[$type][$property] = $value;
};

foreach ($request->query as $param => $value) {
if ($metadata->isField($param)) {
$add($param, $value, 'field');
} elseif ($metadata->isRelationship($param)) {
$add($param, $value, 'association'); // Doctrine 2 term.
} else {
} elseif (!in_array($param, self::$reserved)) {
$add($param, $value, 'custom');
}
}
Expand Down

0 comments on commit 36dd899

Please sign in to comment.