oms-Knowledgebase/Models/WikiDoc.php
2024-03-20 07:21:22 +00:00

179 lines
3.1 KiB
PHP
Executable File

<?php
/**
* Jingga
*
* PHP Version 8.2
*
* @package Modules\Knowledgebase\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\Knowledgebase\Models;
use Modules\Admin\Models\Account;
use Modules\Admin\Models\NullAccount;
use Modules\Tag\Models\Tag;
use phpOMS\Localization\ISO639x1Enum;
/**
* Wiki document class.
*
* @package Modules\Knowledgebase\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
class WikiDoc implements \JsonSerializable
{
/**
* ID.
*
* @var int
* @since 1.0.0
*/
public int $id = 0;
/**
* Version.
*
* @var string
* @since 1.0.0
*/
public string $version = '';
/**
* App id.
*
* There can be different wikis
*
* @var null|WikiApp
* @since 1.0.0
*/
public ?WikiApp $app = null;
/**
* Name.
*
* @var string
* @since 1.0.0
*/
public string $name = '';
/**
* Article status.
*
* @var int
* @since 1.0.0
*/
public int $status = WikiStatus::ACTIVE;
/**
* Document content.
*
* @var string
* @since 1.0.0
*/
public string $doc = '';
/**
* Document raw content.
*
* @var string
* @since 1.0.0
*/
public string $docRaw = '';
/**
* Category.
*
* @var null|WikiCategory
* @since 1.0.0
*/
public ?WikiCategory $category = null;
/**
* Language.
*
* @var string
* @since 1.0.0
*/
public string $language = ISO639x1Enum::_EN;
/**
* Tags.
*
* @var Tag[]
* @since 1.0.0
*/
public array $tags = [];
/**
* Is versioned
*
* @var bool
* @since 1.0.0
*/
public bool $isVersioned = false;
/**
* Created.
*
* @var \DateTimeImmutable
* @since 1.0.0
*/
public \DateTimeImmutable $createdAt;
/**
* Creator.
*
* @var Account
* @since 1.0.0
*/
public Account $createdBy;
/**
* Constructor.
*
* @since 1.0.0
*/
public function __construct()
{
$this->createdBy = new NullAccount();
$this->createdAt = new \DateTimeImmutable('now');
}
/**
* {@inheritdoc}
*/
public function toArray() : array
{
return [
'id' => $this->id,
'app' => $this->app,
'name' => $this->name,
'status' => $this->status,
'doc' => $this->doc,
'docRaw' => $this->docRaw,
'language' => $this->language,
'tags' => $this->tags,
'media' => $this->files,
'createdAt' => $this->createdAt,
'createdBy' => $this->createdBy,
];
}
/**
* {@inheritdoc}
*/
public function jsonSerialize() : mixed
{
return $this->toArray();
}
use \Modules\Media\Models\MediaListTrait;
}