@@ -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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user