1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
<?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/>.
*
*/
namespace OCA\Polls\AppInfo;
use OC\AppFramework\Utility\SimpleContainer;
use OCA\Polls\Controller\PageController;
use OCA\Polls\Db\CommentMapper;
use OCA\Polls\Db\DateMapper;
use OCA\Polls\Db\EventMapper;
use OCA\Polls\Db\NotificationMapper;
use OCA\Polls\Db\ParticipationMapper;
use OCA\Polls\Db\ParticipationTextMapper;
use OCA\Polls\Db\TextMapper;
use OCP\AppFramework\App;
class Application extends App {
/**
* Application constructor.
* @param array $urlParams
*/
public function __construct(array $urlParams = array()) {
parent::__construct('polls', $urlParams);
$container = $this->getContainer();
$server = $container->getServer();
/**
* Controllers
*/
$container->registerService('PageController', function (SimpleContainer $c) {
return new PageController(
$c->query('AppName'),
$c->query('Request'),
$c->query('UserManager'),
$c->query('GroupManager'),
$c->query('AvatarManager'),
$c->query('Logger'),
$c->query('L10N'),
$c->query('ServerContainer')->getURLGenerator(),
$c->query('UserId'),
$c->query('CommentMapper'),
$c->query('DateMapper'),
$c->query('EventMapper'),
$c->query('NotificationMapper'),
$c->query('ParticipationMapper'),
$c->query('ParticipationTextMapper'),
$c->query('TextMapper')
);
});
$container->registerService('UserManager', function (SimpleContainer $c) {
return $c->query('ServerContainer')->getUserManager();
});
$container->registerService('GroupManager', function (SimpleContainer $c) {
return $c->query('ServerContainer')->getGroupManager();
});
$container->registerService('AvatarManager', function (SimpleContainer $c) {
return $c->query('ServerContainer')->getAvatarManager();
});
$container->registerService('Logger', function (SimpleContainer $c) {
return $c->query('ServerContainer')->getLogger();
});
$container->registerService('L10N', function (SimpleContainer $c) {
return $c->query('ServerContainer')->getL10N($c->query('AppName'));
});
$container->registerService('CommentMapper', function (SimpleContainer $c) use ($server) {
return new CommentMapper(
$server->getDatabaseConnection()
);
});
$container->registerService('DateMapper', function (SimpleContainer $c) use ($server) {
return new DateMapper(
$server->getDatabaseConnection()
);
});
$container->registerService('EventMapper', function (SimpleContainer $c) use ($server) {
return new EventMapper(
$server->getDatabaseConnection()
);
});
$container->registerService('NotificationMapper', function (SimpleContainer $c) use ($server) {
return new NotificationMapper(
$server->getDatabaseConnection()
);
});
$container->registerService('ParticipationMapper', function (SimpleContainer $c) use ($server) {
return new ParticipationMapper(
$server->getDatabaseConnection()
);
});
$container->registerService('ParticipationTextMapper', function (SimpleContainer $c) use ($server) {
return new ParticipationTextMapper(
$server->getDatabaseConnection()
);
});
$container->registerService('TextMapper', function (SimpleContainer $c) use ($server) {
return new TextMapper(
$server->getDatabaseConnection()
);
});
}
/**
* Register navigation entry for main navigation.
*/
public function registerNavigationEntry() {
$container = $this->getContainer();
$container->query('OCP\INavigationManager')->add(function () use ($container) {
$urlGenerator = $container->query('OCP\IURLGenerator');
$l10n = $container->query('OCP\IL10N');
return [
'id' => 'polls',
'order' => 77,
'href' => $urlGenerator->linkToRoute('polls.page.index'),
'icon' => $urlGenerator->imagePath('polls', 'app.svg'),
'name' => $l10n->t('Polls')
];
});
}
}
|