dependencies.php 5.4 KB
Newer Older
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
<?php

/*
 * This file is part of Anis Server.
 *
 * (c) Laboratoire d'Astrophysique de Marseille / CNRS
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
declare(strict_types=1);

use Psr\Container\ContainerInterface;

// Load settings
$container->set(SETTINGS, function () {
    return include __DIR__ . '/../app/settings.php';
});

// Doctrine factory
$container->set('em', function (ContainerInterface $c) {
    $settings = $c->get(SETTINGS)['database'];
    $dc = \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration(
        array('src/Entity'),
        $settings['dev_mode']
    );
    $dc->setProxyDir($settings['path_proxy']);
    if ($settings['dev_mode']) {
        $dc->setAutoGenerateProxyClasses(true);
    } else {
        $dc->setAutoGenerateProxyClasses(false);
    }
    return \Doctrine\ORM\EntityManager::create($settings['connection_options'], $dc);
});

// Monolog factory
$container->set('logger', function (ContainerInterface $c) {
    $loggerSettings = $c->get('settings')['logger'];
    $logger = new \Monolog\Logger($loggerSettings['name']);
    $logger->pushProcessor(new \Monolog\Processor\UidProcessor());
    $logger->pushHandler(new \Monolog\Handler\StreamHandler($loggerSettings['path'], $loggerSettings['level']));
    return $logger;
});

// Actions
$container->set('App\Action\RootAction', function () {
    return new App\Action\RootAction();
});

$container->set('App\Action\DatabaseListAction', function (ContainerInterface $c) {
    return new App\Action\DatabaseListAction($c->get('em'));
});

$container->set('App\Action\DatabaseAction', function (ContainerInterface $c) {
    return new App\Action\DatabaseAction($c->get('em'));
});

$container->set('App\Action\TableListAction', function (ContainerInterface $c) {
    return new App\Action\TableListAction($c->get('em'), new App\Utils\DBALConnectionFactory());
});

$container->set('App\Action\ProjectListAction', function (ContainerInterface $c) {
    return new App\Action\ProjectListAction($c->get('em'));
});

$container->set('App\Action\ProjectAction', function (ContainerInterface $c) {
    return new App\Action\ProjectAction($c->get('em'));
});

$container->set('App\Action\FamilyListAction', function (ContainerInterface $c) {
    return new App\Action\FamilyListAction($c->get('em'));
});

$container->set('App\Action\FamilyAction', function (ContainerInterface $c) {
    return new App\Action\FamilyAction($c->get('em'));
});

78
79
80
81
82
83
84
85
$container->set('App\Action\InstanceListAction', function (ContainerInterface $c) {
    return new App\Action\InstanceListAction($c->get('em'));
});

$container->set('App\Action\InstanceAction', function (ContainerInterface $c) {
    return new App\Action\InstanceAction($c->get('em'));
});

86
87
88
89
$container->set('App\Action\DatasetFamilyListAction', function (ContainerInterface $c) {
    return new App\Action\DatasetFamilyListAction($c->get('em'));
});

90
91
92
93
$container->set('App\Action\DatasetListByInstanceAction', function (ContainerInterface $c) {
    return new App\Action\DatasetListByInstanceAction($c->get('em'));
});

94
95
96
97
$container->set('App\Action\DatasetFamilyAction', function (ContainerInterface $c) {
    return new App\Action\DatasetFamilyAction($c->get('em'));
});

98
99
100
101
102
103
104
105
$container->set('App\Action\DatasetListAction', function (ContainerInterface $c) {
    return new App\Action\DatasetListAction($c->get('em'), new App\Utils\DBALConnectionFactory());
});

$container->set('App\Action\DatasetAction', function (ContainerInterface $c) {
    return new App\Action\DatasetAction($c->get('em'), new App\Utils\DBALConnectionFactory());
});

106
107
108
109
110
111
112
113
$container->set('App\Action\CriteriaFamilyListAction', function (ContainerInterface $c) {
    return new App\Action\CriteriaFamilyListAction($c->get('em'), new App\Utils\DBALConnectionFactory());
});

$container->set('App\Action\CriteriaFamilyAction', function (ContainerInterface $c) {
    return new App\Action\CriteriaFamilyAction($c->get('em'), new App\Utils\DBALConnectionFactory());
});

114
115
116
117
$container->set('App\Action\OutputFamilyListAction', function (ContainerInterface $c) {
    return new App\Action\OutputFamilyListAction($c->get('em'), new App\Utils\DBALConnectionFactory());
});

François Agneray's avatar
François Agneray committed
118
119
120
121
122
123
124
125
126
127
128
129
$container->set('App\Action\OutputFamilyAction', function (ContainerInterface $c) {
    return new App\Action\OutputFamilyAction($c->get('em'), new App\Utils\DBALConnectionFactory());
});

$container->set('App\Action\OutputCategoryListAction', function (ContainerInterface $c) {
    return new App\Action\OutputCategoryListAction($c->get('em'));
});

$container->set('App\Action\OutputCategoryAction', function (ContainerInterface $c) {
    return new App\Action\OutputCategoryAction($c->get('em'));
});

130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
$container->set('App\Action\AttributeListAction', function (ContainerInterface $c) {
    return new App\Action\AttributeListAction($c->get('em'));
});

$container->set('App\Action\AttributeAction', function (ContainerInterface $c) {
    return new App\Action\AttributeAction($c->get('em'));
});

$container->set('App\Action\SearchAction', function (ContainerInterface $c) {
    return new App\Action\SearchAction(
        $c->get('em'),
        new App\Utils\DBALConnectionFactory(),
        new App\Utils\Operator\OperatorFactory()
    );
});

// Middlewares
$container->set('App\Middleware\AuthorizationMiddleware', function (ContainerInterface $c) {
    return new App\Middleware\AuthorizationMiddleware($c->get('em'), $c->get(SETTINGS)['token_options']);
});