mirror of
https://github.com/Karaka-Management/oms-News.git
synced 2026-02-14 23:58:39 +00:00
implement immutable datetime
This commit is contained in:
parent
2287a43138
commit
a2923fa173
|
|
@ -93,7 +93,7 @@ class NewsArticle implements \JsonSerializable, ArrayableInterface
|
||||||
* @var \DateTime
|
* @var \DateTime
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private \DateTime $createdAt;
|
private \DateTimeImmutable $createdAt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creator.
|
* Creator.
|
||||||
|
|
@ -143,7 +143,7 @@ class NewsArticle implements \JsonSerializable, ArrayableInterface
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->createdBy = new NullAccount();
|
$this->createdBy = new NullAccount();
|
||||||
$this->createdAt = new \DateTime('now');
|
$this->createdAt = new \DateTimeImmutable('now');
|
||||||
$this->publish = new \DateTime('now');
|
$this->publish = new \DateTime('now');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -232,7 +232,7 @@ class NewsArticle implements \JsonSerializable, ArrayableInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function getCreatedAt() : \DateTime
|
public function getCreatedAt() : \DateTimeInterface
|
||||||
{
|
{
|
||||||
return $this->createdAt;
|
return $this->createdAt;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ final class NewsArticleMapper extends DataMapperAbstract
|
||||||
'news_type' => ['name' => 'news_type', 'type' => 'int', 'internal' => 'type'],
|
'news_type' => ['name' => 'news_type', 'type' => 'int', 'internal' => 'type'],
|
||||||
'news_featured' => ['name' => 'news_featured', 'type' => 'bool', 'internal' => 'featured'],
|
'news_featured' => ['name' => 'news_featured', 'type' => 'bool', 'internal' => 'featured'],
|
||||||
'news_comment_list' => ['name' => 'news_comment_list', 'type' => 'int', 'internal' => 'comments'],
|
'news_comment_list' => ['name' => 'news_comment_list', 'type' => 'int', 'internal' => 'comments'],
|
||||||
'news_created_at' => ['name' => 'news_created_at', 'type' => 'DateTime', 'internal' => 'createdAt', 'readonly' => true],
|
'news_created_at' => ['name' => 'news_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true],
|
||||||
'news_created_by' => ['name' => 'news_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
|
'news_created_by' => ['name' => 'news_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user