diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-08-27 10:27:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-27 10:27:34 +0200 |
commit | af41d5ab5d2bd3ba64d052c997bc6afa6966a63c (patch) | |
tree | 8fad2829c55f94022e359fa8914e11f80a2afc2a /application/container/ContainerBuilder.php | |
parent | b8e3630f2ecd142d397b1b062a346a667bb78595 (diff) | |
parent | 0c6fdbe12bbbb336348666b14b82096f24d5858b (diff) | |
download | Shaarli-af41d5ab5d2bd3ba64d052c997bc6afa6966a63c.tar.gz Shaarli-af41d5ab5d2bd3ba64d052c997bc6afa6966a63c.tar.zst Shaarli-af41d5ab5d2bd3ba64d052c997bc6afa6966a63c.zip |
Merge pull request #1511 from ArthurHoaro/wip-slim-routing
Diffstat (limited to 'application/container/ContainerBuilder.php')
-rw-r--r-- | application/container/ContainerBuilder.php | 83 |
1 files changed, 80 insertions, 3 deletions
diff --git a/application/container/ContainerBuilder.php b/application/container/ContainerBuilder.php index e2c78ccc..4a1a6ea7 100644 --- a/application/container/ContainerBuilder.php +++ b/application/container/ContainerBuilder.php | |||
@@ -7,11 +7,21 @@ namespace Shaarli\Container; | |||
7 | use Shaarli\Bookmark\BookmarkFileService; | 7 | use Shaarli\Bookmark\BookmarkFileService; |
8 | use Shaarli\Bookmark\BookmarkServiceInterface; | 8 | use Shaarli\Bookmark\BookmarkServiceInterface; |
9 | use Shaarli\Config\ConfigManager; | 9 | use Shaarli\Config\ConfigManager; |
10 | use Shaarli\Feed\FeedBuilder; | ||
11 | use Shaarli\Formatter\FormatterFactory; | ||
12 | use Shaarli\Front\Controller\Visitor\ErrorController; | ||
10 | use Shaarli\History; | 13 | use Shaarli\History; |
14 | use Shaarli\Http\HttpAccess; | ||
15 | use Shaarli\Netscape\NetscapeBookmarkUtils; | ||
11 | use Shaarli\Plugin\PluginManager; | 16 | use Shaarli\Plugin\PluginManager; |
12 | use Shaarli\Render\PageBuilder; | 17 | use Shaarli\Render\PageBuilder; |
18 | use Shaarli\Render\PageCacheManager; | ||
19 | use Shaarli\Security\CookieManager; | ||
13 | use Shaarli\Security\LoginManager; | 20 | use Shaarli\Security\LoginManager; |
14 | use Shaarli\Security\SessionManager; | 21 | use Shaarli\Security\SessionManager; |
22 | use Shaarli\Thumbnailer; | ||
23 | use Shaarli\Updater\Updater; | ||
24 | use Shaarli\Updater\UpdaterUtils; | ||
15 | 25 | ||
16 | /** | 26 | /** |
17 | * Class ContainerBuilder | 27 | * Class ContainerBuilder |
@@ -30,22 +40,37 @@ class ContainerBuilder | |||
30 | /** @var SessionManager */ | 40 | /** @var SessionManager */ |
31 | protected $session; | 41 | protected $session; |
32 | 42 | ||
43 | /** @var CookieManager */ | ||
44 | protected $cookieManager; | ||
45 | |||
33 | /** @var LoginManager */ | 46 | /** @var LoginManager */ |
34 | protected $login; | 47 | protected $login; |
35 | 48 | ||
36 | public function __construct(ConfigManager $conf, SessionManager $session, LoginManager $login) | 49 | /** @var string|null */ |
37 | { | 50 | protected $basePath = null; |
51 | |||
52 | public function __construct( | ||
53 | ConfigManager $conf, | ||
54 | SessionManager $session, | ||
55 | CookieManager $cookieManager, | ||
56 | LoginManager $login | ||
57 | ) { | ||
38 | $this->conf = $conf; | 58 | $this->conf = $conf; |
39 | $this->session = $session; | 59 | $this->session = $session; |
40 | $this->login = $login; | 60 | $this->login = $login; |
61 | $this->cookieManager = $cookieManager; | ||
41 | } | 62 | } |
42 | 63 | ||
43 | public function build(): ShaarliContainer | 64 | public function build(): ShaarliContainer |
44 | { | 65 | { |
45 | $container = new ShaarliContainer(); | 66 | $container = new ShaarliContainer(); |
67 | |||
46 | $container['conf'] = $this->conf; | 68 | $container['conf'] = $this->conf; |
47 | $container['sessionManager'] = $this->session; | 69 | $container['sessionManager'] = $this->session; |
70 | $container['cookieManager'] = $this->cookieManager; | ||
48 | $container['loginManager'] = $this->login; | 71 | $container['loginManager'] = $this->login; |
72 | $container['basePath'] = $this->basePath; | ||
73 | |||
49 | $container['plugins'] = function (ShaarliContainer $container): PluginManager { | 74 | $container['plugins'] = function (ShaarliContainer $container): PluginManager { |
50 | return new PluginManager($container->conf); | 75 | return new PluginManager($container->conf); |
51 | }; | 76 | }; |
@@ -73,7 +98,59 @@ class ContainerBuilder | |||
73 | }; | 98 | }; |
74 | 99 | ||
75 | $container['pluginManager'] = function (ShaarliContainer $container): PluginManager { | 100 | $container['pluginManager'] = function (ShaarliContainer $container): PluginManager { |
76 | return new PluginManager($container->conf); | 101 | $pluginManager = new PluginManager($container->conf); |
102 | |||
103 | $pluginManager->load($container->conf->get('general.enabled_plugins')); | ||
104 | |||
105 | return $pluginManager; | ||
106 | }; | ||
107 | |||
108 | $container['formatterFactory'] = function (ShaarliContainer $container): FormatterFactory { | ||
109 | return new FormatterFactory( | ||
110 | $container->conf, | ||
111 | $container->loginManager->isLoggedIn() | ||
112 | ); | ||
113 | }; | ||
114 | |||
115 | $container['pageCacheManager'] = function (ShaarliContainer $container): PageCacheManager { | ||
116 | return new PageCacheManager( | ||
117 | $container->conf->get('resource.page_cache'), | ||
118 | $container->loginManager->isLoggedIn() | ||
119 | ); | ||
120 | }; | ||
121 | |||
122 | $container['feedBuilder'] = function (ShaarliContainer $container): FeedBuilder { | ||
123 | return new FeedBuilder( | ||
124 | $container->bookmarkService, | ||
125 | $container->formatterFactory->getFormatter(), | ||
126 | $container->environment, | ||
127 | $container->loginManager->isLoggedIn() | ||
128 | ); | ||
129 | }; | ||
130 | |||
131 | $container['thumbnailer'] = function (ShaarliContainer $container): Thumbnailer { | ||
132 | return new Thumbnailer($container->conf); | ||
133 | }; | ||
134 | |||
135 | $container['httpAccess'] = function (): HttpAccess { | ||
136 | return new HttpAccess(); | ||
137 | }; | ||
138 | |||
139 | $container['netscapeBookmarkUtils'] = function (ShaarliContainer $container): NetscapeBookmarkUtils { | ||
140 | return new NetscapeBookmarkUtils($container->bookmarkService, $container->conf, $container->history); | ||
141 | }; | ||
142 | |||
143 | $container['updater'] = function (ShaarliContainer $container): Updater { | ||
144 | return new Updater( | ||
145 | UpdaterUtils::read_updates_file($container->conf->get('resource.updates')), | ||
146 | $container->bookmarkService, | ||
147 | $container->conf, | ||
148 | $container->loginManager->isLoggedIn() | ||
149 | ); | ||
150 | }; | ||
151 | |||
152 | $container['errorHandler'] = function (ShaarliContainer $container): ErrorController { | ||
153 | return new ErrorController($container); | ||
77 | }; | 154 | }; |
78 | 155 | ||
79 | return $container; | 156 | return $container; |