This commit is contained in:
Dennis Eichhorn 2020-03-05 20:35:58 +01:00
parent b1f53c89bc
commit dc5b332b71
7 changed files with 59 additions and 33 deletions

View File

@ -14,17 +14,18 @@ declare(strict_types=1);
namespace Modules\Kanban\Controller;
use Modules\Admin\Models\NullAccount;
use Modules\Kanban\Models\BoardStatus;
use Modules\Kanban\Models\CardStatus;
use Modules\Kanban\Models\CardType;
use Modules\Kanban\Models\KanbanBoard;
use Modules\Kanban\Models\KanbanBoardMapper;
use Modules\Kanban\Models\KanbanCard;
use Modules\Kanban\Models\KanbanCard;
use Modules\Kanban\Models\KanbanCardMapper;
use Modules\Kanban\Models\KanbanColumn;
use Modules\Kanban\Models\KanbanColumnMapper;
use Modules\Kanban\Models\KanbanColumnMapper;
use phpOMS\Message\NotificationLevel;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
@ -89,7 +90,7 @@ final class ApiController extends Controller
$card->setRef((int) ($request->getData('ref') ?? 0));
$card->setStatus((int) ($request->getData('status') ?? CardStatus::ACTIVE));
$card->setType((int) ($request->getData('type') ?? CardType::TEXT));
$card->setCreatedBy($request->getHeader()->getAccount());
$card->setCreatedBy(new NullAccount($request->getHeader()->getAccount()));
return $card;
}
@ -165,7 +166,7 @@ final class ApiController extends Controller
$board->setDescription((string) ($request->getData('plain') ?? ''));
$board->setOrder((int) ($request->getData('order') ?? 1));
$board->setStatus((int) ($request->getData('status') ?? BoardStatus::ACTIVE));
$board->setCreatedBy($request->getHeader()->getAccount());
$board->setCreatedBy(new NullAccount($request->getHeader()->getAccount()));
return $board;
}

View File

@ -14,6 +14,9 @@ declare(strict_types=1);
namespace Modules\Kanban\Models;
use Modules\Admin\Models\Account;
use Modules\Admin\Models\NullAccount;
/**
* Task class.
*
@ -51,11 +54,11 @@ class KanbanBoard implements \JsonSerializable
*/
private string $description = '';
private $createdBy = 0;
private Account $createdBy;
private $createdAt = null;
private \DateTime $createdAt;
private $columns = [];
private array $columns = [];
/**
* Constructor.
@ -65,6 +68,7 @@ class KanbanBoard implements \JsonSerializable
public function __construct()
{
$this->createdAt = new \DateTime('now');
$this->createdBy = new NullAccount();
}
/**
@ -186,11 +190,11 @@ class KanbanBoard implements \JsonSerializable
/**
* Get created by
*
* @return int|\phpOMS\Account\Account
* @return Account
*
* @since 1.0.0
*/
public function getCreatedBy()
public function getCreatedBy() : Account
{
return $this->createdBy;
}
@ -198,15 +202,15 @@ class KanbanBoard implements \JsonSerializable
/**
* Set created by
*
* @param mixed $id Created by
* @param Account $account Created by
*
* @return void
*
* @since 1.0.0
*/
public function setCreatedBy($id) : void
public function setCreatedBy(Account $account) : void
{
$this->createdBy = $id;
$this->createdBy = $account;
}
/**

View File

@ -39,7 +39,7 @@ final class KanbanBoardMapper extends DataMapperAbstract
'kanban_board_desc' => ['name' => 'kanban_board_desc', 'type' => 'string', 'internal' => 'description'],
'kanban_board_status' => ['name' => 'kanban_board_status', 'type' => 'int', 'internal' => 'status'],
'kanban_board_order' => ['name' => 'kanban_board_order', 'type' => 'int', 'internal' => 'order'],
'kanban_board_created_by' => ['name' => 'kanban_board_created_by', 'type' => 'int', 'internal' => 'createdBy'],
'kanban_board_created_by' => ['name' => 'kanban_board_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
'kanban_board_created_at' => ['name' => 'kanban_board_created_at', 'type' => 'DateTime', 'internal' => 'createdAt', 'readonly' => true],
];

View File

@ -14,6 +14,8 @@ declare(strict_types=1);
namespace Modules\Kanban\Models;
use Modules\Admin\Models\Account;
use Modules\Admin\Models\NullAccount;
use Modules\Tasks\Models\Task;
/**
@ -59,15 +61,15 @@ class KanbanCard implements \JsonSerializable
private $ref = 0;
private $createdBy = 0;
private Account $createdBy;
private $createdAt = null;
private \DateTime $createdAt;
private $comments = [];
private array $comments = [];
private $labels = [];
private array $labels = [];
private $media = [];
private array $media = [];
/**
* Constructor.
@ -77,6 +79,7 @@ class KanbanCard implements \JsonSerializable
public function __construct()
{
$this->createdAt = new \DateTime('now');
$this->createdBy = new NullAccount();
}
/**
@ -276,11 +279,11 @@ class KanbanCard implements \JsonSerializable
/**
* Get created by
*
* @return int|\phpOMS\Account\Account
* @return Account
*
* @since 1.0.0
*/
public function getCreatedBy()
public function getCreatedBy() : Account
{
return $this->createdBy;
}
@ -288,15 +291,15 @@ class KanbanCard implements \JsonSerializable
/**
* Set created by
*
* @param mixed $id Created by
* @param Account $account Created by
*
* @return void
*
* @since 1.0.0
*/
public function setCreatedBy($id) : void
public function setCreatedBy(Account $account) : void
{
$this->createdBy = $id;
$this->createdBy = $account;
}
/**

View File

@ -14,6 +14,9 @@ declare(strict_types=1);
namespace Modules\Kanban\Models;
use Modules\Admin\Models\Account;
use Modules\Admin\Models\NullAccount;
/**
* Task class.
*
@ -41,11 +44,11 @@ class KanbanCardComment implements \JsonSerializable
private $card = 0;
private $createdBy = 0;
private Account $createdBy;
private $createdAt = null;
private \DateTime $createdAt;
private $media = [];
private array $media = [];
/**
* Constructor.
@ -55,6 +58,7 @@ class KanbanCardComment implements \JsonSerializable
public function __construct()
{
$this->createdAt = new \DateTime('now');
$this->createdBy = new NullAccount();
}
/**
@ -124,11 +128,11 @@ class KanbanCardComment implements \JsonSerializable
/**
* Get created by
*
* @return int|\phpOMS\Account\Account
* @return Account
*
* @since 1.0.0
*/
public function getCreatedBy() : int
public function getCreatedBy() : Account
{
return $this->createdBy;
}
@ -136,15 +140,15 @@ class KanbanCardComment implements \JsonSerializable
/**
* Set created by
*
* @param mixed $id Created by
* @param Account $account Created by
*
* @return void
*
* @since 1.0.0
*/
public function setCreatedBy($id) : void
public function setCreatedBy(Account $account) : void
{
$this->createdBy = $id;
$this->createdBy = $account;
}
/**

View File

@ -14,6 +14,7 @@ declare(strict_types=1);
namespace Modules\Kanban\Models;
use Modules\Admin\Models\AccountMapper;
use Modules\Media\Models\MediaMapper;
use phpOMS\DataStorage\Database\DataMapperAbstract;
@ -38,7 +39,7 @@ final class KanbanCardCommentMapper extends DataMapperAbstract
'kanban_card_comment_description' => ['name' => 'kanban_card_comment_description', 'type' => 'string', 'internal' => 'description'],
'kanban_card_comment_card' => ['name' => 'kanban_card_comment_card', 'type' => 'int', 'internal' => 'card'],
'kanban_card_comment_created_at' => ['name' => 'kanban_card_comment_created_at', 'type' => 'DateTime', 'internal' => 'createdAt', 'readonly' => true],
'kanban_card_comment_created_by' => ['name' => 'kanban_card_comment_created_by', 'type' => 'int', 'internal' => 'createdBy'],
'kanban_card_comment_created_by' => ['name' => 'kanban_card_comment_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
];
/**
@ -56,6 +57,19 @@ final class KanbanCardCommentMapper 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' => 'kanban_card_comment_created_by',
],
];
/**
* Primary table.
*

View File

@ -44,7 +44,7 @@ final class KanbanCardMapper extends DataMapperAbstract
'kanban_card_ref' => ['name' => 'kanban_card_ref', 'type' => 'int', 'internal' => 'ref'],
'kanban_card_column' => ['name' => 'kanban_card_column', 'type' => 'int', 'internal' => 'column'],
'kanban_card_created_at' => ['name' => 'kanban_card_created_at', 'type' => 'DateTime', 'internal' => 'createdAt', 'readonly' => true],
'kanban_card_created_by' => ['name' => 'kanban_card_created_by', 'type' => 'int', 'internal' => 'createdBy'],
'kanban_card_created_by' => ['name' => 'kanban_card_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
];
/**