-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #283 from dotkernel/issue-264
bump for doctrine orm 2 -> 3, dbal 3 -> 4 through roave psr container
- Loading branch information
Showing
16 changed files
with
105 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Api\App\Entity; | ||
|
||
use DateTimeImmutable; | ||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
#[ORM\HasLifecycleCallbacks] | ||
trait TimestampsTrait | ||
{ | ||
#[ORM\Column(name: "created", type: "datetime_immutable")] | ||
protected DateTimeImmutable $created; | ||
|
||
#[ORM\Column(name: "updated", type: "datetime_immutable", nullable: true)] | ||
protected ?DateTimeImmutable $updated = null; | ||
|
||
public function getCreated(): ?DateTimeImmutable | ||
{ | ||
return $this->created; | ||
} | ||
|
||
public function getCreatedFormatted(string $dateFormat = 'Y-m-d H:i:s'): string | ||
{ | ||
return $this->created->format($dateFormat); | ||
} | ||
|
||
public function getUpdated(): ?DateTimeImmutable | ||
{ | ||
return $this->updated; | ||
} | ||
|
||
public function getUpdatedFormatted(string $dateFormat = 'Y-m-d H:i:s'): ?string | ||
{ | ||
if ($this->updated instanceof DateTimeImmutable) { | ||
return $this->updated->format($dateFormat); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
#[ORM\PrePersist] | ||
public function created(): void | ||
{ | ||
$this->created = new DateTimeImmutable(); | ||
} | ||
|
||
#[ORM\PreUpdate] | ||
public function touch(): void | ||
{ | ||
$this->updated = new DateTimeImmutable(); | ||
} | ||
} |
Oops, something went wrong.