|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author Joas Schilling <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* @copyright Copyright (c) 2016, Joas Schilling <[email protected]> |
|
6
|
|
|
* @license AGPL-3.0 |
|
7
|
|
|
* |
|
8
|
|
|
* This code is free software: you can redistribute it and/or modify |
|
9
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
|
10
|
|
|
* as published by the Free Software Foundation. |
|
11
|
|
|
* |
|
12
|
|
|
* This program is distributed in the hope that it will be useful, |
|
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15
|
|
|
* GNU Affero General Public License for more details. |
|
16
|
|
|
* |
|
17
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
|
18
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
|
19
|
|
|
* |
|
20
|
|
|
*/ |
|
21
|
|
|
|
|
22
|
|
|
namespace OCA\AnnouncementCenter\AppInfo; |
|
23
|
|
|
|
|
24
|
|
|
use OCA\AnnouncementCenter\Controller\PageController; |
|
25
|
|
|
use OCA\AnnouncementCenter\Manager; |
|
26
|
|
|
use OCP\AppFramework\App; |
|
27
|
|
|
use OCP\IContainer; |
|
28
|
|
|
use OCP\IUser; |
|
29
|
|
|
use OCP\IUserSession; |
|
30
|
|
|
|
|
31
|
|
|
class Application extends App { |
|
32
|
5 |
|
public function __construct (array $urlParams = array()) { |
|
33
|
5 |
|
parent::__construct('announcementcenter', $urlParams); |
|
34
|
5 |
|
$container = $this->getContainer(); |
|
35
|
|
|
|
|
36
|
5 |
|
$container->registerAlias('PageController', 'OCA\AnnouncementCenter\Controller\PageController'); |
|
37
|
5 |
|
} |
|
38
|
|
|
|
|
39
|
3 |
|
public function register() { |
|
40
|
3 |
|
$this->registerNavigationEntry(); |
|
41
|
3 |
|
$this->registerActivityExtension(); |
|
42
|
3 |
|
$this->registerNotificationNotifier(); |
|
43
|
3 |
|
} |
|
44
|
|
|
|
|
45
|
3 |
|
protected function registerNavigationEntry() { |
|
46
|
3 |
|
$server = $this->getContainer()->getServer(); |
|
47
|
|
|
|
|
48
|
|
|
$server->getNavigationManager()->add(function() use ($server) { |
|
49
|
1 |
|
$urlGenerator = $server->getURLGenerator(); |
|
50
|
1 |
|
$l = $server->getL10NFactory()->get('announcementcenter'); |
|
51
|
|
|
return [ |
|
52
|
1 |
|
'id' => 'announcementcenter', |
|
53
|
1 |
|
'order' => 10, |
|
54
|
1 |
|
'href' => $urlGenerator->linkToRoute('announcementcenter.page.index'), |
|
55
|
1 |
|
'icon' => $urlGenerator->imagePath('announcementcenter', 'announcementcenter.svg'), |
|
56
|
1 |
|
'name' => $l->t('Announcements'), |
|
57
|
1 |
|
]; |
|
58
|
3 |
|
}); |
|
59
|
3 |
|
} |
|
60
|
|
|
|
|
61
|
3 |
|
protected function registerActivityExtension() { |
|
62
|
|
|
$this->getContainer()->getServer()->getActivityManager()->registerExtension(function() { |
|
63
|
1 |
|
return $this->getContainer()->query('OCA\AnnouncementCenter\Activity\Extension'); |
|
64
|
3 |
|
}); |
|
65
|
3 |
|
} |
|
66
|
|
|
|
|
67
|
3 |
|
protected function registerNotificationNotifier() { |
|
68
|
|
|
$this->getContainer()->getServer()->getNotificationManager()->registerNotifier(function() { |
|
69
|
1 |
|
return $this->getContainer()->query('OCA\AnnouncementCenter\Notification\Notifier'); |
|
70
|
3 |
|
}, function() { |
|
71
|
1 |
|
$l = $this->getContainer()->getServer()->getL10NFactory()->get('announcementcenter'); |
|
72
|
|
|
return [ |
|
73
|
1 |
|
'id' => 'announcementcenter', |
|
74
|
1 |
|
'name' => $l->t('Announcements'), |
|
75
|
1 |
|
]; |
|
76
|
3 |
|
}); |
|
77
|
3 |
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|