/**
  * @return ResourceViewModel
  *
  * @throws ForbiddenException
  * @throws NotFoundException
  */
 public function post() : ResourceViewModel
 {
     if (!$this->isGranted(UserMessagePermissions::START_NAMED_CONVERSATION)) {
         throw new ForbiddenException('You don\'t have permission to start a named conversation');
     }
     $values = $this->validateIncomingData(NamedConversationInputFilter::class);
     $conversation = new NamedConversationEntity($values);
     $this->conversationService->create($conversation);
     return new ResourceViewModel(['conversation' => $conversation], ['template' => 'named-conversations/conversation']);
 }
 public function removeParticipantAction()
 {
     $conversation = $this->getConversation();
     if (!$this->isGranted(UserMessagePermissions::REMOVE_PARTICIPANT, $conversation)) {
         throw new ForbiddenException('User does not have permission to remove a user from this conversation');
     }
     $data = $this->validate();
     $user = $this->getParticipant($data);
     $this->conversationService->removeParticipant($conversation, $user);
     return $this->getResponse()->setStatusCode(Response::STATUS_CODE_204);
 }
 public function put() : ResourceViewModel
 {
     $conversation = $this->getConversation();
     if (!$this->isGranted(UserMessagePermissions::UPDATE_NAMED_CONVERSATION, $conversation)) {
         throw new ForbiddenException('User is not allowed to update the name of this conversation');
     }
     $values = $this->validateIncomingData(NamedConversationInputFilter::class);
     NamedConversationEntity::update($conversation, $values);
     $this->service->update($conversation);
     return new ResourceViewModel(['conversation' => $conversation], ['template' => 'named-conversations/conversation']);
 }