getProviders()); } /** * @inheritdoc */ public function findAll(): array { return $this->getProviders(); } /** * @inheritdoc */ public function searchByLabel(string $label): array { return array_filter( $this->getProviders(), static function (LtiProvider $provider) use ($label) { return stripos($provider->getLabel(), $label) !== false; } ); } /** * Get providers from configuration. * * @return LtiProvider[] */ private function getProviders(): array { if ($this->providers === null) { $providerList = $this->getOption(self::OPTION_LTI_PROVIDER_LIST); if ($providerList === null) { throw new InvalidArgumentException('LTI provider list is not valid.'); } $this->providers = []; foreach ($providerList as $provider) { $this->providers[] = $this->getLtiProviderFactory()->createFromArray($provider); } } return $this->providers; } public function searchById(string $id): ?LtiProvider { foreach ($this->getProviders() as $provider) { if ($provider->getId() === $id) { return $provider; } } return null; } public function searchByOauthKey(string $oauthKey): ?LtiProvider { foreach ($this->getProviders() as $provider) { if ($provider->getKey() === $oauthKey) { return $provider; } } return null; } public function searchByIssuer(string $issuer, ?string $clientId = null): ?LtiProvider { foreach ($this->getProviders() as $provider) { if ($clientId !== null && $provider->getToolClientId() !== $clientId) { continue; } if ($provider->getToolAudience() === $issuer) { return $provider; } } return null; } private function getLtiProviderFactory(): LtiProviderFactory { /** @noinspection PhpIncompatibleReturnTypeInspection */ return $this->getServiceLocator()->get(LtiProviderFactory::class); } }