cloud_bbb/lib/AppInfo/Application.php

86 lines
3.1 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\EventDispatcher\IEventDispatcher;
use \OCP\IConfig;
use \OCP\Settings\IManager as ISettingsManager;
use \OCP\User\Events\UserDeletedEvent;
2020-04-26 11:36:41 +02:00
if ((@include_once __DIR__ . '/../../vendor/autoload.php') === false) {
throw new \Exception('Cannot include autoload. Did you run install dependencies using composer?');
}
class Application extends App {
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);
$container = $this->getContainer();
/* @var IEventDispatcher $dispatcher */
2020-09-07 22:18:23 +02:00
$dispatcher = $container->query(IEventDispatcher::class);
$this->registerServiceListener($dispatcher);
2020-09-22 16:02:18 +02:00
$container->registerMiddleWare(JoinMiddleware::class);
$container->registerMiddleWare(HookMiddleware::class);
$config = $container->query(IConfig::class);
2020-09-07 22:18:23 +02:00
if ($config->getAppValue(self::ID, 'app.navigation') === 'true') {
$this->registerAsNavigationEntry();
} else {
$this->registerAsPersonalSetting();
}
}
private function registerAsPersonalSetting() {
$settingsManager = $this->getContainer()->getServer()->getSettingsManager();
$settingsManager->registerSetting(ISettingsManager::KEY_PERSONAL_SETTINGS, \OCA\BigBlueButton\Settings\Personal::class);
}
private function registerAsNavigationEntry() {
$server = $this->getContainer()->getServer();
$server->getNavigationManager()->add(function () use ($server) {
return [
2020-09-07 22:18:23 +02:00
'id' => self::ID,
'order' => 80,
'href' => $server->getURLGenerator()->linkToRoute('bbb.page.index'),
'icon' => $server->getURLGenerator()->imagePath('bbb', 'app.svg'),
'name' => 'BigBlueButton',
];
});
}
private function registerServiceListener(IEventDispatcher $dispatcher) {
$dispatcher->addServiceListener(RoomCreatedEvent::class, RoomListener::class);
$dispatcher->addServiceListener(RoomDeletedEvent::class, RoomListener::class);
$dispatcher->addServiceListener(RoomShareCreatedEvent::class, RoomShareListener::class);
$dispatcher->addServiceListener(RoomShareDeletedEvent::class, RoomShareListener::class);
$dispatcher->addServiceListener(MeetingStartedEvent::class, MeetingListener::class);
$dispatcher->addServiceListener(MeetingEndedEvent::class, MeetingListener::class);
$dispatcher->addServiceListener(RecordingReadyEvent::class, MeetingListener::class);
$dispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedListener::class);
}
}