diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-10-24 16:09:06 +0200 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-10-25 09:52:35 +0200 |
commit | 4130a4cbd8e5bb4506ac30a19a91b088aa35dd24 (patch) | |
tree | 1649216df56b9a685eec56cd694cef4f7ccbfa50 /apps/user_ldap/lib/Proxy.php | |
parent | 6435191a6e96600db9efbad8514d6c2eff1375d1 (diff) | |
download | nextcloud-server-4130a4cbd8e5bb4506ac30a19a91b088aa35dd24.tar.gz nextcloud-server-4130a4cbd8e5bb4506ac30a19a91b088aa35dd24.zip |
Make sure to use AccessFactory to create Access instances and use DI
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps/user_ldap/lib/Proxy.php')
-rw-r--r-- | apps/user_ldap/lib/Proxy.php | 46 |
1 files changed, 15 insertions, 31 deletions
diff --git a/apps/user_ldap/lib/Proxy.php b/apps/user_ldap/lib/Proxy.php index 4df6c2683a6..8cdb1b1da6a 100644 --- a/apps/user_ldap/lib/Proxy.php +++ b/apps/user_ldap/lib/Proxy.php @@ -34,57 +34,41 @@ namespace OCA\User_LDAP; use OCA\User_LDAP\Mapping\GroupMapping; use OCA\User_LDAP\Mapping\UserMapping; -use OCA\User_LDAP\User\Manager; -use OCP\IConfig; -use OCP\IUserManager; +use OCP\ICache; use OCP\Server; -use Psr\Log\LoggerInterface; abstract class Proxy { - private static $accesses = []; - private $ldap = null; - /** @var bool */ - private $isSingleBackend; - - /** @var \OCP\ICache|null */ - private $cache; - - /** - * @param ILDAPWrapper $ldap - */ - public function __construct(ILDAPWrapper $ldap) { + /** @var array<string,Access> */ + private static array $accesses = []; + private ILDAPWrapper $ldap; + private ?bool $isSingleBackend = null; + private ?ICache $cache = null; + private AccessFactory $accessFactory; + + public function __construct( + ILDAPWrapper $ldap, + AccessFactory $accessFactory + ) { $this->ldap = $ldap; + $this->accessFactory = $accessFactory; $memcache = \OC::$server->getMemCacheFactory(); if ($memcache->isAvailable()) { $this->cache = $memcache->createDistributed(); } } - /** - * @param string $configPrefix - */ private function addAccess(string $configPrefix): void { - $ocConfig = Server::get(IConfig::class); $userMap = Server::get(UserMapping::class); $groupMap = Server::get(GroupMapping::class); - $coreUserManager = Server::get(IUserManager::class); - $logger = Server::get(LoggerInterface::class); - $helper = Server::get(Helper::class); - - $userManager = Server::get(Manager::class); $connector = new Connection($this->ldap, $configPrefix); - $access = new Access($connector, $this->ldap, $userManager, $helper, $ocConfig, $coreUserManager, $logger); + $access = $this->accessFactory->get($connector); $access->setUserMapper($userMap); $access->setGroupMapper($groupMap); self::$accesses[$configPrefix] = $access; } - /** - * @param string $configPrefix - * @return mixed - */ - protected function getAccess($configPrefix) { + protected function getAccess(string $configPrefix): Access { if (!isset(self::$accesses[$configPrefix])) { $this->addAccess($configPrefix); } |