From 8ca2d350e80d5797f1c89e578f9701f344794168 Mon Sep 17 00:00:00 2001 From: flo Date: Wed, 1 Jan 2025 23:58:15 +0100 Subject: [PATCH] DataDomain changes --- .../Business/config/service_manager.php | 8 +- src/DataDomain/Business/src/Entity/Mail.php | 125 ++++++++++++++++++ src/DataDomain/Business/src/Entity/User.php | 32 ++++- .../Business/src/Entity/UserPasswordToken.php | 91 +++++++++++++ .../src/Repository/MailRepository.php | 9 ++ .../UserPasswordTokenRepository.php | 10 ++ 6 files changed, 269 insertions(+), 6 deletions(-) create mode 100644 src/DataDomain/Business/src/Entity/Mail.php create mode 100644 src/DataDomain/Business/src/Entity/UserPasswordToken.php create mode 100644 src/DataDomain/Business/src/Repository/MailRepository.php create mode 100644 src/DataDomain/Business/src/Repository/UserPasswordTokenRepository.php diff --git a/src/DataDomain/Business/config/service_manager.php b/src/DataDomain/Business/config/service_manager.php index c0faf40..d20656a 100644 --- a/src/DataDomain/Business/config/service_manager.php +++ b/src/DataDomain/Business/config/service_manager.php @@ -1,20 +1,20 @@ [ - 'doctrine.entity_manager.orm_template' => [BaseEntityManagerFactory::class, 'orm_template'], + 'doctrine.entity_manager.orm_template' => [EntityManagerFactory::class, 'orm_template'], 'doctrine.configuration.orm_template' => [ConfigurationFactory::class, 'orm_template'], 'doctrine.connection.orm_template' => [ConnectionFactory::class, 'orm_template'], - EntityManager::class => EntityManagerFactory::class, + EntityManager::class => TemplateEntityManagerFactory::class, UserRepository::class => [AutowireRepositoryFactory::class, EntityManager::class, User::class], ], diff --git a/src/DataDomain/Business/src/Entity/Mail.php b/src/DataDomain/Business/src/Entity/Mail.php new file mode 100644 index 0000000..ffff6fe --- /dev/null +++ b/src/DataDomain/Business/src/Entity/Mail.php @@ -0,0 +1,125 @@ +id = UuidGenerator::generate(); + + $now = new DateTime(); + $this->setCreatedAt($now); + $this->setFailedAt(null); + } + + + /** + * @ORM\PrePersist + * @ORM\PreUpdate + */ + public function updateTimestamps(): void { + $now = new DateTime(); + //$this->setUpdatedAt($now); + } + + + public function getId(): UuidInterface { + return $this->id; + } + + public function getTemplate(): string + { + return $this->template; + } + public function setTemplate(string $template): void + { + $this->template = $template; + } + + public function getData(): array + { + return $this->data; + } + public function setData(array $data): void + { + $this->data = $data; + } + + public function getRecipient(): string + { + return $this->recipient; + } + public function setRecipient(string $recipient): void + { + $this->recipient = $recipient; + } + + public function getSender(): ?string + { + return $this->sender; + } + public function setSender(?string $sender): void + { + $this->sender = $sender; + } + + public function getSenderName(): ?string + { + return $this->senderName; + } + public function setSenderName(?string $senderName): void + { + $this->senderName = $senderName; + } + + public function getFailedAt(): ?DateTime + { + return $this->failedAt; + } + public function setFailedAt(?DateTime $failedAt): void + { + $this->failedAt = $failedAt; + } + + public function getCreatedAt(): DateTime { + return $this->createdAt; + } + public function setCreatedAt(DateTime $createdAt): void { + $this->createdAt = $createdAt; + } +} diff --git a/src/DataDomain/Business/src/Entity/User.php b/src/DataDomain/Business/src/Entity/User.php index a753968..d011fe0 100644 --- a/src/DataDomain/Business/src/Entity/User.php +++ b/src/DataDomain/Business/src/Entity/User.php @@ -3,6 +3,8 @@ namespace Template\Data\Business\Entity; use DateTime; +use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Template\Infrastructure\UuidGenerator\UuidGenerator; use Ramsey\Uuid\UuidInterface; @@ -39,8 +41,11 @@ class User { /** @ORM\OneToOne(targetEntity="Template\Data\Business\Entity\UserSession", mappedBy="user") */ private ?UserSession $session; + /* @ORM\OneToMany(targetEntity="Bee\Data\Business\Entity\UserPasswordToken", mappedBy="user") */ + private Collection $passwordTokens; + /** @ORM\Column(name="last_login_at", type="datetime", nullable=true) */ - private DateTime $lastLoginAt; + private ?DateTime $lastLoginAt; /** @ORM\Column(name="created_at", type="datetime") */ private DateTime $createdAt; @@ -51,7 +56,9 @@ class User { public function __construct() { $this->id = UuidGenerator::generate(); - + + $this->passwordTokens = new ArrayCollection(); + $now = new DateTime(); $this->setCreatedAt($now); $this->setUpdatedAt($now); @@ -143,6 +150,27 @@ class User { public function setUpdatedAt(DateTime $updatedAt): void { $this->updatedAt = $updatedAt; } + + public function getPasswordTokens(): Collection + { + return $this->passwordTokens; + } + public function setPasswordTokens(Collection $passwordTokens): void + { + $this->passwordTokens = $passwordTokens; + } + public function addPasswordToken(UserPasswordToken $passwordToken): void + { + if (!$this->passwordTokens->contains($passwordToken)) { + $this->passwordTokens->add($passwordToken); + } + } + public function removePasswordToken(UserPasswordToken $passwordToken): void + { + if ($this->passwordTokens->contains($passwordToken)) { + $this->passwordTokens->removeElement($passwordToken); + } + } } ?> \ No newline at end of file diff --git a/src/DataDomain/Business/src/Entity/UserPasswordToken.php b/src/DataDomain/Business/src/Entity/UserPasswordToken.php new file mode 100644 index 0000000..5c6575b --- /dev/null +++ b/src/DataDomain/Business/src/Entity/UserPasswordToken.php @@ -0,0 +1,91 @@ +id = UuidGenerator::generate(); + + $now = new DateTime(); + $this->setCreatedAt($now); + $this->setUpdatedAt($now); + } + + + /** + * @ORM\PrePersist + * @ORM\PreUpdate + */ + public function updateTimestamps(): void { + $now = new DateTime(); + $this->setUpdatedAt($now); + } + + + public function getId(): UuidInterface { + return $this->id; + } + + public function getUserId(): UuidInterface { + return $this->userId; + } + + public function setUserId(UuidInterface $userId): void { + $this->userId = $userId; + } + + public function getUser(): User { + return $this->user; + } + + public function setUser(User $user): void { + $this->user = $user; + } + + public function getCreatedAt(): DateTime { + return $this->createdAt; + } + + public function setCreatedAt(DateTime $createdAt): void { + $this->createdAt = $createdAt; + } + + public function getUpdatedAt(): DateTime { + return $this->updatedAt; + } + + public function setUpdatedAt(DateTime $updatedAt): void { + $this->updatedAt = $updatedAt; + } +} \ No newline at end of file diff --git a/src/DataDomain/Business/src/Repository/MailRepository.php b/src/DataDomain/Business/src/Repository/MailRepository.php new file mode 100644 index 0000000..9252295 --- /dev/null +++ b/src/DataDomain/Business/src/Repository/MailRepository.php @@ -0,0 +1,9 @@ +