mirror of
https://github.com/nextcloud/passman.git
synced 2025-09-14 00:44:52 +08:00
Move appinfo to lib
This commit is contained in:
parent
aa6d91136a
commit
2a8ff7f1c8
2 changed files with 71 additions and 28 deletions
|
@ -11,37 +11,13 @@
|
|||
|
||||
namespace OCA\Passman\AppInfo;
|
||||
|
||||
use OCP\AppFramework\App;
|
||||
|
||||
use OCP\Util;
|
||||
require_once __DIR__ . '/autoload.php';
|
||||
|
||||
$app = new App('passman');
|
||||
$container = $app->getContainer();
|
||||
|
||||
$container->query('OCP\INavigationManager')->add(function () use ($container) {
|
||||
$urlGenerator = $container->query('OCP\IURLGenerator');
|
||||
$l10n = $container->query('OCP\IL10N');
|
||||
return [
|
||||
// the string under which your app will be referenced in Nextcloud
|
||||
'id' => 'passman',
|
||||
|
||||
// sorting weight for the navigation. The higher the number, the higher
|
||||
// will it be listed in the navigation
|
||||
'order' => 10,
|
||||
|
||||
// the route that will be shown on startup
|
||||
'href' => $urlGenerator->linkToRoute('passman.page.index'),
|
||||
|
||||
// the icon that will be shown in the navigation
|
||||
// this file needs to exist in img/
|
||||
'icon' => $urlGenerator->imagePath('passman', 'app.svg'),
|
||||
|
||||
// the title of your application. This will be used in the
|
||||
// navigation or on the settings page of your app
|
||||
'name' => $l10n->t('Passwords'),
|
||||
];
|
||||
});
|
||||
|
||||
$app = new \OCA\Passman\AppInfo\Application();
|
||||
$app->registerNavigationEntry();
|
||||
$app->registerPersonalPage();
|
||||
/**
|
||||
* Loading translations
|
||||
*
|
||||
|
|
67
lib/AppInfo/Application.php
Normal file
67
lib/AppInfo/Application.php
Normal file
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
/**
|
||||
* Nextcloud - passman
|
||||
*
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later. See the COPYING file.
|
||||
*
|
||||
* @author Sander Brand <brantje@gmail.com>
|
||||
* @copyright Sander Brand 2016
|
||||
*/
|
||||
|
||||
namespace OCA\Passman\AppInfo;
|
||||
use OC\Files\View;
|
||||
|
||||
use OCA\Passman\Controller\CredentialController;
|
||||
use OCA\Passman\Controller\FileController;
|
||||
use OCA\Passman\Controller\PageController;
|
||||
use OCA\Passman\Controller\RevisionController;
|
||||
use OCA\Passman\Controller\VaultController;
|
||||
|
||||
use OCP\AppFramework\App;
|
||||
use OCP\IL10N;
|
||||
use OCP\Util;
|
||||
class Application extends App {
|
||||
public function __construct () {
|
||||
parent::__construct('passman');
|
||||
$container = $this->getContainer();
|
||||
// Allow automatic DI for the View, until we migrated to Nodes API
|
||||
$container->registerService(View::class, function() {
|
||||
return new View('');
|
||||
}, false);
|
||||
$container->registerService('isCLI', function() {
|
||||
return \OC::$CLI;
|
||||
});
|
||||
// Aliases for the controllers so we can use the automatic DI
|
||||
$container->registerAlias('CredentialController', CredentialController::class);
|
||||
$container->registerAlias('FileController', FileController::class);
|
||||
$container->registerAlias('PageController', PageController::class);
|
||||
$container->registerAlias('RevisionController', RevisionController::class);
|
||||
$container->registerAlias('VaultController', VaultController::class);
|
||||
}
|
||||
/**
|
||||
* Register the navigation entry
|
||||
*/
|
||||
public function registerNavigationEntry() {
|
||||
$c = $this->getContainer();
|
||||
/** @var \OCP\IServerContainer $server */
|
||||
$server = $c->getServer();
|
||||
$navigationEntry = function () use ($c, $server) {
|
||||
return [
|
||||
'id' => $c->getAppName(),
|
||||
'order' => 10,
|
||||
'name' => $c->query(IL10N::class)->t('Password'),
|
||||
'href' => $server->getURLGenerator()->linkToRoute('passman.PageController.index'),
|
||||
'icon' => $server->getURLGenerator()->imagePath($c->getAppName(), 'app.svg'),
|
||||
];
|
||||
};
|
||||
$server->getNavigationManager()->add($navigationEntry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register personal settings for notifications and emails
|
||||
*/
|
||||
public function registerPersonalPage() {
|
||||
\OCP\App::registerPersonal($this->getContainer()->getAppName(), 'personal');
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue