Move setupContainerForAddons() into App

This commit is contained in:
Art4 2025-01-09 08:17:43 +00:00
parent e899127137
commit 768d7961a6
2 changed files with 17 additions and 9 deletions

View file

@ -17,6 +17,7 @@ use Friendica\App\Router;
use Friendica\Capabilities\ICanCreateResponses; use Friendica\Capabilities\ICanCreateResponses;
use Friendica\Capabilities\ICanHandleRequests; use Friendica\Capabilities\ICanHandleRequests;
use Friendica\Content\Nav; use Friendica\Content\Nav;
use Friendica\Core\Addon\Capability\ICanLoadAddons;
use Friendica\Core\Config\Factory\Config; use Friendica\Core\Config\Factory\Config;
use Friendica\Core\Container; use Friendica\Core\Container;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
@ -134,6 +135,8 @@ class App
], ],
]); ]);
$this->setupContainerForAddons();
$this->container->setup(LogChannel::APP, false); $this->container->setup(LogChannel::APP, false);
$this->requestId = $this->container->create(Request::class)->getRequestId(); $this->requestId = $this->container->create(Request::class)->getRequestId();
@ -170,11 +173,15 @@ class App
public function processConsole(array $argv): void public function processConsole(array $argv): void
{ {
$this->setupContainerForAddons();
(\Friendica\Core\Console::create($this->container, $argv))->execute(); (\Friendica\Core\Console::create($this->container, $argv))->execute();
} }
public function processEjabberd(): void public function processEjabberd(): void
{ {
$this->setupContainerForAddons();
$this->container->setup(LogChannel::AUTH_JABBERED, false); $this->container->setup(LogChannel::AUTH_JABBERED, false);
/** @var BasePath */ /** @var BasePath */
@ -192,6 +199,16 @@ class App
} }
} }
private function setupContainerForAddons(): void
{
/** @var ICanLoadAddons $addonLoader */
$addonLoader = $this->container->create(ICanLoadAddons::class);
foreach ($addonLoader->getActiveAddonConfig('dependencies') as $name => $rule) {
$this->container->addRule($name, $rule);
}
}
private function registerTemplateEngine(): void private function registerTemplateEngine(): void
{ {
Renderer::registerTemplateEngine('Friendica\Render\FriendicaSmartyEngine'); Renderer::registerTemplateEngine('Friendica\Render\FriendicaSmartyEngine');

View file

@ -49,7 +49,6 @@ final class DiceContainer implements Container
*/ */
public function setup(string $logChannel = LogChannel::DEFAULT, bool $withTemplateEngine = true): void public function setup(string $logChannel = LogChannel::DEFAULT, bool $withTemplateEngine = true): void
{ {
$this->setupContainerForAddons();
$this->setupContainerForLogger($logChannel); $this->setupContainerForLogger($logChannel);
$this->setupLegacyServiceLocator(); $this->setupLegacyServiceLocator();
$this->registerErrorHandler(); $this->registerErrorHandler();
@ -85,14 +84,6 @@ final class DiceContainer implements Container
$this->container = $this->container->addRule($name, $rule); $this->container = $this->container->addRule($name, $rule);
} }
private function setupContainerForAddons(): void
{
/** @var ICanLoadAddons $addonLoader */
$addonLoader = $this->container->create(ICanLoadAddons::class);
$this->container = $this->container->addRules($addonLoader->getActiveAddonConfig('dependencies'));
}
private function setupContainerForLogger(string $logChannel): void private function setupContainerForLogger(string $logChannel): void
{ {
$this->container = $this->container->addRule(LoggerInterface::class, [ $this->container = $this->container->addRule(LoggerInterface::class, [