Skip to content
Permalink
Browse files

refactor: Changed default `EntityInterface` for future needs.

  • Loading branch information...
tarlepp committed Jun 25, 2019
1 parent 499bfd9 commit 0a9a42219714e8d0add0c90497ebd4fbdb515859
@@ -9,6 +9,7 @@
namespace App\Entity;
use DateTime;
use DateTimeZone;
use Doctrine\ORM\Mapping as ORM;
use Ramsey\Uuid\Uuid;
use Symfony\Component\Serializer\Annotation\Groups;
@@ -378,4 +379,14 @@ public function getUnixTime(): int
{
return $this->unixTime;
}
/**
* Returns createdAt.
*
* @return DateTime
*/
public function getCreatedAt(): DateTime
{
return DateTime::createFromFormat('U', (string)$this->getUnixTime(), new DateTimeZone('UTC'));
}
}
@@ -8,6 +8,8 @@
namespace App\Entity;
use DateTime;
/**
* Interface EntityInterface
*
@@ -20,4 +22,11 @@ interface EntityInterface
* @return string
*/
public function getId(): string;
/**
* Returns createdAt.
*
* @return DateTime|null
*/
public function getCreatedAt(): ?DateTime;
}
@@ -100,4 +100,14 @@ public function setTimestamp(DateTime $timestamp): self
return $this;
}
/**
* Returns createdAt.
*
* @return DateTime|null
*/
public function getCreatedAt(): ?DateTime
{
return $this->timestamp;
}
}
@@ -125,4 +125,14 @@ public function getTimestamp(): DateTime
{
return $this->timestamp;
}
/**
* Returns createdAt.
*
* @return DateTime|null
*/
public function getCreatedAt(): ?DateTime
{
return $this->getTimestamp();
}
}
@@ -14,14 +14,15 @@
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Serializer\Annotation\Groups;
use Throwable;
/**
* Trait LogEntityTrait
*
* @package App\Entity\Traits
* @author TLe, Tarmo Leppänen <tarmo.leppanen@protacon.com>
*
* @property \App\Entity\User|null $user
* @property User|null $user
*/
trait LogEntityTrait
{
@@ -165,8 +166,20 @@ public function getClientIp(): string
return $this->clientIp;
}
/**
* Returns createdAt.
*
* @return DateTime|null
*/
public function getCreatedAt(): ?DateTime
{
return $this->date;
}
/**
* @ORM\PrePersist()
*
* @throws Throwable
*/
protected function processTimeAndDate(): void
{
@@ -63,6 +63,7 @@ class UserGroup implements EntityInterface
*
* @Assert\NotBlank()
* @Assert\NotNull()
* @Assert\Valid()
*
* @ORM\ManyToOne(
* targetEntity="App\Entity\Role",

0 comments on commit 0a9a422

Please sign in to comment.
You can’t perform that action at this time.