/** * @return ResourceViewModel * * @throws ForbiddenException * @throws NotFoundException */ public function post() { if (!$this->isGranted(UserMessagePermissions::START_CONVERSATION)) { throw new ForbiddenException('User must be logged on to start a conversation'); } $values = $this->validateIncomingData(ConversationInputFilter::class); /* @var MessageUserInterface[] $user */ $users = $this->userRepository->findBy(['id' => $values['participants']]); $conversation = new GroupConversationEntity($users); $this->conversationService->create($conversation); return new ResourceViewModel(['conversation' => $conversation], ['template' => 'conversations/conversation']); }
/** * Update the name of a conversation * * @param NamedConversationEntity $instance * @param array $data */ public static function update(NamedConversationEntity $instance, array $data) { $instance->name = $data['name']; $instance->slug = ConversationService::slugify($data['name']); $instance->updatedAt = new DateTime(); }