From cf0d2dc28c7b8b40a00e623b0273a10ac7e843f4 Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Wed, 10 Apr 2019 20:29:19 -0100 Subject: [PATCH 1/2] using isAvailable() Signed-off-by: Maxence Lange --- lib/AppInfo/Application.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 1a7faf6d6..05698a49f 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -24,6 +24,7 @@ namespace OCA\Deck\AppInfo; use Exception; +use OC\FullTextSearch\FullTextSearchManager; use OCA\Deck\Activity\CommentEventHandler; use OCA\Deck\Db\Acl; use OCA\Deck\Db\AclMapper; @@ -36,6 +37,7 @@ use OCP\AppFramework\App; use OCA\Deck\Middleware\SharingMiddleware; use OCP\Collaboration\Resources\IManager; use OCP\Comments\CommentsEntityEvent; +use OCP\FullTextSearch\IFullTextSearchManager; use OCP\IGroup; use OCP\IUser; use OCP\IUserManager; @@ -50,6 +52,9 @@ class Application extends App { /** @var FullTextSearchService */ private $fullTextSearchService; + /** @var IFullTextSearchManager */ + private $fullTextSearchManager; + /** * Application constructor. @@ -191,17 +196,22 @@ class Application extends App { } public function registerFullTextSearch() { - if (Util::getVersion()[0] < 16 || !\OC::$server->getAppManager()->isEnabledForUser('fulltextsearch')) { + if (Util::getVersion()[0] < 16) { return; } $c = $this->getContainer(); try { $this->fullTextSearchService = $c->query(FullTextSearchService::class); + $this->fullTextSearchManager = $c->query(FullTextSearchManager::class); } catch (Exception $e) { return; } + if (!$this->fullTextSearchManager->isAvailable()) { + return; + } + $eventDispatcher = \OC::$server->getEventDispatcher(); $eventDispatcher->addListener( '\OCA\Deck\Card::onCreate', function(GenericEvent $e) { From a8472c650a2f44b4cd79b3e2af43f1fa7e7bbd9b Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Thu, 11 Apr 2019 07:27:43 -0100 Subject: [PATCH 2/2] using public instead Signed-off-by: Maxence Lange --- lib/AppInfo/Application.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 05698a49f..1b28c5e42 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -24,7 +24,6 @@ namespace OCA\Deck\AppInfo; use Exception; -use OC\FullTextSearch\FullTextSearchManager; use OCA\Deck\Activity\CommentEventHandler; use OCA\Deck\Db\Acl; use OCA\Deck\Db\AclMapper; @@ -203,7 +202,7 @@ class Application extends App { $c = $this->getContainer(); try { $this->fullTextSearchService = $c->query(FullTextSearchService::class); - $this->fullTextSearchManager = $c->query(FullTextSearchManager::class); + $this->fullTextSearchManager = $c->query(IFullTextSearchManager::class); } catch (Exception $e) { return; }