diff options
author | Julius Härtl <jus@bitgrid.net> | 2020-06-19 16:56:46 +0300 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2020-06-19 16:56:46 +0300 |
commit | 5587944955eacbded8692805ad953209de7baace (patch) | |
tree | 346bdcecc28ff174d5b1f3f7c0d1d6828ba25120 /lib | |
parent | ce3801d79d964a30c494329d203ef60ef14cc690 (diff) |
Catch query exception and only add listener if the LoadViewer class is available
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AppInfo/Application.php | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 9eebcb18..07485aa7 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -39,6 +39,7 @@ use OCA\Richdocuments\Service\FederationService; use OCA\Richdocuments\WOPI\DiscoveryManager; use OCA\Viewer\Event\LoadViewer; use OCP\AppFramework\App; +use OCP\AppFramework\QueryException; use OCP\EventDispatcher\IEventDispatcher; use OCP\IPreview; @@ -63,11 +64,16 @@ class Application extends App { public function __construct(array $urlParams = array()) { parent::__construct(self::APPNAME, $urlParams); - /** @var IEventDispatcher $eventDispatcher */ - $eventDispatcher = $this->getContainer()->getServer()->query(IEventDispatcher::class); - $eventDispatcher->addListener(LoadViewer::class, function () { - \OCP\Util::addScript('richdocuments', 'viewer'); - }); + try { + /** @var IEventDispatcher $eventDispatcher */ + $eventDispatcher = $this->getContainer()->getServer()->query(IEventDispatcher::class); + if (class_exists(LoadViewer::class)) { + $eventDispatcher->addListener(LoadViewer::class, function () { + \OCP\Util::addScript('richdocuments', 'viewer'); + }); + } + } catch (QueryException $e) { + } $this->getContainer()->registerCapability(Capabilities::class); } |