dependencies.php 6.65 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
<?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'];
François Agneray's avatar
François Agneray committed
23
24
25
26
27
28
    $devMode = boolval($settings['dev_mode']);
    $proxyDir = getcwd() . '/../doctrine-proxy';
    $cache = null;
    if ($devMode == false) {
        $cache = new \Doctrine\Common\Cache\ApcuCache();
    }
29
30
    $dc = \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration(
        array('src/Entity'),
François Agneray's avatar
François Agneray committed
31
32
33
        $devMode,
        $proxyDir,
        $cache
34
    );
François Agneray's avatar
François Agneray committed
35
36
37
38
    $dc->setAutogenerateProxyClasses(false);
    
    if ($devMode) {
        $dc->setSQLLogger(new \Doctrine\DBAL\Logging\DebugStack());
39
    } else {
François Agneray's avatar
François Agneray committed
40
        $dc->setQueryCacheImpl($cache);
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
    }
    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();
});

59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
$container->set('App\Action\SelectListAction', function (ContainerInterface $c) {
    return new App\Action\SelectListAction($c->get('em'));
});

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

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

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

75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
$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'));
});

95
96
97
98
99
100
101
102
$container->set('App\Action\GroupListAction', function (ContainerInterface $c) {
    return new App\Action\GroupListAction($c->get('em'));
});

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

103
104
105
106
107
108
109
110
$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'));
});

111
112
113
114
115
116
117
118
$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'));
});

119
120
121
122
$container->set('App\Action\DatasetFamilyListAction', function (ContainerInterface $c) {
    return new App\Action\DatasetFamilyListAction($c->get('em'));
});

123
$container->set('App\Action\DatasetListByInstanceAction', function (ContainerInterface $c) {
124
    return new App\Action\DatasetListByInstanceAction($c->get('em'), $c->get(SETTINGS)['token']);
125
126
});

127
128
129
130
$container->set('App\Action\DatasetFamilyAction', function (ContainerInterface $c) {
    return new App\Action\DatasetFamilyAction($c->get('em'));
});

131
132
133
134
135
$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) {
136
    return new App\Action\DatasetAction($c->get('em'));
137
138
});

139
$container->set('App\Action\CriteriaFamilyListAction', function (ContainerInterface $c) {
140
    return new App\Action\CriteriaFamilyListAction($c->get('em'));
141
142
143
});

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

147
$container->set('App\Action\OutputFamilyListAction', function (ContainerInterface $c) {
148
    return new App\Action\OutputFamilyListAction($c->get('em'));
149
150
});

François Agneray's avatar
François Agneray committed
151
$container->set('App\Action\OutputFamilyAction', function (ContainerInterface $c) {
152
153
154
155
156
    return new App\Action\OutputFamilyAction($c->get('em'));
});

$container->set('App\Action\OutputCategoryListByDatasetAction', function (ContainerInterface $c) {
    return new App\Action\OutputCategoryListByDatasetAction($c->get('em'));
François Agneray's avatar
François Agneray committed
157
158
159
160
161
162
163
164
165
166
});

$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'));
});

167
168
169
170
171
172
173
174
$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'));
});

François Agneray's avatar
François Agneray committed
175
176
177
178
$container->set('App\Action\AttributeDistinctAction', function (ContainerInterface $c) {
    return new App\Action\AttributeDistinctAction($c->get('em'), new App\Utils\DBALConnectionFactory());
});

179
180
181
182
$container->set('App\Action\SearchAction', function (ContainerInterface $c) {
    return new App\Action\SearchAction(
        $c->get('em'),
        new App\Utils\DBALConnectionFactory(),
183
184
        new App\Utils\Operator\OperatorFactory(),
        $c->get(SETTINGS)['token']
185
186
187
    );
});

François Agneray's avatar
François Agneray committed
188
$container->set('App\Action\DownloadFileAction', function (ContainerInterface $c) {
189
    return new App\Action\DownloadFileAction($c->get('em'), $c->get(SETTINGS)['token']);
François Agneray's avatar
François Agneray committed
190
});