fix(service): add service constructor arguments

This commit is contained in:
Simon Vieille 2025-03-10 18:41:09 +01:00
commit 44fd4fab52

View file

@ -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),
);
});
}