mirror of
https://github.com/Karaka-Management/oms-Knowledgebase.git
synced 2026-02-10 15:28:41 +00:00
fixes Orange-Management/phpOMS#224 and fixes Orange-Management/phpOMS#212
This commit is contained in:
parent
2a7300a26c
commit
94c9c0bcd0
|
|
@ -24,4 +24,15 @@ namespace Modules\Knowledgebase\Models;
|
||||||
*/
|
*/
|
||||||
final class NullWikiApp extends WikiApp
|
final class NullWikiApp extends WikiApp
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param int $id Model id
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function __construct(int $id = 0)
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,4 +24,15 @@ namespace Modules\Knowledgebase\Models;
|
||||||
*/
|
*/
|
||||||
final class NullWikiCategory extends WikiCategory
|
final class NullWikiCategory extends WikiCategory
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param int $id Model id
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function __construct(int $id = 0)
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,4 +24,15 @@ namespace Modules\Knowledgebase\Models;
|
||||||
*/
|
*/
|
||||||
final class NullWikiDoc extends WikiDoc
|
final class NullWikiDoc extends WikiDoc
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param int $id Model id
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function __construct(int $id = 0)
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,10 +37,10 @@ class WikiCategory implements \JsonSerializable
|
||||||
*
|
*
|
||||||
* There can be different wikis
|
* There can be different wikis
|
||||||
*
|
*
|
||||||
* @var null|int|WikiApp
|
* @var null|WikiApp
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private $app = null;
|
private ?WikiApp $app = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name.
|
* Name.
|
||||||
|
|
@ -61,10 +61,10 @@ class WikiCategory implements \JsonSerializable
|
||||||
/**
|
/**
|
||||||
* Parent category.
|
* Parent category.
|
||||||
*
|
*
|
||||||
* @var null|int|self
|
* @var self
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private $parent = null;
|
private ?self $parent = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get id.
|
* Get id.
|
||||||
|
|
@ -81,25 +81,25 @@ class WikiCategory implements \JsonSerializable
|
||||||
/**
|
/**
|
||||||
* Get app
|
* Get app
|
||||||
*
|
*
|
||||||
* @return null|int|WikiApp
|
* @return WikiApp
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function getApp()
|
public function getApp() : WikiApp
|
||||||
{
|
{
|
||||||
return $this->app;
|
return $this->app ?? new NullWikiApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set app
|
* Set app
|
||||||
*
|
*
|
||||||
* @param int $app App
|
* @param null|WikiApp $app App
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function setApp(int $app) : void
|
public function setApp(?WikiApp $app) : void
|
||||||
{
|
{
|
||||||
$this->app = $app;
|
$this->app = $app;
|
||||||
}
|
}
|
||||||
|
|
@ -159,25 +159,25 @@ class WikiCategory implements \JsonSerializable
|
||||||
/**
|
/**
|
||||||
* Get parent category
|
* Get parent category
|
||||||
*
|
*
|
||||||
* @return null|int|self
|
* @return null|self
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function getParent()
|
public function getParent() : self
|
||||||
{
|
{
|
||||||
return $this->parent;
|
return $this->parent ?? new NullWikiCategory();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set parent category
|
* Set parent category
|
||||||
*
|
*
|
||||||
* @param int $parent Parent category
|
* @param null|self $parent Parent category
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function setParent(int $parent) : void
|
public function setParent(?self $parent) : void
|
||||||
{
|
{
|
||||||
$this->parent = $parent;
|
$this->parent = $parent;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Modules\Knowledgebase\Models;
|
namespace Modules\Knowledgebase\Models;
|
||||||
|
|
||||||
|
use Modules\Tag\Models\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wiki document class.
|
* Wiki document class.
|
||||||
*
|
*
|
||||||
|
|
@ -37,10 +39,10 @@ class WikiDoc implements \JsonSerializable
|
||||||
*
|
*
|
||||||
* There can be different wikis
|
* There can be different wikis
|
||||||
*
|
*
|
||||||
* @var null|int|WikiApp
|
* @var null|WikiApp
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private $app = null;
|
private ?WikiApp $app = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name.
|
* Name.
|
||||||
|
|
@ -77,10 +79,10 @@ class WikiDoc implements \JsonSerializable
|
||||||
/**
|
/**
|
||||||
* Category.
|
* Category.
|
||||||
*
|
*
|
||||||
* @var int|WikiCategory
|
* @var null|WikiCategory
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private $category = 0;
|
private ?WikiCategory $category = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Language.
|
* Language.
|
||||||
|
|
@ -88,15 +90,15 @@ class WikiDoc implements \JsonSerializable
|
||||||
* @var string
|
* @var string
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private $language = 'en';
|
private string $language = 'en';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tags.
|
* Tags.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var Tag[]
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private $tags = [];
|
private array $tags = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get id.
|
* Get id.
|
||||||
|
|
@ -113,25 +115,25 @@ class WikiDoc implements \JsonSerializable
|
||||||
/**
|
/**
|
||||||
* Get app
|
* Get app
|
||||||
*
|
*
|
||||||
* @return null|int|WikiApp
|
* @return WikiApp
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function getApp()
|
public function getApp() : WikiApp
|
||||||
{
|
{
|
||||||
return $this->app;
|
return $this->app ?? new NullWikiApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set app
|
* Set app
|
||||||
*
|
*
|
||||||
* @param int $app App
|
* @param null|WikiApp $app App
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function setApp(int $app) : void
|
public function setApp(?WikiApp $app) : void
|
||||||
{
|
{
|
||||||
$this->app = $app;
|
$this->app = $app;
|
||||||
}
|
}
|
||||||
|
|
@ -269,25 +271,25 @@ class WikiDoc implements \JsonSerializable
|
||||||
/**
|
/**
|
||||||
* Get category
|
* Get category
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return WikiCategory
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function getCategory()
|
public function getCategory() : WikiCategory
|
||||||
{
|
{
|
||||||
return $this->category;
|
return $this->category ?? new NullWikiCategory();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set cateogry
|
* Set cateogry
|
||||||
*
|
*
|
||||||
* @param int $category Category
|
* @param null|WikiCategory $category Category
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function setCategory(int $category) : void
|
public function setCategory(?WikiCategory $category) : void
|
||||||
{
|
{
|
||||||
$this->category = $category;
|
$this->category = $category;
|
||||||
}
|
}
|
||||||
|
|
@ -307,13 +309,13 @@ class WikiDoc implements \JsonSerializable
|
||||||
/**
|
/**
|
||||||
* Add tag
|
* Add tag
|
||||||
*
|
*
|
||||||
* @param mixed $tag Tag
|
* @param Tag $tag Tag
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function addTag($tag) : void
|
public function addTag(Tag $tag) : void
|
||||||
{
|
{
|
||||||
$this->tags[] = $tag;
|
$this->tags[] = $tag;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user