|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* sysPass |
|
4
|
|
|
* |
|
5
|
|
|
* @author nuxsmin |
|
6
|
|
|
* @link https://syspass.org |
|
7
|
|
|
* @copyright 2012-2019, Rubén Domínguez nuxsmin@$syspass.org |
|
8
|
|
|
* |
|
9
|
|
|
* This file is part of sysPass. |
|
10
|
|
|
* |
|
11
|
|
|
* sysPass is free software: you can redistribute it and/or modify |
|
12
|
|
|
* it under the terms of the GNU General Public License as published by |
|
13
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
|
14
|
|
|
* (at your option) any later version. |
|
15
|
|
|
* |
|
16
|
|
|
* sysPass is distributed in the hope that it will be useful, |
|
17
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19
|
|
|
* GNU General Public License for more details. |
|
20
|
|
|
* |
|
21
|
|
|
* You should have received a copy of the GNU General Public License |
|
22
|
|
|
* along with sysPass. If not, see <http://www.gnu.org/licenses/>. |
|
23
|
|
|
*/ |
|
24
|
|
|
|
|
25
|
|
|
use Monolog\Logger; |
|
26
|
|
|
use PHPMailer\PHPMailer\PHPMailer; |
|
27
|
|
|
use Psr\Container\ContainerInterface; |
|
28
|
|
|
use SP\Config\Config; |
|
29
|
|
|
use SP\Config\ConfigData; |
|
30
|
|
|
use SP\Core\Acl\Acl; |
|
31
|
|
|
use SP\Core\Acl\Actions; |
|
32
|
|
|
use SP\Core\Context\ContextInterface; |
|
33
|
|
|
use SP\Core\Context\SessionContext; |
|
34
|
|
|
use SP\Core\Context\StatelessContext; |
|
35
|
|
|
use SP\Core\MimeTypes; |
|
36
|
|
|
use SP\Core\UI\Theme; |
|
37
|
|
|
use SP\Core\UI\ThemeInterface; |
|
38
|
|
|
use SP\Http\Client; |
|
39
|
|
|
use SP\Http\Request; |
|
40
|
|
|
use SP\Services\Account\AccountAclService; |
|
41
|
|
|
use SP\Storage\Database\DatabaseConnectionData; |
|
42
|
|
|
use SP\Storage\Database\DBStorageInterface; |
|
43
|
|
|
use SP\Storage\Database\MySQLHandler; |
|
44
|
|
|
use SP\Storage\File\FileCache; |
|
45
|
|
|
use SP\Storage\File\FileHandler; |
|
46
|
|
|
use SP\Storage\File\XmlHandler; |
|
47
|
|
|
use function DI\autowire; |
|
48
|
|
|
use function DI\create; |
|
49
|
|
|
use function DI\factory; |
|
50
|
|
|
use function DI\get; |
|
51
|
|
|
|
|
52
|
|
|
return [ |
|
53
|
|
|
Request::class => create(Request::class) |
|
54
|
|
|
->constructor(\Klein\Request::createFromGlobals()), |
|
55
|
|
|
ContextInterface::class => function (ContainerInterface $c) { |
|
56
|
|
|
switch (APP_MODULE) { |
|
57
|
|
|
case 'web': |
|
58
|
|
|
return $c->get(SessionContext::class); |
|
59
|
|
|
default: |
|
60
|
|
|
return $c->get(StatelessContext::class); |
|
61
|
|
|
} |
|
62
|
|
|
}, |
|
63
|
|
|
Config::class => function (ContainerInterface $c) { |
|
64
|
|
|
return new Config( |
|
65
|
|
|
new XmlHandler(new FileHandler(CONFIG_FILE)), |
|
66
|
|
|
new FileCache(Config::CONFIG_CACHE_FILE), |
|
67
|
|
|
$c); |
|
68
|
|
|
}, |
|
69
|
|
|
ConfigData::class => function (Config $config) { |
|
70
|
|
|
return $config->getConfigData(); |
|
71
|
|
|
}, |
|
72
|
|
|
DBStorageInterface::class => create(MySQLHandler::class) |
|
73
|
|
|
->constructor(factory([DatabaseConnectionData::class, 'getFromConfig'])), |
|
74
|
|
|
Actions::class => function (ContainerInterface $c) { |
|
|
|
|
|
|
75
|
|
|
return new Actions( |
|
76
|
|
|
new FileCache(Actions::ACTIONS_CACHE_FILE), |
|
77
|
|
|
new XmlHandler(new FileHandler(ACTIONS_FILE)) |
|
78
|
|
|
); |
|
79
|
|
|
}, |
|
80
|
|
|
MimeTypes::class => function () { |
|
81
|
|
|
return new MimeTypes( |
|
82
|
|
|
new FileCache(MimeTypes::MIME_CACHE_FILE), |
|
83
|
|
|
new XmlHandler(new FileHandler(MIMETYPES_FILE)) |
|
84
|
|
|
); |
|
85
|
|
|
}, |
|
86
|
|
|
Acl::class => autowire(Acl::class) |
|
87
|
|
|
->constructorParameter('action', get(Actions::class)), |
|
88
|
|
|
ThemeInterface::class => autowire(Theme::class) |
|
89
|
|
|
->constructorParameter('module', APP_MODULE) |
|
90
|
|
|
->constructorParameter('fileCache', new FileCache(Theme::ICONS_CACHE_FILE)), |
|
91
|
|
|
PHPMailer::class => create(PHPMailer::class) |
|
92
|
|
|
->constructor(true), |
|
93
|
|
|
Logger::class => create(Logger::class) |
|
94
|
|
|
->constructor('syspass'), |
|
95
|
|
|
AccountAclService::class => autowire(AccountAclService::class), |
|
96
|
|
|
\GuzzleHttp\Client::class => create(GuzzleHttp\Client::class) |
|
97
|
|
|
->constructor(factory([Client::class, 'getOptions'])) |
|
98
|
|
|
]; |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.