Add boilerplate code, Docker environment, Makefile etc.
This commit is contained in:
parent
1e9d351173
commit
114a67dbe4
21 changed files with 3766 additions and 0 deletions
41
src/Dependencies.php
Normal file
41
src/Dependencies.php
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MailAccountAdmin;
|
||||
|
||||
use DI\Container;
|
||||
use MailAccountAdmin\Login\LoginController;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Slim\Views\Twig;
|
||||
|
||||
class Dependencies
|
||||
{
|
||||
private const SETTINGS = 'settings';
|
||||
private const TWIG = 'view';
|
||||
private const TWIG_TEMPLATE_DIR = __DIR__ . '/../templates';
|
||||
|
||||
public static function createContainer(Settings $settings): Container
|
||||
{
|
||||
$container = new Container();
|
||||
|
||||
// App settings
|
||||
$container->set(self::SETTINGS, $settings);
|
||||
|
||||
// Twig template engine
|
||||
$container->set(self::TWIG, function (ContainerInterface $c) {
|
||||
/** @var Settings $settings */
|
||||
$settings = $c->get(self::SETTINGS);
|
||||
|
||||
return Twig::create(self::TWIG_TEMPLATE_DIR, $settings->getTwigSettings());
|
||||
});
|
||||
|
||||
// Login, registration, authentication
|
||||
$container->set(LoginController::class, function (ContainerInterface $c) {
|
||||
return new LoginController(
|
||||
$c->get(self::TWIG)
|
||||
);
|
||||
});
|
||||
|
||||
return $container;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue