forked from RSS-Bridge/rss-bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdependencies.php
70 lines (53 loc) · 1.85 KB
/
dependencies.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
<?php
declare(strict_types=1);
$container = new Container();
$container[ConnectivityAction::class] = function ($c) {
return new ConnectivityAction($c['bridge_factory']);
};
$container[DetectAction::class] = function ($c) {
return new DetectAction($c['bridge_factory']);
};
$container[DisplayAction::class] = function ($c) {
return new DisplayAction($c['cache'], $c['logger'], $c['bridge_factory']);
};
$container[FindfeedAction::class] = function ($c) {
return new FindfeedAction($c['bridge_factory']);
};
$container[FrontpageAction::class] = function ($c) {
return new FrontpageAction($c['bridge_factory']);
};
$container[HealthAction::class] = function () {
return new HealthAction();
};
$container[ListAction::class] = function ($c) {
return new ListAction($c['bridge_factory']);
};
$container['bridge_factory'] = function ($c) {
return new BridgeFactory($c['cache'], $c['logger']);
};
$container['http_client'] = function () {
return new CurlHttpClient();
};
$container['cache_factory'] = function ($c) {
return new CacheFactory($c['logger']);
};
$container['logger'] = function () {
$logger = new SimpleLogger('rssbridge');
if (Debug::isEnabled()) {
$logger->addHandler(new ErrorLogHandler(Logger::DEBUG));
} else {
$logger->addHandler(new ErrorLogHandler(Logger::INFO));
}
// Uncomment this for info logging to fs
// $logger->addHandler(new StreamHandler('/tmp/rss-bridge.txt', Logger::INFO));
// Uncomment this for debug logging to fs
// $logger->addHandler(new StreamHandler('/tmp/rss-bridge-debug.txt', Logger::DEBUG));
return $logger;
};
$container['cache'] = function ($c) {
/** @var CacheFactory $cacheFactory */
$cacheFactory = $c['cache_factory'];
$cache = $cacheFactory->create(Configuration::getConfig('cache', 'type'));
return $cache;
};
return $container;