|
|
@@ -24,8 +24,6 @@ $twig = new \Twig\Environment($loader, []); |
|
|
|
|
|
|
|
//$db = new DB(); |
|
|
|
ini_set('display_errors', 'Off'); |
|
|
|
|
|
|
|
|
|
|
|
function addNavbar($response) |
|
|
|
{ |
|
|
|
|
|
|
@@ -37,14 +35,12 @@ function addNavbar($response) |
|
|
|
} |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
function addFooter($response) |
|
|
|
{ |
|
|
|
$response->getBody()->write('<div>Privacy statement | Cookie Policy | Contact</div>'); |
|
|
|
$response->getBody()->write("</body></html>"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
function init() |
|
|
|
{ |
|
|
|
$art1 = ["slug" => "artikel-1", "title" => "Dit is titel 1", "content" => "Lorem ipsum 1"]; |
|
|
@@ -54,15 +50,20 @@ function init() |
|
|
|
$_SESSION['blogs'] = [$art1, $art2, $art3, $art4]; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$app->get('/', function (Request $request, Response $response, array $args) { |
|
|
|
if (!isset($_SESSION['blogs'])) { |
|
|
|
init(); |
|
|
|
} |
|
|
|
|
|
|
|
$vars = [ |
|
|
|
"key" => "value", |
|
|
|
'key2' => ["val1", "val2", "val3"], |
|
|
|
"key3" => ["x1" => "y1", "x2" => "y2"] |
|
|
|
]; |
|
|
|
|
|
|
|
global $twig; |
|
|
|
$template = $twig->load('index.html.twig'); |
|
|
|
$a = $template->render(); |
|
|
|
$a = $template->render($vars); |
|
|
|
$response->getBody()->write($a); |
|
|
|
return $response; |
|
|
|
}); |