2016-11-21 20:55:05 +01:00
|
|
|
<?php
|
2017-04-21 08:09:24 +02:00
|
|
|
/**
|
|
|
|
* @api {OBJECT} Topic Topic
|
2019-03-06 16:47:24 +01:00
|
|
|
* @apiVersion 4.4.0
|
2017-04-21 08:09:24 +02:00
|
|
|
* @apiGroup Data Structures
|
|
|
|
* @apiParam {Number} id Id of the topic.
|
|
|
|
* @apiParam {String} name Name of the topic.
|
|
|
|
* @apiParam {String} icon Icon of the topic.
|
|
|
|
* @apiParam {String} iconColor Icon's color of the topic.
|
2018-11-08 18:51:04 +01:00
|
|
|
* @apiParam {Boolean} private Indicates if this event is not shown to users.
|
2017-04-22 03:33:17 +02:00
|
|
|
* @apiParam {[Article](#api-Data_Structures-ObjectArticle)[]} articles Articles of the Topic.
|
2017-04-21 08:09:24 +02:00
|
|
|
*/
|
2016-11-21 20:55:05 +01:00
|
|
|
|
|
|
|
class Topic extends DataStore {
|
|
|
|
const TABLE = 'topic';
|
|
|
|
|
2016-11-24 22:02:18 +01:00
|
|
|
public static function getProps() {
|
2016-11-21 20:55:05 +01:00
|
|
|
return [
|
|
|
|
'name',
|
|
|
|
'icon',
|
|
|
|
'iconColor',
|
2018-11-08 18:51:04 +01:00
|
|
|
'ownArticleList',
|
|
|
|
'private'
|
2016-11-21 20:55:05 +01:00
|
|
|
];
|
|
|
|
}
|
2016-11-23 02:27:05 +01:00
|
|
|
|
|
|
|
public function toArray() {
|
|
|
|
$articlesArray = [];
|
|
|
|
|
|
|
|
foreach($this->ownArticleList as $article) {
|
|
|
|
$articlesArray[] = $article->toArray();
|
|
|
|
}
|
|
|
|
|
|
|
|
return [
|
2016-12-05 03:51:45 +01:00
|
|
|
'id' => $this->id,
|
2016-11-23 02:27:05 +01:00
|
|
|
'name' => $this->name,
|
|
|
|
'icon' => $this->icon,
|
|
|
|
'iconColor' => $this->iconColor,
|
2018-11-08 18:51:04 +01:00
|
|
|
'private' => $this->private,
|
2016-11-23 02:27:05 +01:00
|
|
|
'articles' => $articlesArray
|
|
|
|
];
|
|
|
|
}
|
2018-11-08 18:51:04 +01:00
|
|
|
}
|