file); // Prüft, ob der Ordner existiert. Wenn nicht, wird er angelegt. if (!is_dir($dir)) { mkdir($dir, 0777, true); } file_put_contents( $this->file, json_encode($articles, JSON_PRETTY_PRINT) ); } public function addArticle($title, $content, $author, $category, array $tags) { $articles = $this->getAllArticles(); $articles[] = [ //"id" => count($articles)+1, "title" => $title, "content" => $content, "author" => $author, "category" => $category, "tags" => $tags, //"creationDate" => date("Y-m-d H:i:s") ]; $this->saveArticle($articles); } public function updateArticle($id, $title, $content, $author) { // TODO: Implement updateArticle() method. } public function deleteArticle($id) { // TODO: Implement deleteArticle() method. } public function getArticle($id) { // TODO: Implement getArticle() method. } public function getAllArticles() { if (!file_exists($this->file)) { return []; } $json = file_get_contents($this->file); $articles = json_decode($json, true); return is_array($articles) ? $articles : []; } } ?>