diff --git a/appinfo/app.php b/appinfo/app.php deleted file mode 100644 index bf0ac6c98..000000000 --- a/appinfo/app.php +++ /dev/null @@ -1,39 +0,0 @@ - - * - * @author Julius Härtl - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - -use OCA\Deck\AppInfo\Application; -use OCP\AppFramework\QueryException; - -if ((@include_once __DIR__ . '/../vendor/autoload.php')=== false) { - throw new Exception('Cannot include autoload. Did you run install dependencies using composer?'); -} - -try { - /** @var Application $app */ - $app = \OC::$server->query(Application::class); - $app->register(); -} catch (QueryException $e) { -} - -/** Load activity style global so it is availabile in the activity app as well */ -\OC_Util::addStyle('deck', 'activity'); diff --git a/appinfo/info.xml b/appinfo/info.xml index 34c1ed4ed..95fd78a95 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -69,4 +69,13 @@ OCA\Deck\Provider\DeckProvider + + + Deck + deck.page.index + deck.svg + 10 + + + diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index d4fd3a7a9..e0adc9d17 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -38,9 +38,13 @@ use OCA\Deck\Db\CardMapper; use OCA\Deck\Middleware\DefaultBoardMiddleware; use OCA\Deck\Middleware\ExceptionMiddleware; use OCA\Deck\Notification\Notifier; +use OCA\Deck\Search\DeckProvider; use OCA\Deck\Service\FullTextSearchService; use OCA\Deck\Service\PermissionService; use OCP\AppFramework\App; +use OCP\AppFramework\Bootstrap\IBootContext; +use OCP\AppFramework\Bootstrap\IBootstrap; +use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCP\Collaboration\Resources\IManager; use OCP\Collaboration\Resources\IProviderManager; use OCP\Comments\CommentsEntityEvent; @@ -48,6 +52,9 @@ use OCP\Dashboard\RegisterWidgetEvent; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventDispatcher; use OCP\FullTextSearch\IFullTextSearchManager; +use OCP\IConfig; +use OCP\IContainer; +use OCP\IDBConnection; use OCP\IGroup; use OCP\IServerContainer; use OCP\IUser; @@ -55,7 +62,7 @@ use OCP\IUserManager; use OCP\IURLGenerator; use OCP\Util; -class Application extends App { +class Application extends App implements IBootstrap { public const APP_ID = 'deck'; public const COMMENT_ENTITY_TYPE = 'deckCard'; @@ -70,22 +77,28 @@ class Application extends App { private $fullTextSearchManager; public function __construct(array $urlParams = []) { - parent::__construct('deck', $urlParams); + parent::__construct(self::APP_ID, $urlParams); - $container = $this->getContainer(); - $server = $this->getContainer()->getServer(); + $this->server = \OC::$server; + } - $this->server = $server; + public function boot(IBootContext $context): void { + $notificationManager = $context->getServerContainer()->get(\OCP\Notification\IManager::class); + $notificationManager->registerNotifierService(Notifier::class); + \OCP\Util::addStyle('deck', 'deck'); + } - $container->registerCapability(Capabilities::class); - $container->registerMiddleWare(ExceptionMiddleware::class); - $container->registerMiddleWare(DefaultBoardMiddleware::class); + public function register(IRegistrationContext $context): void { - $container->registerService('databaseType', static function () use ($server) { - return $server->getConfig()->getSystemValue('dbtype', 'sqlite'); + $context->registerCapability(Capabilities::class); + $context->registerMiddleWare(ExceptionMiddleware::class); + $context->registerMiddleWare(DefaultBoardMiddleware::class); + + $context->registerService('databaseType', static function (IContainer $c) { + return $c->get(IConfig::class)->getSystemValue('dbtype', 'sqlite'); }); - $container->registerService('database4ByteSupport', static function () use ($server) { - return $server->getDatabaseConnection()->supports4ByteText(); + $context->registerService('database4ByteSupport', static function (IContainer $c) { + return $c->get(IDBConnection::class)->supports4ByteText(); }); $version = OC_Util::getVersion()[0]; @@ -96,31 +109,16 @@ class Application extends App { $event->registerWidget(DeckWidget::class); }); } - } - public function register(): void { - $this->registerNavigationEntry(); + $context->registerSearchProvider(DeckProvider::class); + $this->registerUserGroupHooks(); - $this->registerNotifications(); + $this->registerCommentsEntity(); $this->registerFullTextSearch(); $this->registerCollaborationResources(); } - public function registerNavigationEntry(): void { - $container = $this->getContainer(); - $this->server->getNavigationManager()->add(static function () use ($container) { - $urlGenerator = $container->query(IURLGenerator::class); - return [ - 'id' => 'deck', - 'order' => 10, - 'href' => $urlGenerator->linkToRoute('deck.page.index'), - 'icon' => $urlGenerator->imagePath('deck', 'deck.svg'), - 'name' => 'Deck', - ]; - }); - } - private function registerUserGroupHooks(): void { $container = $this->getContainer(); // Delete user/group acl entries when they get deleted @@ -162,11 +160,6 @@ class Application extends App { }); } - public function registerNotifications(): void { - $notificationManager = $this->server->getNotificationManager(); - $notificationManager->registerNotifierService(Notifier::class); - } - public function registerCommentsEntity(): void { $this->server->getEventDispatcher()->addListener(CommentsEntityEvent::EVENT_ENTITY, function (CommentsEntityEvent $event) { $event->addEntityCollection(self::COMMENT_ENTITY_TYPE, function ($name) { @@ -184,8 +177,6 @@ class Application extends App { $this->registerCommentsEventHandler(); } - /** - */ protected function registerCommentsEventHandler(): void { $this->server->getCommentsManager()->registerEventHandler(function () { return $this->getContainer()->query(CommentEventHandler::class); @@ -194,10 +185,6 @@ class Application extends App { protected function registerCollaborationResources(): void { $version = OC_Util::getVersion()[0]; - if ($version < 16) { - return; - } - /** * Register Collaboration ResourceProvider * diff --git a/lib/Search/CardSearchResultEntry.php b/lib/Search/CardSearchResultEntry.php new file mode 100644 index 000000000..7f31604c5 --- /dev/null +++ b/lib/Search/CardSearchResultEntry.php @@ -0,0 +1,38 @@ + + * + * @author Julius Härtl + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +declare(strict_types=1); + + +namespace OCA\Deck\Search; + + +use OCA\Deck\Db\Board; +use OCP\Search\SearchResultEntry; + +class BoardSearchResultEntry extends SearchResultEntry { + + public function __construct(Board $board, $urlGenerator) { + parent::__construct('', $board->getTitle(), '', $urlGenerator->linkToRoute('deck.page.index') . '#/board/' . $board->getId(), 'icon-deck'); + } +}