diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-11-12 13:02:36 +0100 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-11-12 13:02:36 +0100 |
commit | 1409f1c89a7ca01456ae2dcd6357d296e2b99f5a (patch) | |
tree | ffa30a9358e82d27be75d8fc5e57f3c8820dc6d3 /application/container | |
parent | 054e03f37fa29da8066f1a637919f13c7e7dc5d2 (diff) | |
parent | a6935feb22df8d9634189ee87d257da9f03eedbd (diff) | |
download | Shaarli-v0.12.tar.gz Shaarli-v0.12.tar.zst Shaarli-v0.12.zip |
Diffstat (limited to 'application/container')
-rw-r--r-- | application/container/ContainerBuilder.php | 19 | ||||
-rw-r--r-- | application/container/ShaarliContainer.php | 4 |
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 | ||
5 | namespace Shaarli\Container; | 5 | namespace Shaarli\Container; |
6 | 6 | ||
7 | use malkusch\lock\mutex\FlockMutex; | ||
8 | use Psr\Log\LoggerInterface; | ||
7 | use Shaarli\Bookmark\BookmarkFileService; | 9 | use Shaarli\Bookmark\BookmarkFileService; |
8 | use Shaarli\Bookmark\BookmarkServiceInterface; | 10 | use Shaarli\Bookmark\BookmarkServiceInterface; |
9 | use Shaarli\Config\ConfigManager; | 11 | use Shaarli\Config\ConfigManager; |
@@ -13,6 +15,7 @@ use Shaarli\Front\Controller\Visitor\ErrorController; | |||
13 | use Shaarli\Front\Controller\Visitor\ErrorNotFoundController; | 15 | use Shaarli\Front\Controller\Visitor\ErrorNotFoundController; |
14 | use Shaarli\History; | 16 | use Shaarli\History; |
15 | use Shaarli\Http\HttpAccess; | 17 | use Shaarli\Http\HttpAccess; |
18 | use Shaarli\Http\MetadataRetriever; | ||
16 | use Shaarli\Netscape\NetscapeBookmarkUtils; | 19 | use Shaarli\Netscape\NetscapeBookmarkUtils; |
17 | use Shaarli\Plugin\PluginManager; | 20 | use Shaarli\Plugin\PluginManager; |
18 | use Shaarli\Render\PageBuilder; | 21 | use 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 | ||
5 | namespace Shaarli\Container; | 5 | namespace Shaarli\Container; |
6 | 6 | ||
7 | use Psr\Log\LoggerInterface; | ||
7 | use Shaarli\Bookmark\BookmarkServiceInterface; | 8 | use Shaarli\Bookmark\BookmarkServiceInterface; |
8 | use Shaarli\Config\ConfigManager; | 9 | use Shaarli\Config\ConfigManager; |
9 | use Shaarli\Feed\FeedBuilder; | 10 | use Shaarli\Feed\FeedBuilder; |
10 | use Shaarli\Formatter\FormatterFactory; | 11 | use Shaarli\Formatter\FormatterFactory; |
11 | use Shaarli\History; | 12 | use Shaarli\History; |
12 | use Shaarli\Http\HttpAccess; | 13 | use Shaarli\Http\HttpAccess; |
14 | use Shaarli\Http\MetadataRetriever; | ||
13 | use Shaarli\Netscape\NetscapeBookmarkUtils; | 15 | use Shaarli\Netscape\NetscapeBookmarkUtils; |
14 | use Shaarli\Plugin\PluginManager; | 16 | use Shaarli\Plugin\PluginManager; |
15 | use Shaarli\Render\PageBuilder; | 17 | use 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 |