mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-07 07:43:12 +08:00
Migrated from standard datetime objects to chronos objects
This commit is contained in:
@@ -3,6 +3,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\Core\Entity;
|
||||
|
||||
use Cake\Chronos\Chronos;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
@@ -36,8 +37,8 @@ class ShortUrl extends AbstractEntity
|
||||
*/
|
||||
private $shortCode;
|
||||
/**
|
||||
* @var \DateTime
|
||||
* @ORM\Column(name="date_created", type="datetime")
|
||||
* @var Chronos
|
||||
* @ORM\Column(name="date_created", type="chronos_datetime")
|
||||
*/
|
||||
private $dateCreated;
|
||||
/**
|
||||
@@ -56,13 +57,13 @@ class ShortUrl extends AbstractEntity
|
||||
*/
|
||||
private $tags;
|
||||
/**
|
||||
* @var \DateTime
|
||||
* @ORM\Column(name="valid_since", type="datetime", nullable=true)
|
||||
* @var Chronos|null
|
||||
* @ORM\Column(name="valid_since", type="chronos_datetime", nullable=true)
|
||||
*/
|
||||
private $validSince;
|
||||
/**
|
||||
* @var \DateTime
|
||||
* @ORM\Column(name="valid_until", type="datetime", nullable=true)
|
||||
* @var Chronos|null
|
||||
* @ORM\Column(name="valid_until", type="chronos_datetime", nullable=true)
|
||||
*/
|
||||
private $validUntil;
|
||||
/**
|
||||
@@ -74,7 +75,7 @@ class ShortUrl extends AbstractEntity
|
||||
public function __construct()
|
||||
{
|
||||
$this->shortCode = '';
|
||||
$this->dateCreated = new \DateTime();
|
||||
$this->dateCreated = Chronos::now();
|
||||
$this->visits = new ArrayCollection();
|
||||
$this->tags = new ArrayCollection();
|
||||
}
|
||||
@@ -117,12 +118,12 @@ class ShortUrl extends AbstractEntity
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDateCreated(): \DateTime
|
||||
public function getDateCreated(): Chronos
|
||||
{
|
||||
return $this->dateCreated;
|
||||
}
|
||||
|
||||
public function setDateCreated(\DateTime $dateCreated): self
|
||||
public function setDateCreated(Chronos $dateCreated): self
|
||||
{
|
||||
$this->dateCreated = $dateCreated;
|
||||
return $this;
|
||||
@@ -151,23 +152,23 @@ class ShortUrl extends AbstractEntity
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getValidSince(): ?\DateTime
|
||||
public function getValidSince(): ?Chronos
|
||||
{
|
||||
return $this->validSince;
|
||||
}
|
||||
|
||||
public function setValidSince(?\DateTime $validSince): self
|
||||
public function setValidSince(?Chronos $validSince): self
|
||||
{
|
||||
$this->validSince = $validSince;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getValidUntil(): ?\DateTime
|
||||
public function getValidUntil(): ?Chronos
|
||||
{
|
||||
return $this->validUntil;
|
||||
}
|
||||
|
||||
public function setValidUntil(?\DateTime $validUntil): self
|
||||
public function setValidUntil(?Chronos $validUntil): self
|
||||
{
|
||||
$this->validUntil = $validUntil;
|
||||
return $this;
|
||||
|
||||
@@ -3,6 +3,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\Core\Entity;
|
||||
|
||||
use Cake\Chronos\Chronos;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Shlinkio\Shlink\Common\Entity\AbstractEntity;
|
||||
use Shlinkio\Shlink\Common\Exception\WrongIpException;
|
||||
@@ -25,8 +26,8 @@ class Visit extends AbstractEntity implements \JsonSerializable
|
||||
*/
|
||||
private $referer;
|
||||
/**
|
||||
* @var \DateTime
|
||||
* @ORM\Column(type="datetime", nullable=false)
|
||||
* @var Chronos
|
||||
* @ORM\Column(type="chronos_datetime", nullable=false)
|
||||
*/
|
||||
private $date;
|
||||
/**
|
||||
@@ -54,7 +55,7 @@ class Visit extends AbstractEntity implements \JsonSerializable
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->date = new \DateTime();
|
||||
$this->date = Chronos::now();
|
||||
}
|
||||
|
||||
public function getReferer(): string
|
||||
@@ -68,12 +69,12 @@ class Visit extends AbstractEntity implements \JsonSerializable
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDate(): \DateTime
|
||||
public function getDate(): Chronos
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
public function setDate(\DateTime $date): self
|
||||
public function setDate(Chronos $date): self
|
||||
{
|
||||
$this->date = $date;
|
||||
return $this;
|
||||
@@ -148,7 +149,7 @@ class Visit extends AbstractEntity implements \JsonSerializable
|
||||
{
|
||||
return [
|
||||
'referer' => $this->referer,
|
||||
'date' => isset($this->date) ? $this->date->format(\DateTime::ATOM) : null,
|
||||
'date' => isset($this->date) ? $this->date->toAtomString() : null,
|
||||
'userAgent' => $this->userAgent,
|
||||
'visitLocation' => $this->visitLocation,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user