您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

UserMessageManager.php 944B

1234567891011121314151617181920212223242526272829303132333435
  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. }