Skip to content

Commit f0ef985

Browse files
committed
fix(user_ldap): Remove usages of deprecated IServerContainer
Signed-off-by: Côme Chilliet <[email protected]>
1 parent 1829269 commit f0ef985

File tree

3 files changed

+23
-40
lines changed

3 files changed

+23
-40
lines changed

apps/user_ldap/lib/AppInfo/Application.php

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
57
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -8,7 +10,6 @@
810

911
use Closure;
1012
use OCA\Files_External\Service\BackendService;
11-
use OCA\User_LDAP\Controller\RenewPasswordController;
1213
use OCA\User_LDAP\Events\GroupBackendRegistered;
1314
use OCA\User_LDAP\Events\UserBackendRegistered;
1415
use OCA\User_LDAP\Group_Proxy;
@@ -35,10 +36,7 @@
3536
use OCP\IAvatarManager;
3637
use OCP\IConfig;
3738
use OCP\IGroupManager;
38-
use OCP\IL10N;
3939
use OCP\Image;
40-
use OCP\IRequest;
41-
use OCP\IURLGenerator;
4240
use OCP\IUserManager;
4341
use OCP\Notification\IManager as INotificationManager;
4442
use OCP\Share\IManager as IShareManager;
@@ -52,32 +50,15 @@ class Application extends App implements IBootstrap {
5250

5351
public function __construct() {
5452
parent::__construct(self::APP_ID);
55-
$container = $this->getContainer();
56-
57-
/**
58-
* Controller
59-
*/
60-
$container->registerService('RenewPasswordController', function (ContainerInterface $appContainer) {
61-
return new RenewPasswordController(
62-
$appContainer->get('AppName'),
63-
$appContainer->get(IRequest::class),
64-
$appContainer->get(IUserManager::class),
65-
$appContainer->get(IConfig::class),
66-
$appContainer->get(IUserConfig::class),
67-
$appContainer->get(IL10N::class),
68-
$appContainer->get('Session'),
69-
$appContainer->get(IURLGenerator::class),
70-
);
71-
});
53+
}
7254

73-
$container->registerService(ILDAPWrapper::class, function (ContainerInterface $appContainer) {
55+
public function register(IRegistrationContext $context): void {
56+
$context->registerService(ILDAPWrapper::class, function (ContainerInterface $c) {
7457
return new LDAP(
75-
$appContainer->get(IConfig::class)->getSystemValueString('ldap_log_file')
58+
$c->get(IConfig::class)->getSystemValueString('ldap_log_file')
7659
);
7760
});
78-
}
7961

80-
public function register(IRegistrationContext $context): void {
8162
$context->registerNotifierService(Notifier::class);
8263

8364
$context->registerService(

apps/user_ldap/lib/LDAPProvider.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,46 @@
55
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
66
* SPDX-License-Identifier: AGPL-3.0-or-later
77
*/
8+
89
namespace OCA\User_LDAP;
910

1011
use OCA\User_LDAP\User\DeletedUsersIndex;
11-
use OCP\IServerContainer;
12+
use OCP\GroupInterface;
13+
use OCP\IGroupManager;
14+
use OCP\IUserManager;
1215
use OCP\LDAP\IDeletionFlagSupport;
1316
use OCP\LDAP\ILDAPProvider;
17+
use OCP\UserInterface;
1418
use Psr\Log\LoggerInterface;
1519

1620
/**
1721
* LDAP provider for public access to the LDAP backend.
1822
*/
1923
class LDAPProvider implements ILDAPProvider, IDeletionFlagSupport {
20-
private $userBackend;
21-
private $groupBackend;
22-
private $logger;
24+
private IUserLDAP&UserInterface $userBackend;
25+
private IGroupLDAP&GroupInterface $groupBackend;
2326

2427
/**
25-
* Create new LDAPProvider
26-
* @param IServerContainer $serverContainer
27-
* @param Helper $helper
28-
* @param DeletedUsersIndex $deletedUsersIndex
2928
* @throws \Exception if user_ldap app was not enabled
3029
*/
3130
public function __construct(
32-
IServerContainer $serverContainer,
31+
IUserManager $userManager,
32+
IGroupManager $groupManager,
3333
private Helper $helper,
3434
private DeletedUsersIndex $deletedUsersIndex,
35+
private LoggerInterface $logger,
3536
) {
36-
$this->logger = $serverContainer->get(LoggerInterface::class);
3737
$userBackendFound = false;
3838
$groupBackendFound = false;
39-
foreach ($serverContainer->getUserManager()->getBackends() as $backend) {
39+
foreach ($userManager->getBackends() as $backend) {
4040
$this->logger->debug('instance ' . get_class($backend) . ' user backend.', ['app' => 'user_ldap']);
4141
if ($backend instanceof IUserLDAP) {
4242
$this->userBackend = $backend;
4343
$userBackendFound = true;
4444
break;
4545
}
4646
}
47-
foreach ($serverContainer->getGroupManager()->getBackends() as $backend) {
47+
foreach ($groupManager->getBackends() as $backend) {
4848
$this->logger->debug('instance ' . get_class($backend) . ' group backend.', ['app' => 'user_ldap']);
4949
if ($backend instanceof IGroupLDAP) {
5050
$this->groupBackend = $backend;

apps/user_ldap/lib/LDAPProviderFactory.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
57
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
68
* SPDX-License-Identifier: AGPL-3.0-or-later
79
*/
10+
811
namespace OCA\User_LDAP;
912

10-
use OCP\IServerContainer;
1113
use OCP\LDAP\ILDAPProvider;
1214
use OCP\LDAP\ILDAPProviderFactory;
15+
use Psr\Container\ContainerInterface;
1316

1417
class LDAPProviderFactory implements ILDAPProviderFactory {
1518
public function __construct(
16-
/** * @var IServerContainer */
17-
private IServerContainer $serverContainer,
19+
private ContainerInterface $serverContainer,
1820
) {
1921
}
2022

0 commit comments

Comments
 (0)