Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Added item-fields back for single content types. #97

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Action/SingleAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function handle($contentType, $slug, $relatedContentType, Request $reques
} else {
//$allFields = $this->APIHelper->getAllFieldNames($contentType);
//$fields = $this->APIHelper->getFields($contentType, $allFields, 'item-fields');
$fields = $parameters->get('fields')->getFields();
$fields = $parameters->get('fields')->getFields(null, 'getItemFields');
$values = $this->parser->parseItem($results, $fields);
//@todo get previous and next link
$prev = $results->previous();
Expand Down
15 changes: 11 additions & 4 deletions src/Converter/Parameter/Type/Fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function convertRequest()
return $this;
}

protected function getFieldsForContentType($contentType)
protected function getFieldsForContentType($contentType, $fallbackFields = 'getListFields')
{
if ($this->config->getAllowedFields($contentType)) {
$allowedFields = $this->config->getAllowedFields($contentType);
Expand All @@ -53,8 +53,8 @@ protected function getFieldsForContentType($contentType)
// Default on the default/fallback fields defined in the config.
if (empty($this->fields[$contentType])) {
$this->fields[$contentType] = $allowedFields;
if ($this->config->getListFields($contentType)) {
$this->fields[$contentType] = $this->config->getListFields($contentType);
if ($this->config->$fallbackFields($contentType)) {
$this->fields[$contentType] = $this->config->$fallbackFields($contentType);
// todo: do we need to filter these through 'allowed-fields'?
}
}
Expand All @@ -76,8 +76,15 @@ public function getParameter()
/**
* @return array
*/
public function getFields($contentType = null)
public function getFields($contentType = null, $itemFields = null)
{
if ($itemFields) {
$contentType = ($contentType !== null ?: $this->contentType);
$this->getFieldsForContentType($contentType, 'getItemFields');

return $this->fields[$contentType];
}

if (! $contentType) {
return $this->fields[$this->contentType];
}
Expand Down