diff --git a/framework/rest/Serializer.php b/framework/rest/Serializer.php index edc689e94e8..eedd96c2cc6 100644 --- a/framework/rest/Serializer.php +++ b/framework/rest/Serializer.php @@ -188,6 +188,12 @@ protected function getRequestedFields() */ protected function serializeDataProvider($dataProvider) { + if (($pagination = $dataProvider->getPagination()) !== false) { + $this->addPaginationHeaders($pagination); + } + if ($this->request->getIsHead()) { + return null; + } if ($this->preserveKeys) { $models = $dataProvider->getModels(); } else { @@ -195,13 +201,7 @@ protected function serializeDataProvider($dataProvider) } $models = $this->serializeModels($models); - if (($pagination = $dataProvider->getPagination()) !== false) { - $this->addPaginationHeaders($pagination); - } - - if ($this->request->getIsHead()) { - return null; - } elseif ($this->collectionEnvelope === null) { + if ($this->collectionEnvelope === null) { return $models; }