Skip to content

Commit 7e73479

Browse files
committed
Refactoring
1 parent 96163da commit 7e73479

File tree

2 files changed

+16
-33
lines changed

2 files changed

+16
-33
lines changed

src/Entity/Trait/TimestampsTrait.php

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
declare(strict_types=1);
4-
53
/*
64
* This file is part of the ixnode/php-api-version-bundle project.
75
*
@@ -11,13 +9,16 @@
119
* file that was distributed with this source code.
1210
*/
1311

12+
declare(strict_types=1);
13+
1414
namespace Ixnode\PhpApiVersionBundle\Entity\Trait;
1515

1616
use DateTimeImmutable;
1717
use Doctrine\ORM\Mapping as ORM;
18+
use Symfony\Component\Serializer\Annotation\Ignore;
1819

1920
/**
20-
* Trait TimestampsTrait
21+
* Trait TimestampTrait
2122
*
2223
* @author Björn Hempel <bjoern@hempel.li>
2324
* @version 0.1.0 (2023-01-01)
@@ -26,14 +27,14 @@
2627
trait TimestampsTrait
2728
{
2829
#[ORM\Column(name: 'created_at', type: 'datetime_immutable')]
30+
#[Ignore]
2931
private ?DateTimeImmutable $createdAt = null;
3032

3133
#[ORM\Column(name: 'updated_at', type: 'datetime_immutable')]
34+
#[Ignore]
3235
private ?DateTimeImmutable $updatedAt = null;
3336

3437
/**
35-
* Gets the created at field of this trait.
36-
*
3738
* @return DateTimeImmutable|null
3839
*/
3940
public function getCreatedAt(): ?DateTimeImmutable
@@ -42,21 +43,17 @@ public function getCreatedAt(): ?DateTimeImmutable
4243
}
4344

4445
/**
45-
* Sets the created at field of this trait.
46-
*
47-
* @param DateTimeImmutable $timestamp
46+
* @param DateTimeImmutable $createdAt
4847
* @return $this
4948
*/
50-
public function setCreatedAt(DateTimeImmutable $timestamp): self
49+
public function setCreatedAt(DateTimeImmutable $createdAt): self
5150
{
52-
$this->createdAt = $timestamp;
51+
$this->createdAt = $createdAt;
5352

5453
return $this;
5554
}
5655

5756
/**
58-
* Gets the updated at field of this trait.
59-
*
6057
* @return DateTimeImmutable|null
6158
*/
6259
public function getUpdatedAt(): ?DateTimeImmutable
@@ -65,14 +62,12 @@ public function getUpdatedAt(): ?DateTimeImmutable
6562
}
6663

6764
/**
68-
* Sets the updated at field of this trait.
69-
*
70-
* @param DateTimeImmutable $timestamp
65+
* @param DateTimeImmutable $updatedAt
7166
* @return $this
7267
*/
73-
public function setUpdatedAt(DateTimeImmutable $timestamp): self
68+
public function setUpdatedAt(DateTimeImmutable $updatedAt): self
7469
{
75-
$this->updatedAt = $timestamp;
70+
$this->updatedAt = $updatedAt;
7671

7772
return $this;
7873
}
@@ -81,6 +76,7 @@ public function setUpdatedAt(DateTimeImmutable $timestamp): self
8176
* Sets automatically the created at field.
8277
*/
8378
#[ORM\PrePersist]
79+
#[Ignore]
8480
public function setCreatedAtAutomatically(): void
8581
{
8682
if ($this->createdAt === null) {
@@ -93,6 +89,7 @@ public function setCreatedAtAutomatically(): void
9389
*/
9490
#[ORM\PrePersist]
9591
#[ORM\PreUpdate]
92+
#[Ignore]
9693
public function setUpdatedAtAutomatically(): void
9794
{
9895
$this->setUpdatedAt(new DateTimeImmutable());

src/Entity/Version.php

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
declare(strict_types=1);
4-
53
/*
64
* This file is part of the ixnode/php-api-version-bundle project.
75
*
@@ -11,6 +9,8 @@
119
* file that was distributed with this source code.
1210
*/
1311

12+
declare(strict_types=1);
13+
1414
namespace Ixnode\PhpApiVersionBundle\Entity;
1515

1616
use Doctrine\ORM\Mapping as ORM;
@@ -32,20 +32,6 @@ class Version implements EntityInterface, Stringable
3232
{
3333
use TimestampsTrait;
3434

35-
final public const CRUD_FIELDS_ADMIN = [];
36-
37-
final public const CRUD_FIELDS_REGISTERED = ['id', 'version', 'updatedAt', 'createdAt'];
38-
39-
final public const CRUD_FIELDS_INDEX = ['id', 'version', 'updatedAt', 'createdAt'];
40-
41-
final public const CRUD_FIELDS_NEW = ['id', 'version'];
42-
43-
final public const CRUD_FIELDS_EDIT = self::CRUD_FIELDS_NEW;
44-
45-
final public const CRUD_FIELDS_DETAIL = ['id', 'version', 'updatedAt', 'createdAt'];
46-
47-
final public const CRUD_FIELDS_FILTER = ['version'];
48-
4935
#[ORM\Id]
5036
#[ORM\GeneratedValue]
5137
#[ORM\Column(type: 'integer')]

0 commit comments

Comments
 (0)