cloud_bbb/lib/AppInfo/Application.php

51 lines
1.4 KiB
PHP
Raw Normal View History

2020-04-26 11:36:41 +02:00
<?php
namespace OCA\BigBlueButton\AppInfo;
use \OCP\IConfig;
use \OCP\AppFramework\App;
use \OCA\BigBlueButton\Middleware\JoinMiddleware;
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 {
public function __construct(array $urlParams = []) {
parent::__construct('bbb', $urlParams);
$container = $this->getContainer();
$container->registerMiddleWare(JoinMiddleware::class);
$config = $container->query(IConfig::class);
if ($config->getAppValue('bbb', 'app.navigation') === 'true') {
$this->registerAsNavigationEntry();
} else {
$this->registerAsPersonalSetting();
}
}
private function registerAsPersonalSetting() {
$settingsManager = $this->getContainer()->getServer()->getSettingsManager();
$settingsManager->registerSection('personal', \OCA\BigBlueButton\Settings\Section::class);
$settingsManager->registerSetting('personal', \OCA\BigBlueButton\Settings\Personal::class);
}
private function registerAsNavigationEntry() {
$server = $this->getContainer()->getServer();
$server->getNavigationManager()->add(function () use ($server) {
return [
'id' => 'bbb',
'order' => 80,
'href' => $server->getURLGenerator()->linkToRoute('bbb.page.index'),
'icon' => $server->getURLGenerator()->imagePath('bbb', 'app.svg'),
'name' => 'BigBlueButton',
];
});
}
}