diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index eb2b160..1737fd5 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -31,6 +31,7 @@ namespace OCA\Files_FullTextSearch_Tesseract\AppInfo; +use OCA\Files_FullTextSearch_Tesseract\Service\ConfigService; use OCA\Files_FullTextSearch_Tesseract\Service\TesseractService; use OCP\AppFramework\App; use OCP\AppFramework\QueryException; @@ -50,6 +51,8 @@ class Application extends App { /** @var TesseractService */ private $tesseractService; + /** @var ConfigService */ + private $configService; /** * @param array $params @@ -61,6 +64,7 @@ public function __construct(array $params = []) { $c = $this->getContainer(); $this->tesseractService = $c->query(TesseractService::class); + $this->configService = $c->query(ConfigService::class); } @@ -69,6 +73,12 @@ public function __construct(array $params = []) { */ public function registerFilesExtension() { $eventDispatcher = \OC::$server->getEventDispatcher(); + $eventDispatcher->addListener( + '\OCA\Files_FullTextSearch::onGetConfig', + function(GenericEvent $e) { + $this->configService->onGetConfig($e); + } + ); $eventDispatcher->addListener( '\OCA\Files_FullTextSearch::onFileIndexing', function(GenericEvent $e) { diff --git a/lib/Service/ConfigService.php b/lib/Service/ConfigService.php index c55fd08..179f070 100644 --- a/lib/Service/ConfigService.php +++ b/lib/Service/ConfigService.php @@ -33,6 +33,7 @@ use OCA\Files_FullTextSearch_Tesseract\AppInfo\Application; use OCP\IConfig; +use Symfony\Component\EventDispatcher\GenericEvent; /** @@ -80,6 +81,21 @@ public function __construct(IConfig $config, $userId, MiscService $miscService) } + public function onGetConfig(GenericEvent $e) { + /** @var array $config */ + $config = $e->getArgument('config'); + $config['files_fulltextsearch_tesseract'] = + [ + 'version' => $this->getAppValue('installed_version'), + 'enabled' => $this->getAppValue(self::TESSERACT_ENABLED), + 'psm' => $this->getAppValue(self::TESSERACT_PSM), + 'lang' => $this->getAppValue(self::TESSERACT_LANG), + 'pdf' => $this->getAppValue(self::TESSERACT_PDF), + ]; + $e->setArgument('config', $config); + } + + /** * @return array */