[+] Добавлен шаблонизатор твиг и роутинг под него
This commit is contained in:
1 parent
69243e97f1
commit
4e8ea1514e
14 files changed
+395
-18
No files matched your search
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Core;
|
||||
|
||||
class App
|
||||
{
|
||||
public static function index()
|
||||
{
|
||||
global $twig;
|
||||
$navbarItems = [
|
||||
['name' => 'Главная', 'url' => '/', 'active' => true],
|
||||
['name' => 'Админка', 'url' => '/admin', 'active' => false],
|
||||
['name' => 'Командная PHP строка', 'url' => '/phpcmd.php', 'active' => false],
|
||||
['name' => 'Тест', 'url' => '/test', 'active' => false],
|
||||
];
|
||||
echo $twig->render('index.twig', ['navbarItems' => $navbarItems, 'name' => 'Roman Grinko']);
|
||||
}
|
||||
|
||||
public static function test(int $id = 1)
|
||||
{
|
||||
global $twig;
|
||||
$navbarItems = [
|
||||
['name' => 'Главная', 'url' => '/', 'active' => true],
|
||||
['name' => 'Админка', 'url' => '/admin', 'active' => false],
|
||||
['name' => 'Командная PHP строка', 'url' => '/phpcmd.php', 'active' => false],
|
||||
['name' => 'Тест', 'url' => '/test', 'active' => false],
|
||||
];
|
||||
|
||||
$res = (new \Core\Models\User($id))->getAllUserData();
|
||||
echo $twig->render('test.twig', ['navbarItems' => $navbarItems, 'userId' => $id, 'res' => print_r($res, true)]);
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@
|
||||
*/
|
||||
public static function init(string $dir, $enabled = true): void
|
||||
{
|
||||
self::$cacheDir = $dir;
|
||||
self::$cacheDir = $dir . '/';
|
||||
self::$cacheEnabled = $enabled;
|
||||
}
|
||||
|
||||
|
||||
@@ -359,4 +359,16 @@
|
||||
}
|
||||
return $table;
|
||||
}
|
||||
|
||||
|
||||
public static function showPage()
|
||||
{
|
||||
$loader = new \Twig\Loader\FilesystemLoader(PATH_TO_TEMPLATES);
|
||||
$twig = new \Twig\Environment($loader, [
|
||||
'cache' => CACHE_DIR,
|
||||
]);
|
||||
|
||||
echo $twig->render('index.tpl', ['name' => 'Roman']);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Core\Models;
|
||||
|
||||
|
||||
class Router
|
||||
{
|
||||
|
||||
|
||||
Reference in new issue
Block a user