Skip to content

Commit

Permalink
Put resource key value for serializer into class constant
Browse files Browse the repository at this point in the history
  • Loading branch information
maximebeaudoin committed Jul 5, 2017
1 parent afb904f commit 79f7a8b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "0.14-dev"
"dev-master": "0.15-dev"
}
}
}
6 changes: 4 additions & 2 deletions src/Serializer/Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
*/
class Serializer extends ArraySerializer
{
const RESOURCE_KEY = 'data';

/**
* Serialize a collection.
*
Expand All @@ -21,7 +23,7 @@ class Serializer extends ArraySerializer
*/
public function collection($resourceKey, array $data)
{
return [$resourceKey ? $resourceKey: 'data' => $data];
return [$resourceKey ? $resourceKey: static::RESOURCE_KEY => $data];
}

/**
Expand All @@ -34,6 +36,6 @@ public function collection($resourceKey, array $data)
*/
public function item($resourceKey, array $data)
{
return [$resourceKey ? $resourceKey: 'data' => $data];
return [$resourceKey ? $resourceKey: static::RESOURCE_KEY => $data];
}
}

0 comments on commit 79f7a8b

Please sign in to comment.