1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Nextcloud - NextNote |
4
|
|
|
* |
5
|
|
|
* |
6
|
|
|
* @copyright Copyright (c) 2017, Sander Brand ([email protected]) |
7
|
|
|
* @license GNU AGPL version 3 or any later version |
8
|
|
|
* |
9
|
|
|
* This program is free software: you can redistribute it and/or modify |
10
|
|
|
* it under the terms of the GNU Affero General Public License as |
11
|
|
|
* published by the Free Software Foundation, either version 3 of the |
12
|
|
|
* License, or (at your option) any later version. |
13
|
|
|
* |
14
|
|
|
* This program is distributed in the hope that it will be useful, |
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17
|
|
|
* GNU Affero General Public License for more details. |
18
|
|
|
* |
19
|
|
|
* You should have received a copy of the GNU Affero General Public License |
20
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
21
|
|
|
* |
22
|
|
|
*/ |
23
|
|
|
namespace OCA\NextNote\AppInfo; |
24
|
|
|
|
25
|
|
|
use OC\Files\View; |
26
|
|
|
|
27
|
|
|
|
28
|
|
|
use OCA\NextNote\Controller\NextNoteApiController; |
29
|
|
|
use OCA\NextNote\Controller\PageController; |
30
|
|
|
|
31
|
|
|
use OCP\AppFramework\App; |
32
|
|
|
use OCP\IL10N; |
33
|
|
|
|
34
|
|
|
|
35
|
|
|
class Application extends App { |
36
|
|
|
public function __construct() { |
37
|
|
|
parent::__construct('nextnote'); |
38
|
|
|
$container = $this->getContainer(); |
39
|
|
|
// Allow automatic DI for the View, until we migrated to Nodes API |
40
|
|
|
$container->registerService(View::class, function () { |
41
|
|
|
return new View(''); |
42
|
|
|
}, false); |
43
|
|
|
$container->registerService('isCLI', function () { |
44
|
|
|
return \OC::$CLI; |
45
|
|
|
}); |
46
|
|
|
|
47
|
|
|
|
48
|
|
|
|
49
|
|
|
|
50
|
|
|
/** Cron |
51
|
|
|
$container->registerService('CronService', function ($c) { |
52
|
|
|
return new CronService( |
53
|
|
|
$c->query('CredentialService'), |
54
|
|
|
$c->query('Logger'), |
55
|
|
|
$c->query('Utils'), |
56
|
|
|
$c->query('NotificationService'), |
57
|
|
|
$c->query('ActivityService'), |
58
|
|
|
$c->query('IDBConnection') |
59
|
|
|
); |
60
|
|
|
});**/ |
61
|
|
|
/* |
62
|
|
|
$container->registerService('Db', function () { |
63
|
|
|
return new Db(); |
64
|
|
|
});*/ |
65
|
|
|
|
66
|
|
|
|
67
|
|
|
|
68
|
|
|
$container->registerService('Logger', function ($c) { |
69
|
|
|
return $c->query('ServerContainer')->getLogger(); |
70
|
|
|
}); |
71
|
|
|
|
72
|
|
|
// Aliases for the controllers so we can use the automatic DI |
73
|
|
|
$container->registerAlias('PageController', PageController::class); |
74
|
|
|
$container->registerAlias('NextNoteApiController', NextNoteApiController::class); |
75
|
|
|
|
76
|
|
|
|
77
|
|
|
/*$container->registerAlias('CredentialController', CredentialController::class); |
78
|
|
|
$container->registerAlias('PageController', PageController::class); |
79
|
|
|
$container->registerAlias('PageController', PageController::class); |
80
|
|
|
$container->registerAlias('VaultController', VaultController::class); |
81
|
|
|
$container->registerAlias('VaultController', VaultController::class); |
82
|
|
|
$container->registerAlias('CredentialService', CredentialService::class); |
83
|
|
|
$container->registerAlias('NotificationService', NotificationService::class); |
84
|
|
|
$container->registerAlias('ActivityService', ActivityService::class); |
85
|
|
|
$container->registerAlias('VaultService', VaultService::class); |
86
|
|
|
$container->registerAlias('FileService', FileService::class); |
87
|
|
|
$container->registerAlias('ShareService', ShareService::class); |
88
|
|
|
$container->registerAlias('Utils', Utils::class); |
89
|
|
|
$container->registerAlias('IDBConnection', IDBConnection::class); |
90
|
|
|
$container->registerAlias('IConfig', IConfig::class); |
91
|
|
|
$container->registerAlias('SettingsService', SettingsService::class); |
92
|
|
|
$container->registerAlias('APIMiddleware', APIMiddleware::class);*/ |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Register the navigation entry |
97
|
|
|
*/ |
98
|
|
|
public function registerNavigationEntry() { |
99
|
|
|
$c = $this->getContainer(); |
100
|
|
|
/** @var \OCP\IServerContainer $server */ |
101
|
|
|
$server = $c->getServer(); |
102
|
|
|
$navigationEntry = function () use ($c, $server) { |
103
|
|
|
return [ |
104
|
|
|
'id' => $c->getAppName(), |
105
|
|
|
'order' => 10, |
106
|
|
|
'name' => $c->query(IL10N::class)->t('Notes'), |
107
|
|
|
'href' => $server->getURLGenerator()->linkToRoute('nextnote.page.index'), |
108
|
|
|
'icon' => $server->getURLGenerator()->imagePath($c->getAppName(), 'app.svg'), |
109
|
|
|
]; |
110
|
|
|
}; |
111
|
|
|
$server->getNavigationManager()->add($navigationEntry); |
112
|
|
|
} |
113
|
|
|
} |