/** * Extract conversation from route * @return NamedConversationEntity * @throws NotFoundException */ private function getConversation() : NamedConversationEntity { try { $conversation = $this->repository->getBySlug($this->params('slug')); } catch (NamedConversationNotFound $e) { throw new NotFoundException('No conversation with that name exists'); } return $conversation; }
public function get() : ResourceViewModel { if (!$this->isGranted(UserMessagePermissions::GET_ALL_CONVERSATIONS)) { throw new ForbiddenException('User must be logged on to retrieve conversations'); } $paginator = $this->conversationRepository->getAll(); $paginator->setCurrentPageNumber($this->params()->fromQuery('offset', 0)); $paginator->setItemCountPerPage($this->params()->fromQuery('limit', 25)); return new ResourceViewModel(['paginator' => $paginator], ['template' => 'named-conversations/conversations']); }