add Twig for template rendering
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
7cc2d40660
commit
92a4d2fcf8
7 changed files with 333 additions and 81 deletions
|
|
@ -5,9 +5,13 @@ namespace NoteCat;
|
|||
|
||||
use DI\Container;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Slim\Views\Twig;
|
||||
|
||||
class Dependencies
|
||||
{
|
||||
private const TWIG = 'view';
|
||||
private const TWIG_TEMPLATE_DIR = __DIR__ . '/../templates';
|
||||
|
||||
public static function createContainer(): Container
|
||||
{
|
||||
$container = new Container();
|
||||
|
|
@ -15,6 +19,7 @@ class Dependencies
|
|||
// Controllers
|
||||
$container->set(HelloWorldController::class, function (ContainerInterface $c) {
|
||||
return new HelloWorldController(
|
||||
$c->get(self::TWIG),
|
||||
$c->get(HelloWorld::class)
|
||||
);
|
||||
});
|
||||
|
|
@ -24,6 +29,12 @@ class Dependencies
|
|||
return new HelloWorld();
|
||||
});
|
||||
|
||||
$container->set(self::TWIG, function (ContainerInterface $c) {
|
||||
// TODO cache
|
||||
$twigSettings = [];
|
||||
return Twig::create(self::TWIG_TEMPLATE_DIR, $twigSettings);
|
||||
});
|
||||
|
||||
return $container;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue