|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Uxmp\Core\Bootstrap; |
|
6
|
|
|
|
|
7
|
|
|
use Configula\ConfigValues; |
|
8
|
|
|
use DI\ContainerBuilder; |
|
9
|
|
|
use Psr\Container\ContainerInterface; |
|
10
|
|
|
use Uxmp\Core\Component\Event\EventHandlerInterface; |
|
11
|
|
|
|
|
12
|
|
|
final class Init |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* @param callable(ContainerInterface):mixed $app |
|
16
|
|
|
*/ |
|
17
|
1 |
|
public static function run(callable $app): mixed |
|
18
|
|
|
{ |
|
19
|
1 |
|
$builder = new ContainerBuilder(); |
|
20
|
1 |
|
$builder->addDefinitions(__DIR__ . '/Services.php'); |
|
21
|
1 |
|
$builder->addDefinitions(__DIR__ . '/../Api/Services.php'); |
|
22
|
1 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Album/Services.php'); |
|
23
|
1 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Catalog/Services.php'); |
|
24
|
1 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Event/Services.php'); |
|
25
|
1 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Config/Services.php'); |
|
26
|
1 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Song/Services.php'); |
|
27
|
1 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Disc/Services.php'); |
|
28
|
1 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Artist/Services.php'); |
|
29
|
1 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Art/Services.php'); |
|
30
|
1 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Setup/Services.php'); |
|
31
|
1 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Tag/Services.php'); |
|
32
|
1 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Favorite/Services.php'); |
|
33
|
1 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Cli/Services.php'); |
|
34
|
1 |
|
$builder->addDefinitions(__DIR__ . '/../Component/User/Services.php'); |
|
35
|
1 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Playlist/Services.php'); |
|
36
|
1 |
|
$builder->addDefinitions(__DIR__ . '/../Component/SubSonic/Services.php'); |
|
37
|
1 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Authentication/Services.php'); |
|
38
|
1 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Io/Services.php'); |
|
39
|
1 |
|
$builder->addDefinitions(__DIR__ . '/../Component/Cache/Services.php'); |
|
40
|
1 |
|
$builder->addDefinitions(__DIR__ . '/../Lib/Services.php'); |
|
41
|
1 |
|
$builder->addDefinitions(__DIR__ . '/../Orm/Services.php'); |
|
42
|
|
|
|
|
43
|
1 |
|
$container = $builder->build(); |
|
44
|
|
|
|
|
45
|
|
|
// @todo validate env variable |
|
46
|
1 |
|
$container->get(ConfigValues::class); |
|
47
|
|
|
|
|
48
|
1 |
|
$result = $app($container); |
|
49
|
|
|
|
|
50
|
1 |
|
$container->get(EventHandlerInterface::class)->run(); |
|
51
|
|
|
|
|
52
|
1 |
|
return $result; |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|