This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /** |
||
4 | * Nextcloud - OCR |
||
5 | * This file is licensed under the Affero General Public License version 3 or |
||
6 | * later. |
||
7 | * See the COPYING file. |
||
8 | * |
||
9 | * @author Janis Koehr <[email protected]> |
||
10 | * @copyright Janis Koehr 2017 |
||
11 | */ |
||
12 | namespace OCA\Ocr\AppInfo; |
||
13 | |||
14 | use OC\Files\View; |
||
15 | use OCA\Ocr\Controller\JobController; |
||
16 | use OCA\Ocr\Controller\PersonalSettingsController; |
||
17 | use OCA\Ocr\Db\FileMapper; |
||
18 | use OCA\Ocr\Db\OcrJobMapper; |
||
19 | use OCA\Ocr\Db\ShareMapper; |
||
20 | use OCA\Ocr\Service\JobService; |
||
21 | use OCP\AppFramework\App; |
||
22 | use OCP\AppFramework\IAppContainer; |
||
23 | use OCP\IContainer; |
||
24 | use OCA\Ocr\Controller\StatusController; |
||
25 | use OCA\Ocr\Service\StatusService; |
||
26 | use OCA\Ocr\Service\FileService; |
||
27 | use OCA\Ocr\Service\RedisService; |
||
28 | use OCA\Ocr\Service\AppConfigService; |
||
29 | use OCA\Ocr\Util\PHPUtil; |
||
30 | use OCA\Ocr\Util\FileUtil; |
||
31 | use OCA\Ocr\Util\RedisUtil; |
||
32 | use OCA\Ocr\Hooks\UserHooks; |
||
33 | use OCA\Ocr\Constants\OcrConstants; |
||
34 | |||
35 | |||
36 | /** |
||
37 | * Class Application |
||
38 | * |
||
39 | * @package OCA\Ocr\AppInfo |
||
40 | */ |
||
41 | class Application extends App { |
||
42 | |||
43 | /** |
||
44 | * Application constructor. |
||
45 | * |
||
46 | * @param array $urlParams |
||
47 | */ |
||
48 | 16 | public function __construct(array $urlParams = array()) { |
|
49 | 16 | parent::__construct(OcrConstants::APP_NAME, $urlParams); |
|
50 | 16 | $container = $this->getContainer(); |
|
51 | /** |
||
52 | * Add the js and style if OCA\Files app is loaded |
||
53 | */ |
||
54 | 16 | $eventDispatcher = \OC::$server->getEventDispatcher(); |
|
55 | 16 | $eventDispatcher->addListener('OCA\Files::loadAdditionalScripts', |
|
56 | 16 | function () { |
|
57 | script(OcrConstants::APP_NAME, 'dist/ocrapp'); |
||
58 | style(OcrConstants::APP_NAME, 'ocrstyle'); |
||
59 | // if not loaded before - load select2 for multi select languages |
||
60 | vendor_script('select2/select2'); |
||
61 | vendor_style('select2/select2'); |
||
62 | 16 | }); |
|
63 | /** |
||
64 | * Register core services |
||
65 | */ |
||
66 | 16 | $container->registerService('CurrentUID', |
|
67 | 16 | function (IContainer $c) { |
|
68 | /** @var \OC\Server $server */ |
||
69 | 5 | $server = $c->query('ServerContainer'); |
|
70 | 5 | $user = $server->getUserSession() |
|
71 | 5 | ->getUser(); |
|
72 | 5 | return ($user) ? $user->getUID() : ''; |
|
73 | 16 | }); |
|
74 | // Allow automatic DI for the View, until they migrated to Nodes API |
||
75 | 16 | $container->registerService(View::class, function () { |
|
76 | return new View(''); |
||
77 | 16 | }, false); |
|
78 | /** |
||
79 | * Register the PHPUtil |
||
80 | */ |
||
81 | 16 | $container->registerService('PHPUtil', |
|
82 | 16 | function (IContainer $c) { |
|
83 | /** @var \OC\Server $server */ |
||
84 | 5 | $server = $c->query('ServerContainer'); |
|
85 | 5 | return new PHPUtil($server->getL10N(OcrConstants::APP_NAME)); |
|
86 | 16 | }); |
|
87 | /** |
||
88 | * Register the RedisUtil |
||
89 | */ |
||
90 | 16 | $container->registerService('RedisUtil', |
|
91 | 16 | function (IContainer $c) { |
|
92 | /** @var \OC\Server $server */ |
||
93 | 7 | $server = $c->query('ServerContainer'); |
|
94 | 7 | return new RedisUtil($server->getL10N(OcrConstants::APP_NAME), $server->getLogger(), $server->getConfig()); |
|
95 | 16 | }); |
|
96 | /** |
||
97 | * Register the FileUtil |
||
98 | */ |
||
99 | 16 | $container->registerService('FileUtil', |
|
100 | 16 | function (IContainer $c) { |
|
0 ignored issues
–
show
|
|||
101 | 7 | return new FileUtil(); |
|
102 | 16 | }); |
|
103 | /** |
||
104 | * Register the Ocr Job mapper |
||
105 | */ |
||
106 | 16 | $container->registerService('OcrJobMapper', |
|
107 | 16 | function (IContainer $c) { |
|
108 | /** @var \OC\Server $server */ |
||
109 | 7 | $server = $c->query('ServerContainer'); |
|
110 | 7 | return new OcrJobMapper($server->getDatabaseConnection()); |
|
111 | 16 | }); |
|
112 | /** |
||
113 | * Register the File mapper |
||
114 | */ |
||
115 | 16 | $container->registerService('FileMapper', |
|
116 | 16 | function (IContainer $c) { |
|
117 | /** @var \OC\Server $server */ |
||
118 | 6 | $server = $c->query('ServerContainer'); |
|
119 | 6 | return new FileMapper($server->getDatabaseConnection()); |
|
120 | 16 | }); |
|
121 | /** |
||
122 | * Register the Share mapper |
||
123 | */ |
||
124 | 16 | $container->registerService('ShareMapper', |
|
125 | 16 | function (IContainer $c) { |
|
126 | /** @var \OC\Server $server */ |
||
127 | 6 | $server = $c->query('ServerContainer'); |
|
128 | 6 | return new ShareMapper($server->getDatabaseConnection()); |
|
129 | 16 | }); |
|
130 | /** |
||
131 | * Register the App Config Service |
||
132 | */ |
||
133 | 16 | $container->registerService('AppConfigService', |
|
134 | 16 | function (IAppContainer $c) { |
|
135 | /** @var \OC\Server $server */ |
||
136 | 5 | $server = $c->query('ServerContainer'); |
|
137 | 5 | return new AppConfigService($server->getConfig(), $server->getL10N(OcrConstants::APP_NAME), $c->query('RedisUtil'), |
|
138 | 5 | $server->getLogger()); |
|
139 | 16 | }); |
|
140 | /** |
||
141 | * Register the Job Service |
||
142 | */ |
||
143 | 16 | $container->registerService('FileService', |
|
144 | 16 | View Code Duplication | function (IAppContainer $c) { |
145 | /** @var \OC\Server $server */ |
||
146 | 5 | $server = $c->query('ServerContainer'); |
|
147 | 5 | return new FileService($server->getL10N(OcrConstants::APP_NAME), $server->getLogger(), $c->query('CurrentUID'), |
|
148 | 5 | $c->query('FileMapper'), $c->query('ShareMapper'), $c->query('FileUtil')); |
|
149 | 16 | }); |
|
150 | /** |
||
151 | * Register the Redis Service |
||
152 | */ |
||
153 | 16 | $container->registerService('RedisService', |
|
154 | 16 | View Code Duplication | function (IAppContainer $c) { |
155 | /** @var \OC\Server $server */ |
||
156 | 5 | $server = $c->query('ServerContainer'); |
|
157 | 5 | return new RedisService($c->query('OcrJobMapper'), $c->query('FileUtil'), $c->query('RedisUtil'), |
|
158 | 5 | $server->getL10N(OcrConstants::APP_NAME), $server->getLogger(), $server->getTempManager()); |
|
159 | 16 | }); |
|
160 | /** |
||
161 | * Register the Job Service |
||
162 | */ |
||
163 | 16 | $container->registerService('JobService', |
|
164 | 16 | function (IAppContainer $c) { |
|
165 | /** @var \OC\Server $server */ |
||
166 | 4 | $server = $c->query('ServerContainer'); |
|
167 | 4 | return new JobService($server->getL10N(OcrConstants::APP_NAME), $server->getLogger(), $c->query('CurrentUID'), |
|
168 | 4 | new View('/' . $c->query('CurrentUID') . '/files'), $server->getTempManager(), |
|
169 | 4 | $c->query('RedisService'), $c->query('OcrJobMapper'), $c->query('FileService'), |
|
170 | 4 | $c->query('AppConfigService'), $c->query('PHPUtil'), $c->query('FileUtil')); |
|
171 | 16 | }); |
|
172 | /** |
||
173 | * Register the Status Service |
||
174 | */ |
||
175 | 16 | $container->registerService('StatusService', |
|
176 | 16 | View Code Duplication | function (IAppContainer $c) { |
177 | /** @var \OC\Server $server */ |
||
178 | 2 | $server = $c->query('ServerContainer'); |
|
179 | 2 | return new StatusService($server->getL10N(OcrConstants::APP_NAME), $server->getLogger(), $c->query('CurrentUID'), |
|
180 | 2 | $c->query('OcrJobMapper'), $c->query('JobService')); |
|
181 | 16 | }); |
|
182 | /** |
||
183 | * Controller |
||
184 | */ |
||
185 | 16 | $container->registerService('StatusController', |
|
186 | 16 | View Code Duplication | function (IAppContainer $c) { |
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
187 | /** @var \OC\Server $server */ |
||
188 | 1 | $server = $c->query('ServerContainer'); |
|
189 | 1 | return new StatusController($c->getAppName(), $server->getRequest(), $c->query('StatusService')); |
|
190 | 16 | }); |
|
191 | /** |
||
192 | * Controller |
||
193 | */ |
||
194 | 16 | $container->registerService('JobController', |
|
195 | 16 | View Code Duplication | function (IAppContainer $c) { |
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
196 | /** @var \OC\Server $server */ |
||
197 | 1 | $server = $c->query('ServerContainer'); |
|
198 | 1 | return new JobController($c->getAppName(), $server->getRequest(), $c->query('JobService'), |
|
199 | 1 | $c->query('CurrentUID')); |
|
200 | 16 | }); |
|
201 | /** |
||
202 | * Controller |
||
203 | */ |
||
204 | 16 | $container->registerService('UserHooks', |
|
205 | 16 | function (IAppContainer $c) { |
|
206 | /** @var \OC\Server $server */ |
||
207 | 1 | $server = $c->query('ServerContainer'); |
|
208 | 1 | return new UserHooks($c->query('ServerContainer') |
|
209 | 1 | ->getUserManager(), $c->query('OcrJobMapper'), $server->getLogger()); |
|
210 | 16 | }); |
|
211 | /** |
||
212 | * Controller |
||
213 | */ |
||
214 | 16 | $container->registerAlias('PersonalSettingsController', PersonalSettingsController::class); |
|
215 | 16 | } |
|
216 | |||
217 | /** |
||
218 | * Registers the Personal Settings Page for deletion of status objects and such things. |
||
219 | * @codeCoverageIgnore |
||
220 | */ |
||
221 | public function registerPersonal() { |
||
222 | \OCP\App::registerPersonal($this->getContainer() |
||
223 | ->getAppName(), 'personal'); |
||
224 | } |
||
225 | |||
226 | /** |
||
227 | * Registers the User Hooks. |
||
228 | * @codeCoverageIgnore |
||
229 | */ |
||
230 | public function registerHooks() { |
||
231 | $this->getContainer() |
||
232 | ->query('UserHooks') |
||
233 | ->register(); |
||
234 | } |
||
235 | } |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.