mirror of
https://github.com/Karaka-Management/oms-Script.git
synced 2026-01-11 20:38:42 +00:00
fixes Orange-Management/phpOMS#224 and fixes Orange-Management/phpOMS#212
This commit is contained in:
parent
99c4d61353
commit
bd367b3b60
|
|
@ -24,4 +24,15 @@ namespace Modules\Helper\Models;
|
|||
*/
|
||||
final class NullReport extends Report
|
||||
{
|
||||
/**
|
||||
* 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\Helper\Models;
|
|||
*/
|
||||
final class NullTemplate extends Template
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Helper\Models;
|
||||
|
||||
use Modules\Admin\Models\Account;
|
||||
use Modules\Admin\Models\NullAccount;
|
||||
use Modules\Helper\Admin\Install\Media;
|
||||
use Modules\Media\Models\Collection;
|
||||
use Modules\Media\Models\NullCollection;
|
||||
|
||||
/**
|
||||
* Report model.
|
||||
*
|
||||
|
|
@ -30,7 +36,7 @@ class Report implements \JsonSerializable
|
|||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private int $id = 0;
|
||||
protected int $id = 0;
|
||||
|
||||
/**
|
||||
* Report status.
|
||||
|
|
@ -75,26 +81,26 @@ class Report implements \JsonSerializable
|
|||
/**
|
||||
* Report created by.
|
||||
*
|
||||
* @var int|\Modules\Admin\Models\Account
|
||||
* @var Account
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $createdBy = 0;
|
||||
private Account $createdBy;
|
||||
|
||||
/**
|
||||
* Report template.
|
||||
*
|
||||
* @var int|\Modules\Media\Models\Media
|
||||
* @var Template
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $template = 0;
|
||||
private Template $template;
|
||||
|
||||
/**
|
||||
* Report source.
|
||||
*
|
||||
* @var int|\Modules\Media\Models\Collection
|
||||
* @var Collection
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $source = 0;
|
||||
private Collection $source;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
|
@ -103,7 +109,10 @@ class Report implements \JsonSerializable
|
|||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->createdBy = new NullAccount();
|
||||
$this->createdAt = new \DateTime('now');
|
||||
$this->template = new NullTemplate();
|
||||
$this->source = new NullCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -231,17 +240,17 @@ class Report implements \JsonSerializable
|
|||
*/
|
||||
public function getCreatedAt() : \DateTime
|
||||
{
|
||||
return $this->createdAt ?? new \DateTime('now');
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get creator
|
||||
*
|
||||
* @return int|\phpOMS\Account\Account
|
||||
* @return Account
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getCreatedBy()
|
||||
public function getCreatedBy() : Account
|
||||
{
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
|
@ -249,13 +258,13 @@ class Report implements \JsonSerializable
|
|||
/**
|
||||
* Set creator
|
||||
*
|
||||
* @param mixed $creator Created by
|
||||
* @param Account $creator Created by
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setCreatedBy($creator) : void
|
||||
public function setCreatedBy(Account $creator) : void
|
||||
{
|
||||
$this->createdBy = $creator;
|
||||
}
|
||||
|
|
@ -263,11 +272,11 @@ class Report implements \JsonSerializable
|
|||
/**
|
||||
* Get template this report belongs to
|
||||
*
|
||||
* @return mixed
|
||||
* @return Template
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getTemplate()
|
||||
public function getTemplate() : Template
|
||||
{
|
||||
return $this->template;
|
||||
}
|
||||
|
|
@ -275,13 +284,13 @@ class Report implements \JsonSerializable
|
|||
/**
|
||||
* Set template this report belongs to
|
||||
*
|
||||
* @param mixed $template Report template
|
||||
* @param Template $template Report template
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setTemplate($template) : void
|
||||
public function setTemplate(Template $template) : void
|
||||
{
|
||||
$this->template = $template;
|
||||
}
|
||||
|
|
@ -289,13 +298,13 @@ class Report implements \JsonSerializable
|
|||
/**
|
||||
* Set source media for the report
|
||||
*
|
||||
* @param \Modules\Media\Models\Collection|int $source Report source
|
||||
* @param Collection $source Report source
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setSource($source) : void
|
||||
public function setSource(Collection $source) : void
|
||||
{
|
||||
$this->source = $source;
|
||||
}
|
||||
|
|
@ -303,11 +312,11 @@ class Report implements \JsonSerializable
|
|||
/**
|
||||
* Get source media for the report
|
||||
*
|
||||
* @return \Modules\Media\Models\Collection|int
|
||||
* @return Collection
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getSource()
|
||||
public function getSource() : Collection
|
||||
{
|
||||
return $this->source;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ final class ReportMapper extends DataMapperAbstract
|
|||
'helper_report_desc_raw' => ['name' => 'helper_report_desc_raw', 'type' => 'string', 'internal' => 'descriptionRaw'],
|
||||
'helper_report_media' => ['name' => 'helper_report_media', 'type' => 'int', 'internal' => 'source'],
|
||||
'helper_report_template' => ['name' => 'helper_report_template', 'type' => 'int', 'internal' => 'template'],
|
||||
'helper_report_creator' => ['name' => 'helper_report_creator', 'type' => 'int', 'internal' => 'createdBy'],
|
||||
'helper_report_creator' => ['name' => 'helper_report_creator', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
|
||||
'helper_report_created' => ['name' => 'helper_report_created', 'type' => 'DateTime', 'internal' => 'createdAt', 'readonly' => true],
|
||||
];
|
||||
|
||||
|
|
@ -57,7 +57,7 @@ final class ReportMapper extends DataMapperAbstract
|
|||
'self' => 'helper_report_media',
|
||||
],
|
||||
'template' => [
|
||||
'mapper' => \Modules\Helper\Models\TemplateMapper::class,
|
||||
'mapper' => TemplateMapper::class,
|
||||
'self' => 'helper_report_template',
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -14,6 +14,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Helper\Models;
|
||||
|
||||
use Modules\Admin\Models\Account;
|
||||
use Modules\Admin\Models\NullAccount;
|
||||
use Modules\Media\Models\Collection;
|
||||
use Modules\Media\Models\NullCollection;
|
||||
use Modules\Organization\Models\NullUnit;
|
||||
use Modules\Organization\Models\Unit;
|
||||
|
||||
/**
|
||||
* Template model.
|
||||
*
|
||||
|
|
@ -30,15 +37,15 @@ class Template implements \JsonSerializable
|
|||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private int $id = 0;
|
||||
protected int $id = 0;
|
||||
|
||||
/**
|
||||
* Unit.
|
||||
*
|
||||
* @var null|int|\Modules\Organization\Models\Unit
|
||||
* @var Unit
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $unit = null;
|
||||
private Unit $unit;
|
||||
|
||||
/**
|
||||
* Template status.
|
||||
|
|
@ -99,18 +106,18 @@ class Template implements \JsonSerializable
|
|||
/**
|
||||
* Template created by.
|
||||
*
|
||||
* @var int|\Modules\Admin\Models\Account
|
||||
* @var Account
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $createdBy = 0;
|
||||
private Account $createdBy;
|
||||
|
||||
/**
|
||||
* Template source.
|
||||
*
|
||||
* @var int|\Modules\Media\Models\Media
|
||||
* @var Collection
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $source = 0;
|
||||
private Collection $source;
|
||||
|
||||
/**
|
||||
* Expected files.
|
||||
|
|
@ -136,6 +143,9 @@ class Template implements \JsonSerializable
|
|||
public function __construct()
|
||||
{
|
||||
$this->createdAt = new \DateTime('now');
|
||||
$this->unit = new NullUnit();
|
||||
$this->source = new NullCollection();
|
||||
$this->createdBy = new NullAccount();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -153,11 +163,11 @@ class Template implements \JsonSerializable
|
|||
/**
|
||||
* Get unit this template belogns to
|
||||
*
|
||||
* @return null|int|\Modules\Organization\Models\Unit
|
||||
* @return Unit
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getUnit()
|
||||
public function getUnit() : Unit
|
||||
{
|
||||
return $this->unit;
|
||||
}
|
||||
|
|
@ -167,13 +177,13 @@ class Template implements \JsonSerializable
|
|||
*
|
||||
* Set the unit
|
||||
*
|
||||
* @param int $unit Unit
|
||||
* @param Unit $unit Unit
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setUnit(int $unit) : void
|
||||
public function setUnit(Unit $unit) : void
|
||||
{
|
||||
$this->unit = $unit;
|
||||
}
|
||||
|
|
@ -275,13 +285,13 @@ class Template implements \JsonSerializable
|
|||
/**
|
||||
* Set source media
|
||||
*
|
||||
* @param int $source Source
|
||||
* @param Collection $source Source
|
||||
*
|
||||
* @return mixed
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setSource($source)
|
||||
public function setSource(Collection $source) : void
|
||||
{
|
||||
$this->source = $source;
|
||||
}
|
||||
|
|
@ -289,11 +299,11 @@ class Template implements \JsonSerializable
|
|||
/**
|
||||
* Get source media
|
||||
*
|
||||
* @return mixed
|
||||
* @return Collection
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getSource()
|
||||
public function getSource() : Collection
|
||||
{
|
||||
return $this->source;
|
||||
}
|
||||
|
|
@ -301,13 +311,13 @@ class Template implements \JsonSerializable
|
|||
/**
|
||||
* Set creator
|
||||
*
|
||||
* @param mixed $createdBy Creator
|
||||
* @param Account $createdBy Creator
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setCreatedBy($createdBy) : void
|
||||
public function setCreatedBy(Account $createdBy) : void
|
||||
{
|
||||
$this->createdBy = $createdBy;
|
||||
}
|
||||
|
|
@ -315,11 +325,11 @@ class Template implements \JsonSerializable
|
|||
/**
|
||||
* Get creator
|
||||
*
|
||||
* @return int|\phpOMS\Account\Account
|
||||
* @return Account
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getCreatedBy()
|
||||
public function getCreatedBy() : Account
|
||||
{
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
|
@ -333,7 +343,7 @@ class Template implements \JsonSerializable
|
|||
*/
|
||||
public function getCreatedAt() : \DateTime
|
||||
{
|
||||
return $this->createdAt ?? new \DateTime('now');
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user