/** * Retrieves post with id $id or throws an exception if it doesn't exist. * * @param int $id A Post identifier * * @return Post * * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException */ protected function getPost($id) { $post = $this->postManager->find($id); if (null === $post) { throw new NotFoundHttpException(sprintf('Post (%d) not found', $id)); } return $post; }