Skip to content

Commit

Permalink
Add source for id validator at handleGetById
Browse files Browse the repository at this point in the history
  • Loading branch information
nohponex committed Sep 27, 2016
1 parent 369eddc commit 1848e53
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Controller/GetById.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
namespace Phramework\JSONAPI\Controller;

use Phramework\Exceptions\Source\Parameter;
use Phramework\JSONAPI\Directive\AdditionalParameters;
use Phramework\JSONAPI\Directive\AdditionalRelationshipParameters;
use Phramework\JSONAPI\Directive\IncludeResources;
Expand Down Expand Up @@ -50,7 +51,11 @@ public static function handleGetById(
string $id
) : ResponseInterface {
//Validate id using model's validator
$id = $model->getIdAttributeValidator()->parse($id);
$id = $model->getIdAttributeValidator()
->setSource(
new Parameter('filter[' . $model->getResourceType() . ']')
)
->parse($id);

//Parse request related directives from request
$directives = Controller::parseDirectives(
Expand Down

0 comments on commit 1848e53

Please sign in to comment.