Update LocalArticleManager.php
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user