Merge pull request #632 from nextcloud/cleanup

Cleanup routes and and register navigation in info.xml
This commit is contained in:
Raimund Schlüßler 2019-09-23 17:18:32 +02:00 committed by GitHub
commit 9e0e7f6f22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 74 deletions

View file

@ -1,24 +0,0 @@
<?php
/**
* Nextcloud - Tasks
*
* @author Raimund Schlüßler
* @copyright 2018 Raimund Schlüßler <raimund.schluessler@mailbox.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library 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 library. If not, see <http://www.gnu.org/licenses/>.
*
*/
$app = new \OCA\Tasks\AppInfo\Application();
$app->registerNavigation();

View file

@ -22,4 +22,13 @@
<dependencies>
<nextcloud min-version="15" max-version="18"/>
</dependencies>
<navigations>
<navigation>
<id>tasks</id>
<name>Tasks</name>
<route>tasks.page.index</route>
<icon>tasks.svg</icon>
<order>100</order>
</navigation>
</navigations>
</info>

View file

@ -19,26 +19,12 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Tasks;
// use \OCP\AppFramework\App;
use \OCA\Tasks\AppInfo\Application;
$application = new Application();
$application->registerRoutes($this, array('routes' => array(
// page
array('name' => 'page#index', 'url' => '/', 'verb' => 'GET'),
// templates
array('name' => 'page#templates', 'url' => '/templates/{template}', 'verb' => 'GET'),
// collections
array('name' => 'collections#getCollections', 'url' => '/collections', 'verb' => 'GET'),
array('name' => 'collections#setVisibility', 'url' => '/collection/{collectionID}/visibility/{visibility}', 'verb' => 'POST'),
// settings
array('name' => 'settings#get', 'url' => '/settings', 'verb' => 'GET'),
array('name' => 'settings#set', 'url' => '/settings/{setting}/{value}', 'verb' => 'POST'),
)));
return [
'routes' => [
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
['name' => 'collections#getCollections','url' => '/collections', 'verb' => 'GET'],
['name' => 'collections#setVisibility', 'url' => '/collection/{collectionID}/visibility/{visibility}', 'verb' => 'POST'],
['name' => 'settings#get', 'url' => '/settings', 'verb' => 'GET'],
['name' => 'settings#set', 'url' => '/settings/{setting}/{value}', 'verb' => 'POST'],
]
];

View file

@ -32,27 +32,4 @@ class Application extends App {
public function __construct(array $params=[]) {
parent::__construct('tasks', $params);
}
/**
* Register navigation
*/
public function registerNavigation() {
$appName = $this->getContainer()->getAppName();
$server = $this->getContainer()->getServer();
$urlGenerator = $server->getURLGenerator();
$server->getNavigationManager()->add(function() use ($appName, $server, $urlGenerator) {
return [
'id' => $appName,
'order' => 100,
'href' => $urlGenerator->linkToRoute('tasks.page.index'),
'icon' => $urlGenerator->imagePath($appName, 'tasks.svg'),
'name' => $server->getL10N($appName)->t('Tasks'),
];
});
}
}

View file

@ -45,10 +45,8 @@ class AppTest extends TestCase {
public function testNavigation() {
$navigationManager = \OC::$server->getNavigationManager();
$navigationManager->clear();
$countBefore = count($navigationManager->getAll());
require __DIR__ . '/../../../appinfo/app.php';
// Test whether the navigation entry got added
$this->assertCount($countBefore + 1, $navigationManager->getAll());
$enabled = array_key_exists('tasks', $navigationManager->getAll());
$this->assertTrue($enabled);
}
}