sendJson($this->newsDao->getNews()); } function getDoNewsList(int $newsId): void { $comment = $this->newsDao->getNewsById($newsId); if($comment === null) { throw new PageNotFoundException(); } else { $this->sendJson($comment); } } /** * Speichere eine News. * * @return void * @throws StatusException */ function postDoNews(ParamBody $body): void { $httpData = $body->parseJsonToHttpData(); $title = $httpData->reqString('title'); $description = $httpData->reqString('description'); $text = $httpData->reqString('text'); $newsToAdd = $this->createNews($title, $description, $text); $this->beginTransaction(); $this->newsDao->saveNews($newsToAdd); $this->commit(); $this->sendJson($newsToAdd); } function createNews($title, $description, $text): News { $news = new News(); $news->title = $title; $news->description = $description; $news->text = $text; return $news; } }