-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.php
106 lines (99 loc) · 4.11 KB
/
config.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
use Doctrine\DBAL\DriverManager;
use FastRoute\DataGenerator\GroupCountBased;
use FastRoute\RouteParser\Std;
use Go\Core\AspectContainer;
use Go\Core\AspectKernel;
use Go\Core\GoAspectContainer;
use Psr\Container\ContainerInterface;
use TuxBoy\Annotation\Length;
use TuxBoy\Annotation\Link;
use TuxBoy\Annotation\Set;
use TuxBoy\Annotation\Option;
use TuxBoy\Aspect\MaintainerAspect;
use TuxBoy\Database\Database;
use TuxBoy\Database\Maintainer;
use TuxBoy\Handler\HandlerInterface;
use TuxBoy\Priority;
use TuxBoy\Router\Router;
use TuxBoy\Session\PHPSession;
use TuxBoy\Session\SessionInterface;
use TuxBoy\Tools\Whoops;
use TuxBoy\Twig\FlashExtension;
use TuxBoy\Twig\FormExtension;
use TuxBoy\Twig\MenuExtension;
use TuxBoy\Twig\RouterTwigExtension;
use TuxBoy\Twig\TwigFactory;
use function DI\add;
use function DI\env;
use function DI\factory;
use function DI\get;
use function DI\object;
use function DI\string;
return [
Priority::APP => [
'dev' => true,
'environement' => env('ENV'),
'migration.auto' => true,
'basepath' => dirname(dirname(__DIR__)),
'aspect.appDir' => string('{basepath}/src/'),
'aspect.cacheDir' => false,
'db.name' => env('DB_NAME'),
'db.user' => env('DB_USER', 'root'),
'db.pass' => env('DB_PASS', 'root'),
'db.host' => env('DB_HOST', 'localhost'),
'db.driver' => env('DB_DRVER', 'pdo_mysql'),
\Doctrine\DBAL\Connection::class => function (ContainerInterface $container) {
return DriverManager::getConnection([
'dbname' => $container->get('db.name'),
'user' => $container->get('db.user'),
'password' => $container->get('db.pass'),
'host' => $container->get('db.host'),
'driver' => $container->get('db.driver'),
]);
},
Database::class => object()->constructor(get(\Doctrine\DBAL\Connection::class)),
AspectKernel::class => function (ContainerInterface $container) {
$applicationKernel = \TuxBoy\ApplicationApsect::getInstance();
$applicationKernel->init([
'debug' => $container->get('dev'),
'appDir' => $container->get('aspect.appDir'),
'cacheDir' => $container->get('aspect.cacheDir'),
'includePaths' => []
]);
return $applicationKernel;
},
AspectContainer::class => function (ContainerInterface $container) {
$kernel = $container->get(AspectKernel::class);
return $kernel->getContainer();
},
'twig.path' => \DI\add([string('{basepath}/res/views')]),
'twig.extensions' => add([
get(RouterTwigExtension::class),
get(FlashExtension::class),
get(FormExtension::class),
get(MenuExtension::class)
]),
'annotations' => add([
Set::class,
Length::class,
Option::class,
Link::class
]),
Std::class => object(),
GroupCountBased::class => object(),
\FastRoute\RouteCollector::class => object()->constructor(get(Std::class), get(GroupCountBased::class)),
Router::class => object()->constructor(get(\FastRoute\RouteCollector::class)),
Twig_Environment::class => factory(TwigFactory::class),
AspectContainer::class => object(GoAspectContainer::class),
'goaop.aspect' => add([
object(MaintainerAspect::class)
->constructor(get(Maintainer::class), get('dev'), get('migration.auto'))
]),
Maintainer::class => object()->constructorParameter('database', get(Database::class)),
HandlerInterface::class => object(Whoops::class),
SessionInterface::class => object(PHPSession::class)
],
Priority::CORE => [],
Priority::PLUGIN => []
];