getInstance(IUpdatable::class) as $instance) { $instance->update($user, $password); } } public function audit(IUser $user, string $password): void { foreach ($this->getInstance(IAuditor::class) as $instance) { $instance->audit($user, $password); } } /** * @throws LoginException */ public function entryControl(string $loginName, ?string $password): void { $uid = $loginName; \OCP\Util::emitHook('\OCA\Files_Sharing\API\Server2Server', 'preLoginNameUsedAsUserName', ['uid' => &$uid]); /** @var IEntryControl $instance */ foreach ($this->getInstance(IEntryControl::class) as $instance) { try { $user = $this->userManager->get((string)$uid); if ($user === null) { break; } $instance->entryControl($user, $password); } catch (HintException $e) { throw new LoginException($e->getHint()); } } } /** * @template T * @psalm-param class-string $interface * @return Iterable */ protected function getInstance($interface) { foreach (self::COMPLIANCERS as $compliance) { try { $instance = $this->container->get($compliance); if (!$instance instanceof $interface) { continue; } } catch (ContainerExceptionInterface $e) { //ignore and continue $this->logger->info('Could not query compliance', ['compliance' => $compliance, 'exception' => $e]); continue; } yield $instance; } } }