You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
944B

  1. <?php
  2. namespace domain\User\UserMessage;
  3. use domain\_\AbstractManager;
  4. use domain\User\User\User;
  5. class UserMessageManager extends AbstractManager
  6. {
  7. protected UserMessageBuilder $userMessageBuilder;
  8. public function loadDependencies(): void
  9. {
  10. $this->userMessageBuilder = $this->loadService(UserMessageBuilder::class);
  11. }
  12. public function createUserMessage(User $user, string $message, User $createdBy): UserMessage
  13. {
  14. $userMessage = $this->userMessageBuilder->instanciateUserMessage($user, $createdBy);
  15. $userMessage->setMessage($message);
  16. $userMessage->save();
  17. return $userMessage;
  18. }
  19. public function deleteUserMessage(UserMessage $userMessage): bool
  20. {
  21. return $userMessage->delete();
  22. }
  23. public function readUserMessage(UserMessage $userMessage): bool
  24. {
  25. $userMessage->setReadAt(new \DateTime());
  26. return $userMessage->save();
  27. }
  28. }