Use proxy classes

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Juan Pablo Villafáñez 2017-04-19 19:05:27 +02:00 committed by Arthur Schiwon
parent 3e37a5f1c7
commit a9a80f95e3
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
1 changed files with 10 additions and 30 deletions

View File

@ -29,6 +29,7 @@
$helper = new \OCA\User_LDAP\Helper(\OC::$server->getConfig());
$configPrefixes = $helper->getServerConfigurationPrefixes(true);
if(count($configPrefixes) > 0) {
$ldapWrapper = new OCA\User_LDAP\LDAP();
$ocConfig = \OC::$server->getConfig();
$notificationManager = \OC::$server->getNotificationManager();
@ -43,32 +44,11 @@ $notificationManager->registerNotifier(function() {
'name' => $l->t('LDAP user and group backend'),
];
});
if(count($configPrefixes) === 1) {
$dbc = \OC::$server->getDatabaseConnection();
$userManager = new OCA\User_LDAP\User\Manager($ocConfig,
new OCA\User_LDAP\FilesystemHelper(),
new OCA\User_LDAP\LogWrapper(),
\OC::$server->getAvatarManager(),
new \OCP\Image(),
$dbc,
\OC::$server->getUserManager(),
$notificationManager
);
$connector = new OCA\User_LDAP\Connection($ldapWrapper, $configPrefixes[0]);
$ldapAccess = new OCA\User_LDAP\Access($connector, $ldapWrapper, $userManager, $helper);
$ldapAccess->setUserMapper(new OCA\User_LDAP\Mapping\UserMapping($dbc));
$ldapAccess->setGroupMapper(new OCA\User_LDAP\Mapping\GroupMapping($dbc));
$userBackend = new OCA\User_LDAP\User_LDAP($ldapAccess, $ocConfig, $notificationManager);
$groupBackend = new \OCA\User_LDAP\Group_LDAP($ldapAccess);
} else if(count($configPrefixes) > 1) {
$userBackend = new OCA\User_LDAP\User_Proxy(
$configPrefixes, $ldapWrapper, $ocConfig, $notificationManager
);
$groupBackend = new OCA\User_LDAP\Group_Proxy($configPrefixes, $ldapWrapper);
}
if(count($configPrefixes) > 0) {
// register user backend
OC_User::useBackend($userBackend);
\OC::$server->getGroupManager()->addBackend($groupBackend);