updateArticle

This commit is contained in:
2026-06-01 09:11:11 +02:00
parent 2cd68873de
commit 2a3e73d409
3 changed files with 35 additions and 16 deletions
+8 -4
View File
@@ -65,32 +65,36 @@ class LocalArticleManager implements ArticleManagerDAO {
public function updateArticle($id, $article, $author)
{
if (empty($article)) {
// TODO: Implement Exception.
return;
}
// Berechtigungsprüfung:
if ($article->getAuthor() !== $author) {
// TODO: Implement Exception (z.B. throw new Exception("Nicht autorisiert"));
// TODO: Implement Exception.
return;
}
// Beitrag aktualisieren:
$articles = $this->getAllArticles();
$updated = false;
// Beitrag aktualisieren:
foreach ($articles as $index => $storedArticle) {
if (isset($storedArticle['id']) && $storedArticle['id'] == $id) {
$articles[$index] = [
"id" => $id,
"title" => $article->getTitle(),
"content" => $article->getContent(),
"author" => $article->getAuthor(),
"author" => $author,
"category" => $article->getCategory(),
"tags" => $article->getTags(),
"creationDate" => $article->getCreationDate() // Behält das originale Erstelldatum bei
"creationDate" => $article->getCreationDate()
];
$updated = true;
break;
}else{
// TODO: Implement Exception.
return;
}
}