diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-07-16 17:08:03 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2020-07-21 20:43:18 +0200 |
commit | 91e7f12088cb87ffef5660429ece404364167978 (patch) | |
tree | baf44ebc7b240bd49eb0f6bf615cbb1ed99d13db /apps/user_ldap/lib/AppInfo | |
parent | e029055e766298c5852eedabf06ff42b06a50198 (diff) | |
download | nextcloud-server-91e7f12088cb87ffef5660429ece404364167978.tar.gz nextcloud-server-91e7f12088cb87ffef5660429ece404364167978.zip |
Adjust apps' code to use the ContainerInterface
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/user_ldap/lib/AppInfo')
-rw-r--r-- | apps/user_ldap/lib/AppInfo/Application.php | 70 |
1 files changed, 38 insertions, 32 deletions
diff --git a/apps/user_ldap/lib/AppInfo/Application.php b/apps/user_ldap/lib/AppInfo/Application.php index a97b9c3fef9..fb501eedd79 100644 --- a/apps/user_ldap/lib/AppInfo/Application.php +++ b/apps/user_ldap/lib/AppInfo/Application.php @@ -26,6 +26,7 @@ namespace OCA\User_LDAP\AppInfo; +use Closure; use OCA\Files_External\Service\BackendService; use OCA\User_LDAP\Controller\RenewPasswordController; use OCA\User_LDAP\Group_Proxy; @@ -41,9 +42,14 @@ use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\Bootstrap\IRegistrationContext; +use OCP\IConfig; +use OCP\IGroupManager; use OCP\IL10N; use OCP\IServerContainer; +use OCP\IUserSession; +use OCP\Notification\IManager as INotificationManager; use Psr\Container\ContainerInterface; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; class Application extends App implements IBootstrap { public function __construct() { @@ -77,35 +83,37 @@ class Application extends App implements IBootstrap { } public function boot(IBootContext $context): void { - $server = $context->getServerContainer(); - $config = $server->getConfig(); - - $helper = new Helper($config); - $configPrefixes = $helper->getServerConfigurationPrefixes(true); - if (count($configPrefixes) > 0) { - $ldapWrapper = new LDAP(); - - $notificationManager = $server->getNotificationManager(); - $notificationManager->registerNotifierService(Notifier::class); - $userSession = $server->getUserSession(); - - $userPluginManager = $server->query(UserPluginManager::class); - $groupPluginManager = $server->query(GroupPluginManager::class); - - $userBackend = new User_Proxy( - $configPrefixes, $ldapWrapper, $config, $notificationManager, $userSession, $userPluginManager - ); - $groupBackend = new Group_Proxy($configPrefixes, $ldapWrapper, $groupPluginManager); - // register user backend - \OC_User::useBackend($userBackend); - - // Hook to allow plugins to work on registered backends - $server->getEventDispatcher()->dispatch('OCA\\User_LDAP\\User\\User::postLDAPBackendAdded'); - - $server->getGroupManager()->addBackend($groupBackend); + $context->injectFn(function (IConfig $config, + INotificationManager $notificationManager, + IUserSession $userSession, + ContainerInterface $container, + EventDispatcherInterface $dispatcher, + IGroupManager $groupManager) { + $helper = new Helper($config); + $configPrefixes = $helper->getServerConfigurationPrefixes(true); + if (count($configPrefixes) > 0) { + $ldapWrapper = new LDAP(); + + $notificationManager->registerNotifierService(Notifier::class); + + $userPluginManager = $container->get(UserPluginManager::class); + $groupPluginManager = $container->get(GroupPluginManager::class); + + $userBackend = new User_Proxy( + $configPrefixes, $ldapWrapper, $config, $notificationManager, $userSession, $userPluginManager + ); + $groupBackend = new Group_Proxy($configPrefixes, $ldapWrapper, $groupPluginManager); + // register user backend + \OC_User::useBackend($userBackend); + + // Hook to allow plugins to work on registered backends + $dispatcher->dispatch('OCA\\User_LDAP\\User\\User::postLDAPBackendAdded'); + + $groupManager->addBackend($groupBackend); + } + }); - $this->registerBackendDependents($context->getAppContainer()); - } + $context->injectFn(Closure::fromCallable([$this, 'registerBackendDependents'])); \OCP\Util::connectHook( '\OCA\Files_Sharing\API\Server2Server', @@ -115,10 +123,8 @@ class Application extends App implements IBootstrap { ); } - public function registerBackendDependents(ContainerInterface $appContainer) { - /** @var IServerContainer $serverContainer */ - $serverContainer = $appContainer->get(IServerContainer::class); - $serverContainer->getEventDispatcher()->addListener( + private function registerBackendDependents(ContainerInterface $appContainer, EventDispatcherInterface $dispatcher) { + $dispatcher->addListener( 'OCA\\Files_External::loadAdditionalBackends', function () use ($appContainer) { $storagesBackendService = $appContainer->get(BackendService::class); |