aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/container/ContainerBuilder.php
diff options
context:
space:
mode:
authoryude <yudesleepy@gmail.com>2021-01-04 18:51:10 +0900
committerGitHub <noreply@github.com>2021-01-04 18:51:10 +0900
commite6754f2154a79abd8e5e64bd923f6984aa9ad44b (patch)
treef074119530bb59ef155938ea367f719f1e4b70f1 /application/container/ContainerBuilder.php
parent5256b4287021342a9f8868967b2a77e481314331 (diff)
parented4ee8f0297941ac83300389b7de6a293312d20e (diff)
downloadShaarli-e6754f2154a79abd8e5e64bd923f6984aa9ad44b.tar.gz
Shaarli-e6754f2154a79abd8e5e64bd923f6984aa9ad44b.tar.zst
Shaarli-e6754f2154a79abd8e5e64bd923f6984aa9ad44b.zip
Merge pull request #2 from shaarli/master
Merge fork source
Diffstat (limited to 'application/container/ContainerBuilder.php')
-rw-r--r--application/container/ContainerBuilder.php34
1 files changed, 21 insertions, 13 deletions
diff --git a/application/container/ContainerBuilder.php b/application/container/ContainerBuilder.php
index c21d58dd..6d69a880 100644
--- a/application/container/ContainerBuilder.php
+++ b/application/container/ContainerBuilder.php
@@ -5,6 +5,7 @@ declare(strict_types=1);
5namespace Shaarli\Container; 5namespace Shaarli\Container;
6 6
7use malkusch\lock\mutex\FlockMutex; 7use malkusch\lock\mutex\FlockMutex;
8use Psr\Log\LoggerInterface;
8use Shaarli\Bookmark\BookmarkFileService; 9use Shaarli\Bookmark\BookmarkFileService;
9use Shaarli\Bookmark\BookmarkServiceInterface; 10use Shaarli\Bookmark\BookmarkServiceInterface;
10use Shaarli\Config\ConfigManager; 11use Shaarli\Config\ConfigManager;
@@ -14,6 +15,7 @@ use Shaarli\Front\Controller\Visitor\ErrorController;
14use Shaarli\Front\Controller\Visitor\ErrorNotFoundController; 15use Shaarli\Front\Controller\Visitor\ErrorNotFoundController;
15use Shaarli\History; 16use Shaarli\History;
16use Shaarli\Http\HttpAccess; 17use Shaarli\Http\HttpAccess;
18use Shaarli\Http\MetadataRetriever;
17use Shaarli\Netscape\NetscapeBookmarkUtils; 19use Shaarli\Netscape\NetscapeBookmarkUtils;
18use Shaarli\Plugin\PluginManager; 20use Shaarli\Plugin\PluginManager;
19use Shaarli\Render\PageBuilder; 21use Shaarli\Render\PageBuilder;
@@ -48,6 +50,12 @@ class ContainerBuilder
48 /** @var LoginManager */ 50 /** @var LoginManager */
49 protected $login; 51 protected $login;
50 52
53 /** @var PluginManager */
54 protected $pluginManager;
55
56 /** @var LoggerInterface */
57 protected $logger;
58
51 /** @var string|null */ 59 /** @var string|null */
52 protected $basePath = null; 60 protected $basePath = null;
53 61
@@ -55,12 +63,16 @@ class ContainerBuilder
55 ConfigManager $conf, 63 ConfigManager $conf,
56 SessionManager $session, 64 SessionManager $session,
57 CookieManager $cookieManager, 65 CookieManager $cookieManager,
58 LoginManager $login 66 LoginManager $login,
67 PluginManager $pluginManager,
68 LoggerInterface $logger
59 ) { 69 ) {
60 $this->conf = $conf; 70 $this->conf = $conf;
61 $this->session = $session; 71 $this->session = $session;
62 $this->login = $login; 72 $this->login = $login;
63 $this->cookieManager = $cookieManager; 73 $this->cookieManager = $cookieManager;
74 $this->pluginManager = $pluginManager;
75 $this->logger = $logger;
64 } 76 }
65 77
66 public function build(): ShaarliContainer 78 public function build(): ShaarliContainer
@@ -71,11 +83,10 @@ class ContainerBuilder
71 $container['sessionManager'] = $this->session; 83 $container['sessionManager'] = $this->session;
72 $container['cookieManager'] = $this->cookieManager; 84 $container['cookieManager'] = $this->cookieManager;
73 $container['loginManager'] = $this->login; 85 $container['loginManager'] = $this->login;
86 $container['pluginManager'] = $this->pluginManager;
87 $container['logger'] = $this->logger;
74 $container['basePath'] = $this->basePath; 88 $container['basePath'] = $this->basePath;
75 89
76 $container['plugins'] = function (ShaarliContainer $container): PluginManager {
77 return new PluginManager($container->conf);
78 };
79 90
80 $container['history'] = function (ShaarliContainer $container): History { 91 $container['history'] = function (ShaarliContainer $container): History {
81 return new History($container->conf->get('resource.history')); 92 return new History($container->conf->get('resource.history'));
@@ -90,24 +101,21 @@ class ContainerBuilder
90 ); 101 );
91 }; 102 };
92 103
104 $container['metadataRetriever'] = function (ShaarliContainer $container): MetadataRetriever {
105 return new MetadataRetriever($container->conf, $container->httpAccess);
106 };
107
93 $container['pageBuilder'] = function (ShaarliContainer $container): PageBuilder { 108 $container['pageBuilder'] = function (ShaarliContainer $container): PageBuilder {
94 return new PageBuilder( 109 return new PageBuilder(
95 $container->conf, 110 $container->conf,
96 $container->sessionManager->getSession(), 111 $container->sessionManager->getSession(),
112 $container->logger,
97 $container->bookmarkService, 113 $container->bookmarkService,
98 $container->sessionManager->generateToken(), 114 $container->sessionManager->generateToken(),
99 $container->loginManager->isLoggedIn() 115 $container->loginManager->isLoggedIn()
100 ); 116 );
101 }; 117 };
102 118
103 $container['pluginManager'] = function (ShaarliContainer $container): PluginManager {
104 $pluginManager = new PluginManager($container->conf);
105
106 $pluginManager->load($container->conf->get('general.enabled_plugins'));
107
108 return $pluginManager;
109 };
110
111 $container['formatterFactory'] = function (ShaarliContainer $container): FormatterFactory { 119 $container['formatterFactory'] = function (ShaarliContainer $container): FormatterFactory {
112 return new FormatterFactory( 120 return new FormatterFactory(
113 $container->conf, 121 $container->conf,
@@ -145,7 +153,7 @@ class ContainerBuilder
145 153
146 $container['updater'] = function (ShaarliContainer $container): Updater { 154 $container['updater'] = function (ShaarliContainer $container): Updater {
147 return new Updater( 155 return new Updater(
148 UpdaterUtils::read_updates_file($container->conf->get('resource.updates')), 156 UpdaterUtils::readUpdatesFile($container->conf->get('resource.updates')),
149 $container->bookmarkService, 157 $container->bookmarkService,
150 $container->conf, 158 $container->conf,
151 $container->loginManager->isLoggedIn() 159 $container->loginManager->isLoggedIn()