cloud_bbb/lib/AppInfo/Application.php

89 lines
3.4 KiB
PHP
Raw Normal View History

2020-04-26 11:36:41 +02:00
<?php
namespace OCA\BigBlueButton\AppInfo;
2020-09-23 12:33:09 +02:00
use \OCA\BigBlueButton\Activity\MeetingListener;
2020-09-07 22:18:23 +02:00
use \OCA\BigBlueButton\Activity\RoomListener;
2020-09-18 17:13:46 +02:00
use \OCA\BigBlueButton\Activity\RoomShareListener;
2020-09-22 16:02:18 +02:00
use \OCA\BigBlueButton\Event\MeetingEndedEvent;
2020-09-23 12:33:09 +02:00
use \OCA\BigBlueButton\Event\MeetingStartedEvent;
2020-09-22 16:02:18 +02:00
use \OCA\BigBlueButton\Event\RecordingReadyEvent;
2020-09-23 12:33:09 +02:00
use \OCA\BigBlueButton\Event\RoomCreatedEvent;
use \OCA\BigBlueButton\Event\RoomDeletedEvent;
use \OCA\BigBlueButton\Event\RoomShareCreatedEvent;
use \OCA\BigBlueButton\Event\RoomShareDeletedEvent;
use \OCA\BigBlueButton\Listener\UserDeletedListener;
2020-09-23 12:33:09 +02:00
use \OCA\BigBlueButton\Middleware\HookMiddleware;
use \OCA\BigBlueButton\Middleware\JoinMiddleware;
use \OCP\AppFramework\App;
use \OCP\IConfig;
use \OCP\Settings\IManager as ISettingsManager;
use \OCP\User\Events\UserDeletedEvent;
2022-10-26 20:31:16 +02:00
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\INavigationManager;
use OCP\IURLGenerator;
use OCP\Util;
class Application extends App implements IBootstrap {
2020-09-07 22:18:23 +02:00
public const ID = 'bbb';
public function __construct(array $urlParams = []) {
2020-09-07 22:18:23 +02:00
parent::__construct(self::ID, $urlParams);
2022-10-26 20:31:16 +02:00
}
2022-10-26 20:31:16 +02:00
public function register(IRegistrationContext $context): void {
if ((@include_once __DIR__ . '/../../vendor/autoload.php') === false) {
throw new \Exception('Cannot include autoload. Did you run install dependencies using composer?');
}
2022-10-26 20:31:16 +02:00
$context->registerEventListener(RoomCreatedEvent::class, RoomListener::class);
$context->registerEventListener(RoomDeletedEvent::class, RoomListener::class);
2020-09-22 16:02:18 +02:00
2022-10-26 20:31:16 +02:00
$context->registerEventListener(RoomShareCreatedEvent::class, RoomShareListener::class);
$context->registerEventListener(RoomShareDeletedEvent::class, RoomShareListener::class);
2022-10-26 20:31:16 +02:00
$context->registerEventListener(MeetingStartedEvent::class, MeetingListener::class);
$context->registerEventListener(MeetingEndedEvent::class, MeetingListener::class);
$context->registerEventListener(RecordingReadyEvent::class, MeetingListener::class);
2022-10-26 20:31:16 +02:00
$context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class);
2022-10-26 20:31:16 +02:00
$context->registerMiddleware(JoinMiddleware::class);
$context->registerMiddleware(HookMiddleware::class);
}
2022-10-26 20:31:16 +02:00
public function boot(IBootContext $context): void {
$context->injectFn([$this, 'registerAdminPage']);
Util::addScript('bbb', 'filelist');
}
2022-10-26 20:31:16 +02:00
public function registerAdminPage(ISettingsManager $settingsManager, INavigationManager $navigationManager, IURLGenerator $urlGenerator, IConfig $config):void {
if ($config->getAppValue(self::ID, 'app.navigation') === 'true') {
$this->registerAsNavigationEntry($navigationManager, $urlGenerator, $config);
} else {
$this->registerAsPersonalSetting($settingsManager);
}
}
2022-10-26 20:31:16 +02:00
private function registerAsPersonalSetting(ISettingsManager $settingsManager): void {
$settingsManager->registerSetting(ISettingsManager::KEY_PERSONAL_SETTINGS, \OCA\BigBlueButton\Settings\Personal::class);
}
2022-10-26 20:31:16 +02:00
private function registerAsNavigationEntry(INavigationManager $navigationManager, IURLGenerator $urlGenerator, IConfig $config): void {
$name = $config->getAppValue(self::ID, 'app.navigation.name', 'BBB');
2022-10-26 20:31:16 +02:00
$navigationManager->add(function () use ($urlGenerator, $name) {
return [
2020-09-07 22:18:23 +02:00
'id' => self::ID,
'order' => 80,
2022-10-26 20:31:16 +02:00
'href' => $urlGenerator->linkToRoute('bbb.page.index'),
'icon' => $urlGenerator->imagePath('bbb', 'app.svg'),
'name' => $name,
];
});
}
}