mirror of
https://github.com/Karaka-Management/oms-Calendar.git
synced 2026-01-28 15:38:42 +00:00
fixes Orange-Management/phpOMS#224 and fixes Orange-Management/phpOMS#212
This commit is contained in:
parent
8eb88fd7e2
commit
10eefe96e2
|
|
@ -14,8 +14,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Calendar\Models;
|
||||
|
||||
use Modules\Admin\Models\NullAccount;
|
||||
use phpOMS\Account\Account;
|
||||
use phpOMS\Account\NullAccount;
|
||||
use phpOMS\Stdlib\Base\Location;
|
||||
|
||||
/**
|
||||
|
|
@ -63,10 +63,10 @@ class Event
|
|||
/**
|
||||
* Creator.
|
||||
*
|
||||
* @var int|\Modules\Admin\Models\Account
|
||||
* @var Account
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $createdBy = 0;
|
||||
private Account $createdBy;
|
||||
|
||||
/**
|
||||
* Event type.
|
||||
|
|
@ -91,10 +91,10 @@ class Event
|
|||
/**
|
||||
* Schedule
|
||||
*
|
||||
* @var int|Schedule
|
||||
* @var Schedule
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $schedule;
|
||||
private Schedule $schedule;
|
||||
|
||||
/**
|
||||
* Location of the event.
|
||||
|
|
@ -127,6 +127,7 @@ class Event
|
|||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->createdBy = new NullAccount();
|
||||
$this->createdAt = new \DateTime('now');
|
||||
$this->location = new Location();
|
||||
$this->schedule = new Schedule();
|
||||
|
|
@ -247,11 +248,11 @@ class Event
|
|||
}
|
||||
|
||||
/**
|
||||
* @return int|\Modules\Admin\Models\Account
|
||||
* @return Account
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getCreatedBy()
|
||||
public function getCreatedBy() : Account
|
||||
{
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
|
@ -259,13 +260,13 @@ class Event
|
|||
/**
|
||||
* Set creator
|
||||
*
|
||||
* @param int $createdBy Creator
|
||||
* @param Account $createdBy Creator
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setCreatedBy(int $createdBy) : void
|
||||
public function setCreatedBy(Account $createdBy) : void
|
||||
{
|
||||
$this->createdBy = $createdBy;
|
||||
|
||||
|
|
@ -339,11 +340,11 @@ class Event
|
|||
}
|
||||
|
||||
/**
|
||||
* @return int|Schedule
|
||||
* @return Schedule
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getSchedule()
|
||||
public function getSchedule() : Schedule
|
||||
{
|
||||
return $this->schedule;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Calendar\Models;
|
||||
|
||||
use Modules\Admin\Models\AccountMapper;
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
|
||||
/**
|
||||
|
|
@ -41,7 +42,7 @@ final class EventMapper extends DataMapperAbstract
|
|||
'calendar_event_status' => ['name' => 'calendar_event_status', 'type' => 'int', 'internal' => 'status'],
|
||||
'calendar_event_schedule' => ['name' => 'calendar_event_schedule', 'type' => 'int', 'internal' => 'schedule'],
|
||||
'calendar_event_calendar' => ['name' => 'calendar_event_calendar', 'type' => 'int', 'internal' => 'calendar'],
|
||||
'calendar_event_created_by' => ['name' => 'calendar_event_created_by', 'type' => 'int', 'internal' => 'createdBy'],
|
||||
'calendar_event_created_by' => ['name' => 'calendar_event_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
|
||||
'calendar_event_created_at' => ['name' => 'calendar_event_created_at', 'type' => 'DateTime', 'internal' => 'createdAt', 'readonly' => true],
|
||||
];
|
||||
|
||||
|
|
@ -58,6 +59,19 @@ final class EventMapper extends DataMapperAbstract
|
|||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Belongs to.
|
||||
*
|
||||
* @var array<string, array{mapper:string, self:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $belongsTo = [
|
||||
'createdBy' => [
|
||||
'mapper' => AccountMapper::class,
|
||||
'self' => 'calendar_event_created_by',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Calendar\Models;
|
||||
|
||||
use Modules\Admin\Models\Account;
|
||||
use Modules\Admin\Models\NullAccount;
|
||||
use phpOMS\Stdlib\Base\Exception\InvalidEnumValue;
|
||||
|
||||
/**
|
||||
|
|
@ -125,10 +127,10 @@ class Schedule
|
|||
/**
|
||||
* Created by.
|
||||
*
|
||||
* @var int|\Modules\Admin\Models\Account
|
||||
* @var Account
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $createdBy = 0;
|
||||
private Account $createdBy;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
|
@ -137,6 +139,7 @@ class Schedule
|
|||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->createdBy = new NullAccount();
|
||||
$this->createdAt = new \DateTime('now');
|
||||
$this->start = new \DateTime('now');
|
||||
$this->end = new \DateTime('now');
|
||||
|
|
@ -170,7 +173,7 @@ class Schedule
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setStatus(int $status)
|
||||
public function setStatus(int $status) : self
|
||||
{
|
||||
if (!ScheduleStatus::isValidValue($status)) {
|
||||
throw new InvalidEnumValue($status);
|
||||
|
|
@ -198,7 +201,7 @@ class Schedule
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setFreqType(int $freqType)
|
||||
public function setFreqType(int $freqType) : self
|
||||
{
|
||||
if (!FrequencyType::isValidValue($freqType)) {
|
||||
throw new InvalidEnumValue($freqType);
|
||||
|
|
@ -226,7 +229,7 @@ class Schedule
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setIntervalType(int $intervalType)
|
||||
public function setIntervalType(int $intervalType) : self
|
||||
{
|
||||
if (!IntervalType::isValidValue($intervalType)) {
|
||||
throw new InvalidEnumValue($intervalType);
|
||||
|
|
@ -254,7 +257,7 @@ class Schedule
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setFrequencyRelative(int $relativeInterval)
|
||||
public function setFrequencyRelative(int $relativeInterval) : self
|
||||
{
|
||||
if (!FrequencyRelative::isValidValue($relativeInterval)) {
|
||||
throw new InvalidEnumValue($relativeInterval);
|
||||
|
|
@ -272,7 +275,7 @@ class Schedule
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setFreqInterval(int $freqInterval)
|
||||
public function setFreqInterval(int $freqInterval) : self
|
||||
{
|
||||
if (!FrequencyInterval::isValidValue($freqInterval)) {
|
||||
throw new InvalidEnumValue($freqInterval);
|
||||
|
|
@ -310,7 +313,7 @@ class Schedule
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setRecurrenceFactor(int $recurrence)
|
||||
public function setRecurrenceFactor(int $recurrence) : self
|
||||
{
|
||||
$this->recurrenceFactor = $recurrence;
|
||||
|
||||
|
|
@ -334,7 +337,7 @@ class Schedule
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setStart(\DateTime $start)
|
||||
public function setStart(\DateTime $start) : self
|
||||
{
|
||||
$this->start = $start;
|
||||
|
||||
|
|
@ -394,13 +397,13 @@ class Schedule
|
|||
}
|
||||
|
||||
/**
|
||||
* @param int $creator Creator
|
||||
* @param Account $creator Creator
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setCreatedBy(int $creator)
|
||||
public function setCreatedBy(Account $creator) : self
|
||||
{
|
||||
$this->createdBy = $creator;
|
||||
|
||||
|
|
@ -408,11 +411,11 @@ class Schedule
|
|||
}
|
||||
|
||||
/**
|
||||
* @return int|\Modules\Admin\Models\Account
|
||||
* @return Account
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getCreatedBy()
|
||||
public function getCreatedBy() : Account
|
||||
{
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Calendar\Models;
|
||||
|
||||
use Modules\Admin\Models\AccountMapper;
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
|
||||
/**
|
||||
|
|
@ -45,7 +46,20 @@ final class ScheduleMapper extends DataMapperAbstract
|
|||
'schedule_duration' => ['name' => 'schedule_duration', 'type' => 'int', 'internal' => 'duration'],
|
||||
'schedule_end' => ['name' => 'schedule_end', 'type' => 'DateTime', 'internal' => 'end'],
|
||||
'schedule_created_at' => ['name' => 'schedule_created_at', 'type' => 'DateTime', 'internal' => 'createdAt', 'readonly' => true],
|
||||
'schedule_created_by' => ['name' => 'schedule_created_by', 'type' => 'int', 'internal' => 'createdBy'],
|
||||
'schedule_created_by' => ['name' => 'schedule_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
|
||||
];
|
||||
|
||||
/**
|
||||
* Belongs to.
|
||||
*
|
||||
* @var array<string, array{mapper:string, self:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $belongsTo = [
|
||||
'createdBy' => [
|
||||
'mapper' => AccountMapper::class,
|
||||
'self' => 'schedule_created_by',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user