diff --git a/.gitignore b/.gitignore index 61433bc..3da5c49 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ cache/* vendor/ webcron.old/config.inc.php \.idea/ -.env \ No newline at end of file +.env +storage/database.sqlite \ No newline at end of file diff --git a/lib/Framework/Controller.php b/lib/Framework/Controller.php index 48c6e8f..62146f5 100644 --- a/lib/Framework/Controller.php +++ b/lib/Framework/Controller.php @@ -18,8 +18,7 @@ abstract class Controller public function __construct(Request $request, Kernel $kernel) { - $loader = new FilesystemLoader([$kernel->getTemplateDir()]); - $this->twig = new Environment($loader); + $this->twig = new Twig($kernel); $this->request = $request; $this->kernel = $kernel; } diff --git a/lib/Framework/Twig.php b/lib/Framework/Twig.php new file mode 100644 index 0000000..db791ec --- /dev/null +++ b/lib/Framework/Twig.php @@ -0,0 +1,37 @@ +getTemplateDir()]); + $this->environment = new Environment($loader); + $this->kernel = $kernel; + $this->addFunctions(); + } + + public function render(string $template, array $vars = []): string + { + return $this->environment->render($template, $vars); + } + + public function addFunctions() + { + $path = new TwigFunction('path', function(string $route) { + return $this->kernel->getRouter()->getUrlForRoute($route); + }); + $this->environment->addFunction($path); + } + +} \ No newline at end of file diff --git a/templates/security/login.html.twig b/templates/security/login.html.twig index a944f43..e7bf721 100644 --- a/templates/security/login.html.twig +++ b/templates/security/login.html.twig @@ -17,7 +17,7 @@

Webcron management

-
+ {% if not error == "" %}
×