aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/container
diff options
context:
space:
mode:
Diffstat (limited to 'application/container')
-rw-r--r--application/container/ContainerBuilder.php19
-rw-r--r--application/container/ShaarliContainer.php4
2 files changed, 21 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()
diff --git a/application/container/ShaarliContainer.php b/application/container/ShaarliContainer.php
index 66e669aa..3e5bd252 100644
--- a/application/container/ShaarliContainer.php
+++ b/application/container/ShaarliContainer.php
@@ -4,12 +4,14 @@ declare(strict_types=1);
4 4
5namespace Shaarli\Container; 5namespace Shaarli\Container;
6 6
7use Psr\Log\LoggerInterface;
7use Shaarli\Bookmark\BookmarkServiceInterface; 8use Shaarli\Bookmark\BookmarkServiceInterface;
8use Shaarli\Config\ConfigManager; 9use Shaarli\Config\ConfigManager;
9use Shaarli\Feed\FeedBuilder; 10use Shaarli\Feed\FeedBuilder;
10use Shaarli\Formatter\FormatterFactory; 11use Shaarli\Formatter\FormatterFactory;
11use Shaarli\History; 12use Shaarli\History;
12use Shaarli\Http\HttpAccess; 13use Shaarli\Http\HttpAccess;
14use Shaarli\Http\MetadataRetriever;
13use Shaarli\Netscape\NetscapeBookmarkUtils; 15use Shaarli\Netscape\NetscapeBookmarkUtils;
14use Shaarli\Plugin\PluginManager; 16use Shaarli\Plugin\PluginManager;
15use Shaarli\Render\PageBuilder; 17use Shaarli\Render\PageBuilder;
@@ -35,6 +37,8 @@ use Slim\Container;
35 * @property History $history 37 * @property History $history
36 * @property HttpAccess $httpAccess 38 * @property HttpAccess $httpAccess
37 * @property LoginManager $loginManager 39 * @property LoginManager $loginManager
40 * @property LoggerInterface $logger
41 * @property MetadataRetriever $metadataRetriever
38 * @property NetscapeBookmarkUtils $netscapeBookmarkUtils 42 * @property NetscapeBookmarkUtils $netscapeBookmarkUtils
39 * @property callable $notFoundHandler Overrides default Slim exception display 43 * @property callable $notFoundHandler Overrides default Slim exception display
40 * @property PageBuilder $pageBuilder 44 * @property PageBuilder $pageBuilder