|
1234567891011121314151617181920212223242526272829303132333435 |
- <?php
-
- namespace domain\User\UserMessage;
-
- use domain\_\AbstractManager;
- use domain\User\User\User;
-
- class UserMessageManager extends AbstractManager
- {
- protected UserMessageBuilder $userMessageBuilder;
-
- public function loadDependencies(): void
- {
- $this->userMessageBuilder = $this->loadService(UserMessageBuilder::class);
- }
-
- public function createUserMessage(User $user, string $message, User $createdBy): UserMessage
- {
- $userMessage = $this->userMessageBuilder->instanciateUserMessage($user, $createdBy);
- $userMessage->setMessage($message);
- $userMessage->save();
- return $userMessage;
- }
-
- public function deleteUserMessage(UserMessage $userMessage): bool
- {
- return $userMessage->delete();
- }
-
- public function readUserMessage(UserMessage $userMessage): bool
- {
- $userMessage->setReadAt(new \DateTime());
- return $userMessage->save();
- }
- }
|