aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/container/ContainerBuilder.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-11-12 13:02:36 +0100
committerArthurHoaro <arthur@hoa.ro>2020-11-12 13:02:36 +0100
commit1409f1c89a7ca01456ae2dcd6357d296e2b99f5a (patch)
treeffa30a9358e82d27be75d8fc5e57f3c8820dc6d3 /application/container/ContainerBuilder.php
parent054e03f37fa29da8066f1a637919f13c7e7dc5d2 (diff)
parenta6935feb22df8d9634189ee87d257da9f03eedbd (diff)
downloadShaarli-v0.12.tar.gz
Shaarli-v0.12.tar.zst
Shaarli-v0.12.zip
Merge branch 'master' into v0.12v0.12.1v0.12
Diffstat (limited to 'application/container/ContainerBuilder.php')
-rw-r--r--application/container/ContainerBuilder.php19
1 files changed, 17 insertions, 2 deletions
diff --git a/application/container/ContainerBuilder.php b/application/container/ContainerBuilder.php
index 55bb51b5..f0234eca 100644
--- a/application/container/ContainerBuilder.php
+++ b/application/container/ContainerBuilder.php
@@ -4,6 +4,8 @@ declare(strict_types=1);
4 4
5namespace Shaarli\Container; 5namespace Shaarli\Container;
6 6
7use malkusch\lock\mutex\FlockMutex;
8use Psr\Log\LoggerInterface;
7use Shaarli\Bookmark\BookmarkFileService; 9use Shaarli\Bookmark\BookmarkFileService;
8use Shaarli\Bookmark\BookmarkServiceInterface; 10use Shaarli\Bookmark\BookmarkServiceInterface;
9use Shaarli\Config\ConfigManager; 11use Shaarli\Config\ConfigManager;
@@ -13,6 +15,7 @@ use Shaarli\Front\Controller\Visitor\ErrorController;
13use Shaarli\Front\Controller\Visitor\ErrorNotFoundController; 15use Shaarli\Front\Controller\Visitor\ErrorNotFoundController;
14use Shaarli\History; 16use Shaarli\History;
15use Shaarli\Http\HttpAccess; 17use Shaarli\Http\HttpAccess;
18use Shaarli\Http\MetadataRetriever;
16use Shaarli\Netscape\NetscapeBookmarkUtils; 19use Shaarli\Netscape\NetscapeBookmarkUtils;
17use Shaarli\Plugin\PluginManager; 20use Shaarli\Plugin\PluginManager;
18use Shaarli\Render\PageBuilder; 21use Shaarli\Render\PageBuilder;
@@ -47,6 +50,9 @@ class ContainerBuilder
47 /** @var LoginManager */ 50 /** @var LoginManager */
48 protected $login; 51 protected $login;
49 52
53 /** @var LoggerInterface */
54 protected $logger;
55
50 /** @var string|null */ 56 /** @var string|null */
51 protected $basePath = null; 57 protected $basePath = null;
52 58
@@ -54,12 +60,14 @@ class ContainerBuilder
54 ConfigManager $conf, 60 ConfigManager $conf,
55 SessionManager $session, 61 SessionManager $session,
56 CookieManager $cookieManager, 62 CookieManager $cookieManager,
57 LoginManager $login 63 LoginManager $login,
64 LoggerInterface $logger
58 ) { 65 ) {
59 $this->conf = $conf; 66 $this->conf = $conf;
60 $this->session = $session; 67 $this->session = $session;
61 $this->login = $login; 68 $this->login = $login;
62 $this->cookieManager = $cookieManager; 69 $this->cookieManager = $cookieManager;
70 $this->logger = $logger;
63 } 71 }
64 72
65 public function build(): ShaarliContainer 73 public function build(): ShaarliContainer
@@ -70,6 +78,7 @@ class ContainerBuilder
70 $container['sessionManager'] = $this->session; 78 $container['sessionManager'] = $this->session;
71 $container['cookieManager'] = $this->cookieManager; 79 $container['cookieManager'] = $this->cookieManager;
72 $container['loginManager'] = $this->login; 80 $container['loginManager'] = $this->login;
81 $container['logger'] = $this->logger;
73 $container['basePath'] = $this->basePath; 82 $container['basePath'] = $this->basePath;
74 83
75 $container['plugins'] = function (ShaarliContainer $container): PluginManager { 84 $container['plugins'] = function (ShaarliContainer $container): PluginManager {
@@ -84,14 +93,20 @@ class ContainerBuilder
84 return new BookmarkFileService( 93 return new BookmarkFileService(
85 $container->conf, 94 $container->conf,
86 $container->history, 95 $container->history,
96 new FlockMutex(fopen(SHAARLI_MUTEX_FILE, 'r'), 2),
87 $container->loginManager->isLoggedIn() 97 $container->loginManager->isLoggedIn()
88 ); 98 );
89 }; 99 };
90 100
101 $container['metadataRetriever'] = function (ShaarliContainer $container): MetadataRetriever {
102 return new MetadataRetriever($container->conf, $container->httpAccess);
103 };
104
91 $container['pageBuilder'] = function (ShaarliContainer $container): PageBuilder { 105 $container['pageBuilder'] = function (ShaarliContainer $container): PageBuilder {
92 return new PageBuilder( 106 return new PageBuilder(
93 $container->conf, 107 $container->conf,
94 $container->sessionManager->getSession(), 108 $container->sessionManager->getSession(),
109 $container->logger,
95 $container->bookmarkService, 110 $container->bookmarkService,
96 $container->sessionManager->generateToken(), 111 $container->sessionManager->generateToken(),
97 $container->loginManager->isLoggedIn() 112 $container->loginManager->isLoggedIn()
@@ -143,7 +158,7 @@ class ContainerBuilder
143 158
144 $container['updater'] = function (ShaarliContainer $container): Updater { 159 $container['updater'] = function (ShaarliContainer $container): Updater {
145 return new Updater( 160 return new Updater(
146 UpdaterUtils::read_updates_file($container->conf->get('resource.updates')), 161 UpdaterUtils::readUpdatesFile($container->conf->get('resource.updates')),
147 $container->bookmarkService, 162 $container->bookmarkService,
148 $container->conf, 163 $container->conf,
149 $container->loginManager->isLoggedIn() 164 $container->loginManager->isLoggedIn()