Beitrag erstellen #13

Merged
niklas.ortmann merged 164 commits from Beitrag-erstellen into dev 2026-05-29 13:22:11 +02:00
Showing only changes of commit e0835b70df - Show all commits
+1 -9
View File
@@ -9,7 +9,7 @@ require_once 'Article.php';
*/ */
class LocalArticleManager implements ArticleManagerDAO { class LocalArticleManager implements ArticleManagerDAO {
private $file = '../../data/articles.json'; private $file = 'data/articles.json';
private static $instance = null; private static $instance = null;
/** /**
@@ -32,18 +32,10 @@ class LocalArticleManager implements ArticleManagerDAO {
*/ */
public function saveArticle($articles) public function saveArticle($articles)
{ {
$dir = dirname($this->file);
// Prüft, ob der Ordner existiert. Wenn nicht, wird er angelegt.
if (!is_dir($dir)) {
mkdir($dir, 0777, true);
}
file_put_contents( file_put_contents(
$this->file, $this->file,
json_encode($articles, JSON_PRETTY_PRINT) json_encode($articles, JSON_PRETTY_PRINT)
); );
} }
public function addArticle($title, $content, $author, $category, array $tags) public function addArticle($title, $content, $author, $category, array $tags)