Add ViewHelper in view for injecting some basic classes in views

This commit is contained in:
Tim
2023-08-15 12:10:04 +02:00
parent de5ff3a2b9
commit 45797ba20a
12 changed files with 61 additions and 22 deletions

View File

@ -13,9 +13,9 @@ use Ardent\Undercurrent\View\ViewInterface;
class HelloWorldController
{
#[Route('/')]
public function index(): ResponseInterface
public function index(): ViewInterface
{
return new GenericResponse('Index, <a href="/hello">Hello</a>');
return new BaseView('/index.php');
}
#[Route('/error')]
@ -30,10 +30,10 @@ class HelloWorldController
return new GenericResponse('Hello World!');
}
#[Route('/view')]
public function view(): ViewInterface
#[Route('/view/{name}')]
public function view(string $name): ViewInterface
{
return new BaseView('/Template/home.php', ['message' => 'Hello World!']);
return new BaseView('/home.php', ['name' => $name]);
}
#[Route('/routes/{word}')]