96 lines
2.9 KiB
PHP
96 lines
2.9 KiB
PHP
<?php
|
|
require_once "Article.php";
|
|
|
|
class NotFoundException extends Exception {}
|
|
class UnauthorizedAccessException extends Exception {}
|
|
class InternalServerErrorException extends Exception {}
|
|
|
|
/**
|
|
* Die Klasse beinhaltet alle Methoden für die Operation mit den Artikel-Daten.
|
|
*
|
|
* @author Niklas Ortmann
|
|
*/
|
|
interface ArticleManagerDAO
|
|
{
|
|
/**
|
|
* Ein angemeldeter Nutzer erstellt einen neuen Beitrag.
|
|
* @param $title string Titel des Beitrags
|
|
* @param $content string Inhalt des Beitrags
|
|
* @param $author string der Autor des des Beitrages NID
|
|
* @param $category string Kategorie des Beitrages
|
|
* @param $tags string optionale Schlagworte für eine bessere Suche
|
|
*
|
|
* @throws InternalServerErrorException
|
|
*/
|
|
public function addArticle($title, $content, $author, $category, $tags);
|
|
|
|
/**
|
|
* Ändert den gespeicherten Beitrag eines übergebenen Beitrags und eines Autors.
|
|
* Es wird geprüft, ob der zu änderne Beitrag existiert und ob der übergebene Autor der Autor des originalen
|
|
* Beitrages ist.
|
|
* @param $id
|
|
* @param $article
|
|
* @param $author
|
|
* @return void
|
|
*
|
|
* @throws InternalServerErrorException
|
|
* @throws NotFoundException
|
|
* @throws UnauthorizedAccessException
|
|
*/
|
|
public function updateArticle($id, $article, $author);
|
|
|
|
/**
|
|
* Löscht einen Beitrag aus übergebener ID und dem Nutzer, der die Löschung ausführt.
|
|
* @param $id
|
|
* @param $author
|
|
* @return void
|
|
* @throws InternalServerErrorException
|
|
* @throws NotFoundException
|
|
* @throws UnauthorizedAccessException
|
|
*/
|
|
public function deleteArticle($id, $author);
|
|
|
|
/**
|
|
* Beitrag aufrufen.
|
|
* $id ID des Beitrags
|
|
*
|
|
* @return Article
|
|
* @throws InternalServerErrorException
|
|
*/
|
|
public function getArticle($id);
|
|
|
|
/**
|
|
* Alle Beiträge aufrufen.
|
|
*
|
|
* @throws InternalServerErrorException
|
|
*/
|
|
public function getAllArticles();
|
|
|
|
/**
|
|
* Gibt alle Beiträge eines Nutzer mit einer gegebenen ID aus.
|
|
* @param $author
|
|
* @return Article[]
|
|
* @throws InternalServerErrorException
|
|
*/
|
|
public function getArticlesByAuthor($author);
|
|
|
|
/**
|
|
* Durchsucht die vorhandenen Beiträge nach einem bestimmten Suchbegriff.
|
|
* Die Suche prüft, ob das übergebene Keyword im Titel oder im Inhalt eines Beitrags vorkommt.
|
|
* (Unabhängig von Groß-und Kleinschreibung)
|
|
* @param string $keyword Der eingegebene Suchbegriff.
|
|
* @return array Ein Array von Artikeln ,die dem Suchkriterium entsprechen. Wenn nichts gefunden wird, ein leeres Array.
|
|
*/
|
|
public function search(string $keyword): array;
|
|
|
|
/**
|
|
* Gibt alle Beiträge einer gegebenen Kategorie aus.
|
|
* @param $category
|
|
* @return mixed
|
|
* @throws InternalServerErrorException
|
|
*/
|
|
public function getArticlesByCategory($category);
|
|
|
|
|
|
}
|
|
?>
|