Skip to content
Merged
Next Next commit
Move to IBootstrap
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Sep 1, 2020
commit 1e54d77f7aa357ecb561d24426ec7912fc2f3e3c
39 changes: 0 additions & 39 deletions appinfo/app.php

This file was deleted.

9 changes: 9 additions & 0 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,13 @@
<provider min-version="16">OCA\Deck\Provider\DeckProvider</provider>
</fulltextsearch>

<navigations>
<navigation>
<name>Deck</name>
<route>deck.page.index</route>
<icon>deck.svg</icon>
<order>10</order>
</navigation>
</navigations>

</info>
69 changes: 28 additions & 41 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,31 @@
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;
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;
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';
Expand All @@ -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;
}

public function boot(IBootContext $context): void {
$notificationManager = $context->getServerContainer()->get(\OCP\Notification\IManager::class);
$notificationManager->registerNotifierService(Notifier::class);
\OCP\Util::addStyle('deck', 'deck');
}

$this->server = $server;
public function register(IRegistrationContext $context): void {

$container->registerCapability(Capabilities::class);
$container->registerMiddleWare(ExceptionMiddleware::class);
$container->registerMiddleWare(DefaultBoardMiddleware::class);
$context->registerCapability(Capabilities::class);
$context->registerMiddleWare(ExceptionMiddleware::class);
$context->registerMiddleWare(DefaultBoardMiddleware::class);

$container->registerService('databaseType', static function () use ($server) {
return $server->getConfig()->getSystemValue('dbtype', 'sqlite');
$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];
Expand All @@ -96,31 +109,16 @@ public function __construct(array $urlParams = []) {
$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
Expand Down Expand Up @@ -162,11 +160,6 @@ private function registerUserGroupHooks(): void {
});
}

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) {
Expand All @@ -184,8 +177,6 @@ public function registerCommentsEntity(): void {
$this->registerCommentsEventHandler();
}

/**
*/
protected function registerCommentsEventHandler(): void {
$this->server->getCommentsManager()->registerEventHandler(function () {
return $this->getContainer()->query(CommentEventHandler::class);
Expand All @@ -194,10 +185,6 @@ protected function registerCommentsEventHandler(): void {

protected function registerCollaborationResources(): void {
$version = OC_Util::getVersion()[0];
if ($version < 16) {
return;
}

/**
* Register Collaboration ResourceProvider
*
Expand Down
38 changes: 38 additions & 0 deletions lib/Search/CardSearchResultEntry.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/**
* @copyright Copyright (c) 2020 Julius Härtl <[email protected]>
*
* @author Julius Härtl <[email protected]>
*
* @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 <http://www.gnu.org/licenses/>.
*
*/

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');
}
}