Skip to content

Commit

Permalink
[AENV-305] - Add standard switches to article object api response
Browse files Browse the repository at this point in the history
  • Loading branch information
takeit committed Nov 19, 2014
1 parent 2a70289 commit 4951260
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion newscoop/library/Newscoop/Entity/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,8 @@ public function getView()
'publication_number' => $this->publication ? $this->publication->getId() : null,
'issue_number' => $this->issue ? $this->issue->getNumber() : null,
'section_number' => $this->section ? $this->section->getNumber() : null,
'keywords' => array_filter(explode(',', $this->keywords)),
'onFrontPage' => $this->onFrontPage,
'onSection' => $this->onSection,
));
} catch (EntityNotFoundException $e) {
return new ArticleView();
Expand Down
10 changes: 10 additions & 0 deletions newscoop/library/Newscoop/View/ArticleView.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,14 @@ class ArticleView extends View
* @var DateTime
*/
public $indexed;

/**
* @var string
*/
public $onFrontPage;

/**
* @var string
*/
public $onSection;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ class FieldsHandler

public function serializeToJson(JsonSerializationVisitor $visitor, $data, $type)
{
$GLOBALS['g_campsiteDir'] = realpath(__DIR__ . '/../../../../../');

$articleData = new \ArticleData($data->type, $data->number, $data->languageId);
if (count($articleData->getUserDefinedColumns()) == 0) {
return null;
Expand All @@ -30,6 +28,9 @@ public function serializeToJson(JsonSerializationVisitor $visitor, $data, $type)
$fields[$column->getPrintName()] = $articleData->getFieldValue($column->getPrintName());
}

$fields['show_on_front_page'] = $data->onFrontPage;
$fields['show_on_section_page'] = $data->onSection;

return $fields;
}
}

0 comments on commit 4951260

Please sign in to comment.