diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Cron/Index.php | 3 | ||||
-rw-r--r-- | lib/Service/ProviderService.php | 37 | ||||
-rw-r--r-- | lib/Service/SettingsService.php | 4 |
3 files changed, 29 insertions, 15 deletions
diff --git a/lib/Cron/Index.php b/lib/Cron/Index.php index c4b2965..729d54e 100644 --- a/lib/Cron/Index.php +++ b/lib/Cron/Index.php @@ -119,7 +119,8 @@ class Index extends TimedJob { $this->runner->updateAction('indexing'); try { - $provider = $this->providerService->getProvider($index->getProviderId()); + $providerWrapper = $this->providerService->getProvider($index->getProviderId()); + $provider = $providerWrapper->getProvider(); if (!$this->providerService->isProviderIndexed($provider->getId())) { continue; } diff --git a/lib/Service/ProviderService.php b/lib/Service/ProviderService.php index ac120f3..692e0bb 100644 --- a/lib/Service/ProviderService.php +++ b/lib/Service/ProviderService.php @@ -33,6 +33,7 @@ use OCA\FullTextSearch\Exceptions\ProviderIsNotCompatibleException; use OCA\FullTextSearch\Exceptions\ProviderIsNotUniqueException; use OCA\FullTextSearch\Exceptions\ProviderOptionsDoesNotExistException; use OCA\FullTextSearch\IFullTextSearchProvider; +use OCA\FullTextSearch\Model\ProviderWrapper; use OCP\AppFramework\QueryException; class ProviderService { @@ -46,7 +47,7 @@ class ProviderService { /** @var MiscService */ private $miscService; - /** @var IFullTextSearchProvider[] */ + /** @var ProviderWrapper[] */ private $providers = []; /** @var bool */ @@ -94,13 +95,14 @@ class ProviderService { /** + * @param string $appId * @param string $providerId * * @throws ProviderIsNotCompatibleException * @throws ProviderIsNotUniqueException * @throws QueryException */ - public function loadProvider($providerId) { + public function loadProvider($appId, $providerId) { $provider = \OC::$server->query((string)$providerId); if (!($provider instanceof IFullTextSearchProvider)) { @@ -110,16 +112,19 @@ class ProviderService { } $this->providerIdMustBeUnique($provider); + try { $provider->loadProvider(); - $this->providers[] = $provider; + $wrapper = new ProviderWrapper($appId, $provider); + $wrapper->setVersion($this->configService->getAppVersion($appId)); + $this->providers[] = $wrapper; } catch (Exception $e) { } } /** - * @return IFullTextSearchProvider[] + * @return ProviderWrapper[] * @throws Exception */ public function getProviders() { @@ -136,7 +141,8 @@ class ProviderService { $this->loadProviders(); $providers = []; - foreach ($this->providers as $provider) { + foreach ($this->providers as $providerWrapper) { + $provider = $providerWrapper->getProvider(); if ($this->isProviderIndexed($provider->getId())) { $providers[] = $provider; } @@ -164,7 +170,8 @@ class ProviderService { $ret = []; foreach ($providerList as $providerId) { if ($this->isProviderIndexed($providerId)) { - $ret[] = $this->getProvider($providerId); + $providerWrapper = $this->getProvider($providerId); + $ret[] = $providerWrapper->getProvider(); } } @@ -175,16 +182,17 @@ class ProviderService { /** * @param string $providerId * - * @return IFullTextSearchProvider + * @return ProviderWrapper * @throws Exception * @throws ProviderDoesNotExistException */ public function getProvider($providerId) { $providers = $this->getProviders(); - foreach ($providers as $provider) { + foreach ($providers as $providerWrapper) { + $provider = $providerWrapper->getProvider(); if ($provider->getId() === $providerId) { - return $provider; + return $providerWrapper; } } @@ -242,24 +250,25 @@ class ProviderService { } $providers = $appInfo['fulltextsearch']['provider']; - $this->loadProvidersFromList($providers); + $this->loadProvidersFromList($appId, $providers); } /** + * @param string $appId * @param string|array $providers * * @throws ProviderIsNotCompatibleException * @throws ProviderIsNotUniqueException * @throws QueryException */ - private function loadProvidersFromList($providers) { + private function loadProvidersFromList($appId, $providers) { if (!is_array($providers)) { $providers = [$providers]; } foreach ($providers AS $provider) { - $this->loadProvider($provider); + $this->loadProvider($appId, $provider); } } @@ -268,9 +277,11 @@ class ProviderService { * @param IFullTextSearchProvider $provider * * @throws ProviderIsNotUniqueException + * @throws Exception */ private function providerIdMustBeUnique(IFullTextSearchProvider $provider) { - foreach ($this->providers AS $knownProvider) { + foreach ($this->providers AS $providerWrapper) { + $knownProvider = $providerWrapper->getProvider(); if ($knownProvider->getId() === $provider->getId()) { throw new ProviderIsNotUniqueException( 'FullTextSearchProvider ' . $provider->getId() . ' already exist' diff --git a/lib/Service/SettingsService.php b/lib/Service/SettingsService.php index b887346..939db0f 100644 --- a/lib/Service/SettingsService.php +++ b/lib/Service/SettingsService.php @@ -108,7 +108,9 @@ class SettingsService { private function completeSettingsProviders() { $list = []; $providers = $this->providerService->getProviders(); - foreach ($providers as $provider) { + foreach ($providers as $providerWrapper) { + $provider = $providerWrapper->getProvider(); + $list[$provider->getId()] = $provider->getName(); } |