From 44fd4fab529432f1e0424ad0966b06843a352a34 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Mon, 10 Mar 2025 18:41:09 +0100 Subject: [PATCH] fix(service): add service constructor arguments --- lib/AppInfo/Application.php | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 1990bb3..21fbe07 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -3,6 +3,7 @@ namespace OCA\SideMenu\AppInfo; use OC; +use OC\App\AppStore\Fetcher\CategoryFetcher; use OC\Security\CSP\ContentSecurityPolicyNonceManager; use OC\User\User; use OCA\SideMenu\Service\AppRepository; @@ -12,8 +13,13 @@ use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\Bootstrap\IRegistrationContext; +use OCP\EventDispatcher\IEventDispatcher; +use OCP\IConfig; +use OCP\INavigationManager; use OCP\IUserSession; +use OCP\L10N\IFactory; use OCP\Util; +use Psr\Container\ContainerInterface; /** * class Application. @@ -48,16 +54,32 @@ class Application extends App implements IBootstrap public function register(IRegistrationContext $context): void { - $context->registerService('AppRepository', function () { - return new AppRepository(); + $context->registerService(CategoryRepository::class, function (ContainerInterface $c) { + return new CategoryRepository( + $c->get(CategoryFetcher::class), + $c->get(ConfigProxy::class), + $c->get(IConfig::class), + $c->get(IFactory::class), + $c->get(IUserSession::class) + ); }); - $context->registerService('CategoryRepository', function () { - return new CategoryRepository(); + $context->registerService(AppRepository::class, function (ContainerInterface $c) { + return new AppRepository( + $c->get(\OC_App::class), + $c->get(INavigationManager::class), + $c->get(IFactory::class), + $c->get(ConfigProxy::class), + $c->get(CategoryRepository::class), + $c->get(IEventDispatcher::class), + $c->get(IUserSession::class) + ); }); - $context->registerService('ConfigProxy', function () { - return new ConfigProxy(); + $context->registerService(ConfigProxy::class, function (ContainerInterface $c) { + return new ConfigProxy( + $c->get(IConfig::class), + ); }); }