mirror of
https://github.com/Karaka-Management/oms-Tag.git
synced 2026-01-11 15:48:42 +00:00
fixes Orange-Management/phpOMS#224 and fixes Orange-Management/phpOMS#212
This commit is contained in:
parent
88362b3254
commit
e2fca5d3f8
|
|
@ -24,4 +24,15 @@ namespace Modules\Tag\Models;
|
|||
*/
|
||||
final class NullTag extends Tag
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Tag\Models;
|
||||
|
||||
use Modules\Admin\Models\Account;
|
||||
use Modules\Admin\Models\NullAccount;
|
||||
use phpOMS\Contract\ArrayableInterface;
|
||||
|
||||
/**
|
||||
|
|
@ -32,7 +34,7 @@ class Tag implements ArrayableInterface, \JsonSerializable
|
|||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private int $id = 0;
|
||||
protected int $id = 0;
|
||||
|
||||
/**
|
||||
* Title.
|
||||
|
|
@ -53,10 +55,10 @@ class Tag implements ArrayableInterface, \JsonSerializable
|
|||
/**
|
||||
* Creator.
|
||||
*
|
||||
* @var null|int|\Modules\Admin\Models\Account
|
||||
* @var Account
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $owner = null;
|
||||
protected Account $owner;
|
||||
|
||||
/**
|
||||
* Tag type.
|
||||
|
|
@ -69,25 +71,25 @@ class Tag implements ArrayableInterface, \JsonSerializable
|
|||
/**
|
||||
* Get created by
|
||||
*
|
||||
* @return null|int|\Modules\Admin\Models\Account
|
||||
* @return Account
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getOwner()
|
||||
public function getOwner() : Account
|
||||
{
|
||||
return $this->owner;
|
||||
return $this->owner ?? new NullAccount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set created by
|
||||
*
|
||||
* @param mixed $id Created by
|
||||
* @param Account $id Created by
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setOwner($id) : void
|
||||
public function setOwner(Account $id) : void
|
||||
{
|
||||
$this->owner = $id;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user