Move navigation entry to info.xml

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2020-02-28 15:46:29 +01:00
parent d10e10bca2
commit dba5abdaf1
No known key found for this signature in database
GPG key ID: F941078878347C0C
3 changed files with 11 additions and 44 deletions

View file

@ -1,25 +0,0 @@
<?php
/**
* @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
*
* @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
*
* @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/>.
*
*/
$app = new \OCA\Forms\AppInfo\Application();
$app->registerNavigationEntry();

View file

@ -34,4 +34,12 @@
<dependencies>
<nextcloud min-version="17" max-version="19" />
</dependencies>
<navigations>
<navigation>
<name>Forms</name>
<route>forms.page.index</route>
<icon>app.svg</icon>
<order>77</order>
</navigation>
</navigations>
</info>

View file

@ -31,29 +31,13 @@ use OCP\IURLGenerator;
class Application extends App {
const APP_ID = 'forms';
/**
* Application constructor.
* @param array $urlParams
*/
public function __construct(array $urlParams = []) {
parent::__construct('forms', $urlParams);
}
/**
* Register navigation entry for main navigation.
*/
public function registerNavigationEntry(): void {
$container = $this->getContainer();
$container->query(INavigationManager::class)->add(function() use ($container) {
$urlGenerator = $container->query(IURLGenerator::class);
$l10n = $container->query(IL10N::class);
return [
'id' => 'forms',
'order' => 77,
'href' => $urlGenerator->linkToRoute('forms.page.index'),
'icon' => $urlGenerator->imagePath('forms', 'app.svg'),
'name' => $l10n->t('Forms')
];
});
parent::__construct(self::APP_ID, $urlParams);
}
}