NewsItem kan direct gedeserialiseerd worden vanuit API JSON
This commit is contained in:
@@ -19,9 +19,8 @@ class NewsImage extends Model {
|
||||
public $url;
|
||||
public $title;
|
||||
|
||||
public function __construct($data, $urlPrefix = '/') {
|
||||
parent::__construct($data);
|
||||
if($this->url) { $this->url = $urlPrefix . $this->url; }
|
||||
public function getUrl() {
|
||||
return '/img/news/' . $this->url;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,8 +51,8 @@ class NewsItem extends Model {
|
||||
$this->source = $data->source ? new \Model\NewsSource($data->source, $data->source_url, $data->showsource) : null;
|
||||
$this->keywords = trim($data->keywords) ? explode(' ', $data->keywords) : null;
|
||||
$this->podcast = $data->podcast ? $data->podcast : null;
|
||||
|
||||
if($images) {
|
||||
|
||||
if($images = $images ?? $data->images) {
|
||||
$this->images = [];
|
||||
foreach($images as $image) {
|
||||
$this->images[] = new NewsImage($image, '/img/news/');
|
||||
|
||||
Reference in New Issue
Block a user