/**
  * Extract message from route
  *
  * @return MessageEntity
  * @throws \ZfrRest\Http\Exception\Client\NotFoundException
  */
 private function getMessage() : MessageEntity
 {
     try {
         $message = $this->messageRepository->getById((int) $this->params('message_id'));
     } catch (MessageNotFound $e) {
         throw new NotFoundException('Message does not exist');
     }
     return $message;
 }
 /**
  * @return ResourceViewModel
  * @throws NotFoundException
  * @throws ForbiddenException
  */
 public function get()
 {
     $conversation = $this->getConversation();
     if (!$this->isGranted(UserMessagePermissions::GET_CONVERSATION, $conversation)) {
         throw new ForbiddenException('User does not have permission to view this conversation');
     }
     $paginator = $this->messageRepository->getByConversation($conversation);
     $paginator->setCurrentPageNumber($this->params()->fromQuery('offset', 1));
     $paginator->setItemCountPerPage($this->params()->fromQuery('limit', 50));
     return new ResourceViewModel(['paginator' => $paginator], ['template' => 'messages/messages']);
 }