updateArticle - Exeptions
This commit is contained in:
@@ -61,18 +61,16 @@ class LocalArticleManager implements ArticleManagerDAO {
|
||||
|
||||
$this->saveArticle($articles);
|
||||
}
|
||||
|
||||
|
||||
public function updateArticle($id, $article, $author)
|
||||
{
|
||||
if (empty($article)) {
|
||||
// TODO: Implement Exception.
|
||||
return;
|
||||
throw new InvalidArgumentException("Der Beitrag darf nicht leer sein.");
|
||||
}
|
||||
|
||||
// Berechtigungsprüfung:
|
||||
if ($article->getAuthor() !== $author) {
|
||||
// TODO: Implement Exception.
|
||||
return;
|
||||
throw new UnauthorizedAccessException("Sie sind nicht berechtigt, diesen Artikel zu bearbeiten.");
|
||||
}
|
||||
|
||||
// Beitrag aktualisieren:
|
||||
@@ -92,15 +90,15 @@ class LocalArticleManager implements ArticleManagerDAO {
|
||||
];
|
||||
$updated = true;
|
||||
break;
|
||||
}else{
|
||||
// TODO: Implement Exception.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Nur speichern, wenn Beitrag geändert wurde:
|
||||
if ($updated) {
|
||||
$this->saveArticle($articles);
|
||||
} else {
|
||||
throw new NotFoundException("Ein Artikel mit der ID". $id . " wurde nicht gefunden.");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user