updateArticle
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user