mirror of
https://github.com/nextcloud/server.git
synced 2026-06-10 01:00:50 -04:00
fix(user_ldap): Remove usages of deprecated IServerContainer
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
parent
0b8e7bb4f0
commit
c6f56ddbd7
3 changed files with 25 additions and 44 deletions
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
|
@ -8,7 +10,6 @@ namespace OCA\User_LDAP\AppInfo;
|
|||
|
||||
use Closure;
|
||||
use OCA\Files_External\Service\BackendService;
|
||||
use OCA\User_LDAP\Controller\RenewPasswordController;
|
||||
use OCA\User_LDAP\Events\GroupBackendRegistered;
|
||||
use OCA\User_LDAP\Events\UserBackendRegistered;
|
||||
use OCA\User_LDAP\Group_Proxy;
|
||||
|
|
@ -30,16 +31,12 @@ use OCP\AppFramework\Bootstrap\IBootstrap;
|
|||
use OCP\AppFramework\Bootstrap\IRegistrationContext;
|
||||
use OCP\AppFramework\IAppContainer;
|
||||
use OCP\AppFramework\Services\IAppConfig;
|
||||
use OCP\AppFramework\Services\IInitialState;
|
||||
use OCP\Config\IUserConfig;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\IAvatarManager;
|
||||
use OCP\IConfig;
|
||||
use OCP\IGroupManager;
|
||||
use OCP\IL10N;
|
||||
use OCP\Image;
|
||||
use OCP\IRequest;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\IUserManager;
|
||||
use OCP\Notification\IManager as INotificationManager;
|
||||
use OCP\Share\IManager as IShareManager;
|
||||
|
|
@ -53,33 +50,15 @@ class Application extends App implements IBootstrap {
|
|||
|
||||
public function __construct() {
|
||||
parent::__construct(self::APP_ID);
|
||||
$container = $this->getContainer();
|
||||
|
||||
/**
|
||||
* Controller
|
||||
*/
|
||||
$container->registerService('RenewPasswordController', function (ContainerInterface $appContainer) {
|
||||
return new RenewPasswordController(
|
||||
$appContainer->get('AppName'),
|
||||
$appContainer->get(IRequest::class),
|
||||
$appContainer->get(IUserManager::class),
|
||||
$appContainer->get(IConfig::class),
|
||||
$appContainer->get(IUserConfig::class),
|
||||
$appContainer->get(IL10N::class),
|
||||
$appContainer->get('Session'),
|
||||
$appContainer->get(IURLGenerator::class),
|
||||
$appContainer->get(IInitialState::class),
|
||||
);
|
||||
});
|
||||
|
||||
$container->registerService(ILDAPWrapper::class, function (ContainerInterface $appContainer) {
|
||||
return new LDAP(
|
||||
$appContainer->get(IConfig::class)->getSystemValueString('ldap_log_file')
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
public function register(IRegistrationContext $context): void {
|
||||
$context->registerService(ILDAPWrapper::class, function (ContainerInterface $c) {
|
||||
return new LDAP(
|
||||
$c->get(IConfig::class)->getSystemValueString('ldap_log_file')
|
||||
);
|
||||
});
|
||||
|
||||
$context->registerNotifierService(Notifier::class);
|
||||
|
||||
$context->registerService(
|
||||
|
|
|
|||
|
|
@ -5,38 +5,38 @@
|
|||
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace OCA\User_LDAP;
|
||||
|
||||
use OCA\User_LDAP\User\DeletedUsersIndex;
|
||||
use OCP\IServerContainer;
|
||||
use OCP\GroupInterface;
|
||||
use OCP\IGroupManager;
|
||||
use OCP\IUserManager;
|
||||
use OCP\LDAP\IDeletionFlagSupport;
|
||||
use OCP\LDAP\ILDAPProvider;
|
||||
use OCP\UserInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* LDAP provider for public access to the LDAP backend.
|
||||
*/
|
||||
class LDAPProvider implements ILDAPProvider, IDeletionFlagSupport {
|
||||
private $userBackend;
|
||||
private $groupBackend;
|
||||
private $logger;
|
||||
private IUserLDAP&UserInterface $userBackend;
|
||||
private IGroupLDAP&GroupInterface $groupBackend;
|
||||
|
||||
/**
|
||||
* Create new LDAPProvider
|
||||
* @param IServerContainer $serverContainer
|
||||
* @param Helper $helper
|
||||
* @param DeletedUsersIndex $deletedUsersIndex
|
||||
* @throws \Exception if user_ldap app was not enabled
|
||||
*/
|
||||
public function __construct(
|
||||
IServerContainer $serverContainer,
|
||||
IUserManager $userManager,
|
||||
IGroupManager $groupManager,
|
||||
private Helper $helper,
|
||||
private DeletedUsersIndex $deletedUsersIndex,
|
||||
private LoggerInterface $logger,
|
||||
) {
|
||||
$this->logger = $serverContainer->get(LoggerInterface::class);
|
||||
$userBackendFound = false;
|
||||
$groupBackendFound = false;
|
||||
foreach ($serverContainer->getUserManager()->getBackends() as $backend) {
|
||||
foreach ($userManager->getBackends() as $backend) {
|
||||
$this->logger->debug('instance ' . get_class($backend) . ' user backend.', ['app' => 'user_ldap']);
|
||||
if ($backend instanceof IUserLDAP) {
|
||||
$this->userBackend = $backend;
|
||||
|
|
@ -44,7 +44,7 @@ class LDAPProvider implements ILDAPProvider, IDeletionFlagSupport {
|
|||
break;
|
||||
}
|
||||
}
|
||||
foreach ($serverContainer->getGroupManager()->getBackends() as $backend) {
|
||||
foreach ($groupManager->getBackends() as $backend) {
|
||||
$this->logger->debug('instance ' . get_class($backend) . ' group backend.', ['app' => 'user_ldap']);
|
||||
if ($backend instanceof IGroupLDAP) {
|
||||
$this->groupBackend = $backend;
|
||||
|
|
|
|||
|
|
@ -1,20 +1,22 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace OCA\User_LDAP;
|
||||
|
||||
use OCP\IServerContainer;
|
||||
use OCP\LDAP\ILDAPProvider;
|
||||
use OCP\LDAP\ILDAPProviderFactory;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
class LDAPProviderFactory implements ILDAPProviderFactory {
|
||||
public function __construct(
|
||||
/** * @var IServerContainer */
|
||||
private IServerContainer $serverContainer,
|
||||
private ContainerInterface $serverContainer,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue