@@ -11,15 +11,18 @@ use Psr\Http\Message\ResponseInterface as Response; | |||
use Psr\Http\Message\ServerRequestInterface as Request; | |||
use Slim\Factory\AppFactory; | |||
use Blog\DB\User; | |||
use Blog\DB\Blog; | |||
use Blog\DB\Blog as BlogDB; | |||
use Blog\View\Twig; | |||
use Blog\DB\DB; | |||
use Blog\Model\Blog; | |||
require __DIR__ . '/../vendor/autoload.php'; | |||
#addNavbar(); | |||
$container = new Container(); | |||
AppFactory::setContainer($container); | |||
@@ -41,9 +44,9 @@ $container->set( | |||
); | |||
function addNavbar() | |||
function addNavbar($twig) | |||
{ | |||
$twig = $this->get('twig'); | |||
//$twig = $this->get('twig'); | |||
$urls = [ | |||
["link" => "https://www.google.be", "name" => "Google"], | |||
@@ -82,7 +85,7 @@ $app->get('/', function (Request $request, Response $response, array $args) { | |||
]; | |||
$twig = $this->get('twig'); | |||
addNavbar($twig); | |||
$err = ['type' => 'error', 'text' => "something's wrong"]; | |||
$twig->addMessage($err); |
@@ -2,10 +2,11 @@ | |||
namespace Blog\DB; | |||
use Blog\Model\Blog as BlogModel; | |||
class Blog extends DB | |||
{ | |||
public function createBlog($data) | |||
public function createBlog(BlogModel $data) | |||
{ | |||
$this->enableExceptions(false); | |||
$stmt = $this->prepare("INSERT INTO blogs (slug, title, content) VALUES (:slug, :title, :content)"); |
@@ -0,0 +1,58 @@ | |||
<?php | |||
namespace Blog\Model; | |||
use Blog\DB\Blog as BlogDB; | |||
use Blog\Model\Comment; | |||
class Blog | |||
{ | |||
protected $author; | |||
protected $title; | |||
protected $subtitle; | |||
protected $date; | |||
protected $content; | |||
protected $comments; | |||
protected $id; | |||
protected $slug; | |||
public function setAuthor($value) | |||
{ | |||
$this->author = $value; | |||
} | |||
public function setDate($value) | |||
{ | |||
$this->date = $value; | |||
} | |||
public function getDate() | |||
{ | |||
return $this->date; | |||
} | |||
public function getAuthor() | |||
{ | |||
return $this->author; | |||
} | |||
public function getComments() | |||
{ | |||
$comments = new Comment(); | |||
$this->comments = $comments->getComments($this->id); | |||
return $this->comments; | |||
} | |||
public function save() | |||
{ | |||
$db = new BlogDB(); | |||
$data = ["slug" => $this->slug, "title" => $this->title, "content" => $this->content]; | |||
//$db->createBlog($data); | |||
$db->createBlog($this); | |||
} | |||
public function getAssociative() | |||
{ | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
<?php | |||
namespace Blog\Model; | |||
class Comment | |||
{ | |||
protected $user; | |||
protected $date; | |||
protected $blogID; | |||
protected $comment; | |||
public function getComments($blogID) | |||
{ | |||
// vraag de DB om alle comments voro blogID | |||
return []; | |||
} | |||
} |