Kategorien nicht statisch sondern dynamisch

This commit is contained in:
2026-06-03 19:29:29 +02:00
parent 9c3ebc9877
commit e772a8b57f
6 changed files with 138 additions and 52 deletions
+21
View File
@@ -44,5 +44,26 @@ class ArticleManager extends LocalArticleManager
return $articleManager;
}
public function getArticlesByCategory($category)
{
$articles = $this->getAllArticles();
$filteredArticles = [];
foreach ($articles as $article) {
if (isset($article['category']) && $article['category'] == $category) {
$filteredArticles[] = new Article(
intval($article['id']),
$article['title'],
$article['content'],
$article['author'],
$article['category'],
$article['tags'],
$article['creationDate']
);
}
}
return $filteredArticles;
}
}
+7
View File
@@ -85,6 +85,13 @@ interface ArticleManagerDAO
*/
public function search(string $keyword): array;
/**
* Gibt alle Beiträge einer gegebenen Kategorie aus.
* @param $category
* @return mixed
*/
public function getArticlesByCategory($category);
}
?>