Skip to content
This repository has been archived by the owner on Oct 11, 2018. It is now read-only.

Commit

Permalink
move count and pages to fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominik Zogg committed Sep 27, 2017
1 parent 1c2199f commit e0c7a92
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
10 changes: 8 additions & 2 deletions app/Serialization/CourseSearchMapping.php
Expand Up @@ -65,6 +65,8 @@ public function getFieldMappings(): array
),
new FieldMapping('sort'),
new FieldMapping('order'),
new FieldMapping('count'),
new FieldMapping('pages'),
];
}

Expand All @@ -74,8 +76,6 @@ public function getFieldMappings(): array
public function getEmbeddedFieldMappings(): array
{
return [
new FieldMapping('count'),
new FieldMapping('pages'),
new FieldMapping('courses', new CollectionFieldSerializer(new PropertyAccessor('courses'))),
];
}
Expand All @@ -88,6 +88,8 @@ public function getLinkMappings(): array
return [
new LinkMapping('self', new CallbackLinkSerializer(
function (Request $request, CourseSearch $courseSearch, array $fields) {
unset($fields['count'], $fields['pages']);

return $this->linkGenerator->generateLink($request, 'course_search', [], $fields);
}
)),
Expand All @@ -96,6 +98,8 @@ function (Request $request, CourseSearch $courseSearch, array $fields) {
if ($courseSearch->getPage() > 1) {
$fields['page'] -= 1;

unset($fields['count'], $fields['pages']);

return $this->linkGenerator->generateLink($request, 'course_search', [], $fields);
}

Expand All @@ -107,6 +111,8 @@ function (Request $request, CourseSearch $courseSearch, array $fields) {
if ($fields['page'] < $courseSearch->getPages()) {
$fields['page'] += 1;

unset($fields['count'], $fields['pages']);

return $this->linkGenerator->generateLink($request, 'course_search', [], $fields);
}

Expand Down
12 changes: 6 additions & 6 deletions public/swagger/models/course.yml
Expand Up @@ -282,17 +282,17 @@ definitions:
order:
type: string
example: asc
count:
type: integer
example: 1
pages:
type: integer
example: 1
_embedded:
type: object
xml:
name: meta-embedded
properties:
count:
type: integer
example: 1
pages:
type: integer
example: 1
courses:
type: array
xml:
Expand Down

0 comments on commit e0c7a92

Please sign in to comment.