Skip to content

Commit a9a80f9

Browse files
jvillafanezblizzz
authored andcommitted
Use proxy classes
Signed-off-by: Arthur Schiwon <[email protected]>
1 parent 3e37a5f commit a9a80f9

File tree

1 file changed

+10
-30
lines changed

1 file changed

+10
-30
lines changed

apps/user_ldap/appinfo/app.php

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,46 +29,26 @@
2929

3030
$helper = new \OCA\User_LDAP\Helper(\OC::$server->getConfig());
3131
$configPrefixes = $helper->getServerConfigurationPrefixes(true);
32-
$ldapWrapper = new OCA\User_LDAP\LDAP();
33-
$ocConfig = \OC::$server->getConfig();
34-
$notificationManager = \OC::$server->getNotificationManager();
35-
$notificationManager->registerNotifier(function() {
36-
return new \OCA\User_LDAP\Notification\Notifier(
37-
\OC::$server->getL10NFactory()
38-
);
39-
}, function() {
32+
if(count($configPrefixes) > 0) {
33+
$ldapWrapper = new OCA\User_LDAP\LDAP();
34+
$ocConfig = \OC::$server->getConfig();
35+
$notificationManager = \OC::$server->getNotificationManager();
36+
$notificationManager->registerNotifier(function() {
37+
return new \OCA\User_LDAP\Notification\Notifier(
38+
\OC::$server->getL10NFactory()
39+
);
40+
}, function() {
4041
$l = \OC::$server->getL10N('user_ldap');
4142
return [
4243
'id' => 'user_ldap',
4344
'name' => $l->t('LDAP user and group backend'),
4445
];
45-
});
46-
if(count($configPrefixes) === 1) {
47-
$dbc = \OC::$server->getDatabaseConnection();
48-
$userManager = new OCA\User_LDAP\User\Manager($ocConfig,
49-
new OCA\User_LDAP\FilesystemHelper(),
50-
new OCA\User_LDAP\LogWrapper(),
51-
\OC::$server->getAvatarManager(),
52-
new \OCP\Image(),
53-
$dbc,
54-
\OC::$server->getUserManager(),
55-
$notificationManager
56-
);
57-
$connector = new OCA\User_LDAP\Connection($ldapWrapper, $configPrefixes[0]);
58-
$ldapAccess = new OCA\User_LDAP\Access($connector, $ldapWrapper, $userManager, $helper);
46+
});
5947

60-
$ldapAccess->setUserMapper(new OCA\User_LDAP\Mapping\UserMapping($dbc));
61-
$ldapAccess->setGroupMapper(new OCA\User_LDAP\Mapping\GroupMapping($dbc));
62-
$userBackend = new OCA\User_LDAP\User_LDAP($ldapAccess, $ocConfig, $notificationManager);
63-
$groupBackend = new \OCA\User_LDAP\Group_LDAP($ldapAccess);
64-
} else if(count($configPrefixes) > 1) {
6548
$userBackend = new OCA\User_LDAP\User_Proxy(
6649
$configPrefixes, $ldapWrapper, $ocConfig, $notificationManager
6750
);
6851
$groupBackend = new OCA\User_LDAP\Group_Proxy($configPrefixes, $ldapWrapper);
69-
}
70-
71-
if(count($configPrefixes) > 0) {
7252
// register user backend
7353
OC_User::useBackend($userBackend);
7454
\OC::$server->getGroupManager()->addBackend($groupBackend);

0 commit comments

Comments
 (0)