@@ -30,64 +30,64 @@ |
||
30 | 30 | |
31 | 31 | class SyncFederationAddressBooks { |
32 | 32 | |
33 | - /** @var DbHandler */ |
|
34 | - protected $dbHandler; |
|
33 | + /** @var DbHandler */ |
|
34 | + protected $dbHandler; |
|
35 | 35 | |
36 | - /** @var SyncService */ |
|
37 | - private $syncService; |
|
36 | + /** @var SyncService */ |
|
37 | + private $syncService; |
|
38 | 38 | |
39 | - /** @var DiscoveryService */ |
|
40 | - private $ocsDiscoveryService; |
|
39 | + /** @var DiscoveryService */ |
|
40 | + private $ocsDiscoveryService; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @param DbHandler $dbHandler |
|
44 | - * @param SyncService $syncService |
|
45 | - * @param IDiscoveryService $ocsDiscoveryService |
|
46 | - */ |
|
47 | - public function __construct(DbHandler $dbHandler, |
|
48 | - SyncService $syncService, |
|
49 | - IDiscoveryService $ocsDiscoveryService |
|
50 | - ) { |
|
51 | - $this->syncService = $syncService; |
|
52 | - $this->dbHandler = $dbHandler; |
|
53 | - $this->ocsDiscoveryService = $ocsDiscoveryService; |
|
54 | - } |
|
42 | + /** |
|
43 | + * @param DbHandler $dbHandler |
|
44 | + * @param SyncService $syncService |
|
45 | + * @param IDiscoveryService $ocsDiscoveryService |
|
46 | + */ |
|
47 | + public function __construct(DbHandler $dbHandler, |
|
48 | + SyncService $syncService, |
|
49 | + IDiscoveryService $ocsDiscoveryService |
|
50 | + ) { |
|
51 | + $this->syncService = $syncService; |
|
52 | + $this->dbHandler = $dbHandler; |
|
53 | + $this->ocsDiscoveryService = $ocsDiscoveryService; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @param \Closure $callback |
|
58 | - */ |
|
59 | - public function syncThemAll(\Closure $callback) { |
|
56 | + /** |
|
57 | + * @param \Closure $callback |
|
58 | + */ |
|
59 | + public function syncThemAll(\Closure $callback) { |
|
60 | 60 | |
61 | - $trustedServers = $this->dbHandler->getAllServer(); |
|
62 | - foreach ($trustedServers as $trustedServer) { |
|
63 | - $url = $trustedServer['url']; |
|
64 | - $callback($url, null); |
|
65 | - $sharedSecret = $trustedServer['shared_secret']; |
|
66 | - $syncToken = $trustedServer['sync_token']; |
|
61 | + $trustedServers = $this->dbHandler->getAllServer(); |
|
62 | + foreach ($trustedServers as $trustedServer) { |
|
63 | + $url = $trustedServer['url']; |
|
64 | + $callback($url, null); |
|
65 | + $sharedSecret = $trustedServer['shared_secret']; |
|
66 | + $syncToken = $trustedServer['sync_token']; |
|
67 | 67 | |
68 | - $endPoints = $this->ocsDiscoveryService->discover($url, 'FEDERATED_SHARING'); |
|
69 | - $cardDavUser = isset($endPoints['carddav-user']) ? $endPoints['carddav-user'] : 'system'; |
|
70 | - $addressBookUrl = isset($endPoints['system-address-book']) ? trim($endPoints['system-address-book'], '/') : 'remote.php/dav/addressbooks/system/system/system'; |
|
68 | + $endPoints = $this->ocsDiscoveryService->discover($url, 'FEDERATED_SHARING'); |
|
69 | + $cardDavUser = isset($endPoints['carddav-user']) ? $endPoints['carddav-user'] : 'system'; |
|
70 | + $addressBookUrl = isset($endPoints['system-address-book']) ? trim($endPoints['system-address-book'], '/') : 'remote.php/dav/addressbooks/system/system/system'; |
|
71 | 71 | |
72 | - if (is_null($sharedSecret)) { |
|
73 | - continue; |
|
74 | - } |
|
75 | - $targetBookId = $trustedServer['url_hash']; |
|
76 | - $targetPrincipal = "principals/system/system"; |
|
77 | - $targetBookProperties = [ |
|
78 | - '{DAV:}displayname' => $url |
|
79 | - ]; |
|
80 | - try { |
|
81 | - $newToken = $this->syncService->syncRemoteAddressBook($url, $cardDavUser, $addressBookUrl, $sharedSecret, $syncToken, $targetBookId, $targetPrincipal, $targetBookProperties); |
|
82 | - if ($newToken !== $syncToken) { |
|
83 | - $this->dbHandler->setServerStatus($url, TrustedServers::STATUS_OK, $newToken); |
|
84 | - } |
|
85 | - } catch (\Exception $ex) { |
|
86 | - if ($ex->getCode() === Http::STATUS_UNAUTHORIZED) { |
|
87 | - $this->dbHandler->setServerStatus($url, TrustedServers::STATUS_ACCESS_REVOKED); |
|
88 | - } |
|
89 | - $callback($url, $ex); |
|
90 | - } |
|
91 | - } |
|
92 | - } |
|
72 | + if (is_null($sharedSecret)) { |
|
73 | + continue; |
|
74 | + } |
|
75 | + $targetBookId = $trustedServer['url_hash']; |
|
76 | + $targetPrincipal = "principals/system/system"; |
|
77 | + $targetBookProperties = [ |
|
78 | + '{DAV:}displayname' => $url |
|
79 | + ]; |
|
80 | + try { |
|
81 | + $newToken = $this->syncService->syncRemoteAddressBook($url, $cardDavUser, $addressBookUrl, $sharedSecret, $syncToken, $targetBookId, $targetPrincipal, $targetBookProperties); |
|
82 | + if ($newToken !== $syncToken) { |
|
83 | + $this->dbHandler->setServerStatus($url, TrustedServers::STATUS_OK, $newToken); |
|
84 | + } |
|
85 | + } catch (\Exception $ex) { |
|
86 | + if ($ex->getCode() === Http::STATUS_UNAUTHORIZED) { |
|
87 | + $this->dbHandler->setServerStatus($url, TrustedServers::STATUS_ACCESS_REVOKED); |
|
88 | + } |
|
89 | + $callback($url, $ex); |
|
90 | + } |
|
91 | + } |
|
92 | + } |
|
93 | 93 | } |
@@ -63,360 +63,360 @@ |
||
63 | 63 | |
64 | 64 | class DIContainer extends SimpleContainer implements IAppContainer { |
65 | 65 | |
66 | - /** |
|
67 | - * @var array |
|
68 | - */ |
|
69 | - private $middleWares = array(); |
|
70 | - |
|
71 | - /** @var ServerContainer */ |
|
72 | - private $server; |
|
73 | - |
|
74 | - /** |
|
75 | - * Put your class dependencies in here |
|
76 | - * @param string $appName the name of the app |
|
77 | - * @param array $urlParams |
|
78 | - * @param ServerContainer $server |
|
79 | - */ |
|
80 | - public function __construct($appName, $urlParams = array(), ServerContainer $server = null){ |
|
81 | - parent::__construct(); |
|
82 | - $this['AppName'] = $appName; |
|
83 | - $this['urlParams'] = $urlParams; |
|
84 | - |
|
85 | - /** @var \OC\ServerContainer $server */ |
|
86 | - if ($server === null) { |
|
87 | - $server = \OC::$server; |
|
88 | - } |
|
89 | - $this->server = $server; |
|
90 | - $this->server->registerAppContainer($appName, $this); |
|
91 | - |
|
92 | - // aliases |
|
93 | - $this->registerAlias('appName', 'AppName'); |
|
94 | - $this->registerAlias('webRoot', 'WebRoot'); |
|
95 | - $this->registerAlias('userId', 'UserId'); |
|
96 | - |
|
97 | - /** |
|
98 | - * Core services |
|
99 | - */ |
|
100 | - $this->registerService(IOutput::class, function($c){ |
|
101 | - return new Output($this->getServer()->getWebRoot()); |
|
102 | - }); |
|
103 | - |
|
104 | - $this->registerService(Folder::class, function() { |
|
105 | - return $this->getServer()->getUserFolder(); |
|
106 | - }); |
|
107 | - |
|
108 | - $this->registerService(IAppData::class, function (SimpleContainer $c) { |
|
109 | - return $this->getServer()->getAppDataDir($c->query('AppName')); |
|
110 | - }); |
|
111 | - |
|
112 | - $this->registerService(IL10N::class, function($c) { |
|
113 | - return $this->getServer()->getL10N($c->query('AppName')); |
|
114 | - }); |
|
115 | - |
|
116 | - $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
117 | - $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
118 | - |
|
119 | - $this->registerService(IRequest::class, function() { |
|
120 | - return $this->getServer()->query(IRequest::class); |
|
121 | - }); |
|
122 | - $this->registerAlias('Request', IRequest::class); |
|
123 | - |
|
124 | - $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
125 | - $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
126 | - |
|
127 | - $this->registerAlias(\OC\User\Session::class, \OCP\IUserSession::class); |
|
128 | - |
|
129 | - $this->registerService(IServerContainer::class, function ($c) { |
|
130 | - return $this->getServer(); |
|
131 | - }); |
|
132 | - $this->registerAlias('ServerContainer', IServerContainer::class); |
|
133 | - |
|
134 | - $this->registerService(\OCP\WorkflowEngine\IManager::class, function ($c) { |
|
135 | - return $c->query('OCA\WorkflowEngine\Manager'); |
|
136 | - }); |
|
137 | - |
|
138 | - $this->registerService(\OCP\AppFramework\IAppContainer::class, function ($c) { |
|
139 | - return $c; |
|
140 | - }); |
|
141 | - |
|
142 | - $this->registerService(IMountManager::class, function () { |
|
143 | - return $this->getServer()->getMountManager(); |
|
144 | - }); |
|
145 | - $this->registerService(IDiscoveryService::class, function($c) { |
|
146 | - return $this->getServer()->getOCSDiscoveryService(); |
|
147 | - }); |
|
148 | - |
|
149 | - // commonly used attributes |
|
150 | - $this->registerService('UserId', function ($c) { |
|
151 | - return $c->query('OCP\\IUserSession')->getSession()->get('user_id'); |
|
152 | - }); |
|
153 | - |
|
154 | - $this->registerService('WebRoot', function ($c) { |
|
155 | - return $c->query('ServerContainer')->getWebRoot(); |
|
156 | - }); |
|
157 | - |
|
158 | - $this->registerService('fromMailAddress', function() { |
|
159 | - return Util::getDefaultEmailAddress('no-reply'); |
|
160 | - }); |
|
161 | - |
|
162 | - $this->registerService('OC_Defaults', function ($c) { |
|
163 | - return $c->getServer()->getThemingDefaults(); |
|
164 | - }); |
|
165 | - |
|
166 | - $this->registerService('OCP\Encryption\IManager', function ($c) { |
|
167 | - return $this->getServer()->getEncryptionManager(); |
|
168 | - }); |
|
169 | - |
|
170 | - $this->registerService(IValidator::class, function($c) { |
|
171 | - return $c->query(Validator::class); |
|
172 | - }); |
|
173 | - |
|
174 | - $this->registerService(\OC\Security\IdentityProof\Manager::class, function ($c) { |
|
175 | - return new \OC\Security\IdentityProof\Manager( |
|
176 | - $this->getServer()->getAppDataDir('identityproof'), |
|
177 | - $this->getServer()->getCrypto() |
|
178 | - ); |
|
179 | - }); |
|
180 | - |
|
181 | - |
|
182 | - /** |
|
183 | - * App Framework APIs |
|
184 | - */ |
|
185 | - $this->registerService('API', function($c){ |
|
186 | - $c->query('OCP\\ILogger')->debug( |
|
187 | - 'Accessing the API class is deprecated! Use the appropriate ' . |
|
188 | - 'services instead!' |
|
189 | - ); |
|
190 | - return new API($c['AppName']); |
|
191 | - }); |
|
192 | - |
|
193 | - $this->registerService('Protocol', function($c){ |
|
194 | - /** @var \OC\Server $server */ |
|
195 | - $server = $c->query('ServerContainer'); |
|
196 | - $protocol = $server->getRequest()->getHttpProtocol(); |
|
197 | - return new Http($_SERVER, $protocol); |
|
198 | - }); |
|
199 | - |
|
200 | - $this->registerService('Dispatcher', function($c) { |
|
201 | - return new Dispatcher( |
|
202 | - $c['Protocol'], |
|
203 | - $c['MiddlewareDispatcher'], |
|
204 | - $c['ControllerMethodReflector'], |
|
205 | - $c['Request'] |
|
206 | - ); |
|
207 | - }); |
|
208 | - |
|
209 | - /** |
|
210 | - * App Framework default arguments |
|
211 | - */ |
|
212 | - $this->registerParameter('corsMethods', 'PUT, POST, GET, DELETE, PATCH'); |
|
213 | - $this->registerParameter('corsAllowedHeaders', 'Authorization, Content-Type, Accept'); |
|
214 | - $this->registerParameter('corsMaxAge', 1728000); |
|
215 | - |
|
216 | - /** |
|
217 | - * Middleware |
|
218 | - */ |
|
219 | - $app = $this; |
|
220 | - $this->registerService('SecurityMiddleware', function($c) use ($app){ |
|
221 | - /** @var \OC\Server $server */ |
|
222 | - $server = $app->getServer(); |
|
223 | - |
|
224 | - return new SecurityMiddleware( |
|
225 | - $c['Request'], |
|
226 | - $c['ControllerMethodReflector'], |
|
227 | - $server->getNavigationManager(), |
|
228 | - $server->getURLGenerator(), |
|
229 | - $server->getLogger(), |
|
230 | - $server->getSession(), |
|
231 | - $c['AppName'], |
|
232 | - $app->isLoggedIn(), |
|
233 | - $app->isAdminUser(), |
|
234 | - $server->getContentSecurityPolicyManager(), |
|
235 | - $server->getCsrfTokenManager(), |
|
236 | - $server->getContentSecurityPolicyNonceManager(), |
|
237 | - $server->getBruteForceThrottler() |
|
238 | - ); |
|
239 | - |
|
240 | - }); |
|
241 | - |
|
242 | - $this->registerService('CORSMiddleware', function($c) { |
|
243 | - return new CORSMiddleware( |
|
244 | - $c['Request'], |
|
245 | - $c['ControllerMethodReflector'], |
|
246 | - $c->query(IUserSession::class), |
|
247 | - $c->getServer()->getBruteForceThrottler() |
|
248 | - ); |
|
249 | - }); |
|
250 | - |
|
251 | - $this->registerService('SessionMiddleware', function($c) use ($app) { |
|
252 | - return new SessionMiddleware( |
|
253 | - $c['Request'], |
|
254 | - $c['ControllerMethodReflector'], |
|
255 | - $app->getServer()->getSession() |
|
256 | - ); |
|
257 | - }); |
|
258 | - |
|
259 | - $this->registerService('TwoFactorMiddleware', function (SimpleContainer $c) use ($app) { |
|
260 | - $twoFactorManager = $c->getServer()->getTwoFactorAuthManager(); |
|
261 | - $userSession = $app->getServer()->getUserSession(); |
|
262 | - $session = $app->getServer()->getSession(); |
|
263 | - $urlGenerator = $app->getServer()->getURLGenerator(); |
|
264 | - $reflector = $c['ControllerMethodReflector']; |
|
265 | - $request = $app->getServer()->getRequest(); |
|
266 | - return new TwoFactorMiddleware($twoFactorManager, $userSession, $session, $urlGenerator, $reflector, $request); |
|
267 | - }); |
|
268 | - |
|
269 | - $this->registerService('OCSMiddleware', function (SimpleContainer $c) { |
|
270 | - return new OCSMiddleware( |
|
271 | - $c['Request'] |
|
272 | - ); |
|
273 | - }); |
|
274 | - |
|
275 | - $middleWares = &$this->middleWares; |
|
276 | - $this->registerService('MiddlewareDispatcher', function($c) use (&$middleWares) { |
|
277 | - $dispatcher = new MiddlewareDispatcher(); |
|
278 | - $dispatcher->registerMiddleware($c['CORSMiddleware']); |
|
279 | - $dispatcher->registerMiddleware($c['OCSMiddleware']); |
|
280 | - $dispatcher->registerMiddleware($c['SecurityMiddleware']); |
|
281 | - $dispatcher->registerMiddleWare($c['TwoFactorMiddleware']); |
|
282 | - |
|
283 | - foreach($middleWares as $middleWare) { |
|
284 | - $dispatcher->registerMiddleware($c[$middleWare]); |
|
285 | - } |
|
286 | - |
|
287 | - $dispatcher->registerMiddleware($c['SessionMiddleware']); |
|
288 | - return $dispatcher; |
|
289 | - }); |
|
290 | - |
|
291 | - } |
|
292 | - |
|
293 | - |
|
294 | - /** |
|
295 | - * @deprecated implements only deprecated methods |
|
296 | - * @return IApi |
|
297 | - */ |
|
298 | - function getCoreApi() |
|
299 | - { |
|
300 | - return $this->query('API'); |
|
301 | - } |
|
302 | - |
|
303 | - /** |
|
304 | - * @return \OCP\IServerContainer |
|
305 | - */ |
|
306 | - function getServer() |
|
307 | - { |
|
308 | - return $this->server; |
|
309 | - } |
|
310 | - |
|
311 | - /** |
|
312 | - * @param string $middleWare |
|
313 | - * @return boolean|null |
|
314 | - */ |
|
315 | - function registerMiddleWare($middleWare) { |
|
316 | - array_push($this->middleWares, $middleWare); |
|
317 | - } |
|
318 | - |
|
319 | - /** |
|
320 | - * used to return the appname of the set application |
|
321 | - * @return string the name of your application |
|
322 | - */ |
|
323 | - function getAppName() { |
|
324 | - return $this->query('AppName'); |
|
325 | - } |
|
326 | - |
|
327 | - /** |
|
328 | - * @deprecated use IUserSession->isLoggedIn() |
|
329 | - * @return boolean |
|
330 | - */ |
|
331 | - function isLoggedIn() { |
|
332 | - return \OC::$server->getUserSession()->isLoggedIn(); |
|
333 | - } |
|
334 | - |
|
335 | - /** |
|
336 | - * @deprecated use IGroupManager->isAdmin($userId) |
|
337 | - * @return boolean |
|
338 | - */ |
|
339 | - function isAdminUser() { |
|
340 | - $uid = $this->getUserId(); |
|
341 | - return \OC_User::isAdminUser($uid); |
|
342 | - } |
|
343 | - |
|
344 | - private function getUserId() { |
|
345 | - return $this->getServer()->getSession()->get('user_id'); |
|
346 | - } |
|
347 | - |
|
348 | - /** |
|
349 | - * @deprecated use the ILogger instead |
|
350 | - * @param string $message |
|
351 | - * @param string $level |
|
352 | - * @return mixed |
|
353 | - */ |
|
354 | - function log($message, $level) { |
|
355 | - switch($level){ |
|
356 | - case 'debug': |
|
357 | - $level = \OCP\Util::DEBUG; |
|
358 | - break; |
|
359 | - case 'info': |
|
360 | - $level = \OCP\Util::INFO; |
|
361 | - break; |
|
362 | - case 'warn': |
|
363 | - $level = \OCP\Util::WARN; |
|
364 | - break; |
|
365 | - case 'fatal': |
|
366 | - $level = \OCP\Util::FATAL; |
|
367 | - break; |
|
368 | - default: |
|
369 | - $level = \OCP\Util::ERROR; |
|
370 | - break; |
|
371 | - } |
|
372 | - \OCP\Util::writeLog($this->getAppName(), $message, $level); |
|
373 | - } |
|
374 | - |
|
375 | - /** |
|
376 | - * Register a capability |
|
377 | - * |
|
378 | - * @param string $serviceName e.g. 'OCA\Files\Capabilities' |
|
379 | - */ |
|
380 | - public function registerCapability($serviceName) { |
|
381 | - $this->query('OC\CapabilitiesManager')->registerCapability(function() use ($serviceName) { |
|
382 | - return $this->query($serviceName); |
|
383 | - }); |
|
384 | - } |
|
385 | - |
|
386 | - /** |
|
387 | - * @param string $name |
|
388 | - * @return mixed |
|
389 | - * @throws QueryException if the query could not be resolved |
|
390 | - */ |
|
391 | - public function query($name) { |
|
392 | - try { |
|
393 | - return $this->queryNoFallback($name); |
|
394 | - } catch (QueryException $e) { |
|
395 | - return $this->getServer()->query($name); |
|
396 | - } |
|
397 | - } |
|
398 | - |
|
399 | - /** |
|
400 | - * @param string $name |
|
401 | - * @return mixed |
|
402 | - * @throws QueryException if the query could not be resolved |
|
403 | - */ |
|
404 | - public function queryNoFallback($name) { |
|
405 | - $name = $this->sanitizeName($name); |
|
406 | - |
|
407 | - if ($this->offsetExists($name)) { |
|
408 | - return parent::query($name); |
|
409 | - } else { |
|
410 | - if ($this['AppName'] === 'settings' && strpos($name, 'OC\\Settings\\') === 0) { |
|
411 | - return parent::query($name); |
|
412 | - } else if ($this['AppName'] === 'core' && strpos($name, 'OC\\Core\\') === 0) { |
|
413 | - return parent::query($name); |
|
414 | - } else if (strpos($name, \OC\AppFramework\App::buildAppNamespace($this['AppName']) . '\\') === 0) { |
|
415 | - return parent::query($name); |
|
416 | - } |
|
417 | - } |
|
418 | - |
|
419 | - throw new QueryException('Could not resolve ' . $name . '!' . |
|
420 | - ' Class can not be instantiated'); |
|
421 | - } |
|
66 | + /** |
|
67 | + * @var array |
|
68 | + */ |
|
69 | + private $middleWares = array(); |
|
70 | + |
|
71 | + /** @var ServerContainer */ |
|
72 | + private $server; |
|
73 | + |
|
74 | + /** |
|
75 | + * Put your class dependencies in here |
|
76 | + * @param string $appName the name of the app |
|
77 | + * @param array $urlParams |
|
78 | + * @param ServerContainer $server |
|
79 | + */ |
|
80 | + public function __construct($appName, $urlParams = array(), ServerContainer $server = null){ |
|
81 | + parent::__construct(); |
|
82 | + $this['AppName'] = $appName; |
|
83 | + $this['urlParams'] = $urlParams; |
|
84 | + |
|
85 | + /** @var \OC\ServerContainer $server */ |
|
86 | + if ($server === null) { |
|
87 | + $server = \OC::$server; |
|
88 | + } |
|
89 | + $this->server = $server; |
|
90 | + $this->server->registerAppContainer($appName, $this); |
|
91 | + |
|
92 | + // aliases |
|
93 | + $this->registerAlias('appName', 'AppName'); |
|
94 | + $this->registerAlias('webRoot', 'WebRoot'); |
|
95 | + $this->registerAlias('userId', 'UserId'); |
|
96 | + |
|
97 | + /** |
|
98 | + * Core services |
|
99 | + */ |
|
100 | + $this->registerService(IOutput::class, function($c){ |
|
101 | + return new Output($this->getServer()->getWebRoot()); |
|
102 | + }); |
|
103 | + |
|
104 | + $this->registerService(Folder::class, function() { |
|
105 | + return $this->getServer()->getUserFolder(); |
|
106 | + }); |
|
107 | + |
|
108 | + $this->registerService(IAppData::class, function (SimpleContainer $c) { |
|
109 | + return $this->getServer()->getAppDataDir($c->query('AppName')); |
|
110 | + }); |
|
111 | + |
|
112 | + $this->registerService(IL10N::class, function($c) { |
|
113 | + return $this->getServer()->getL10N($c->query('AppName')); |
|
114 | + }); |
|
115 | + |
|
116 | + $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
117 | + $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
118 | + |
|
119 | + $this->registerService(IRequest::class, function() { |
|
120 | + return $this->getServer()->query(IRequest::class); |
|
121 | + }); |
|
122 | + $this->registerAlias('Request', IRequest::class); |
|
123 | + |
|
124 | + $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
125 | + $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
126 | + |
|
127 | + $this->registerAlias(\OC\User\Session::class, \OCP\IUserSession::class); |
|
128 | + |
|
129 | + $this->registerService(IServerContainer::class, function ($c) { |
|
130 | + return $this->getServer(); |
|
131 | + }); |
|
132 | + $this->registerAlias('ServerContainer', IServerContainer::class); |
|
133 | + |
|
134 | + $this->registerService(\OCP\WorkflowEngine\IManager::class, function ($c) { |
|
135 | + return $c->query('OCA\WorkflowEngine\Manager'); |
|
136 | + }); |
|
137 | + |
|
138 | + $this->registerService(\OCP\AppFramework\IAppContainer::class, function ($c) { |
|
139 | + return $c; |
|
140 | + }); |
|
141 | + |
|
142 | + $this->registerService(IMountManager::class, function () { |
|
143 | + return $this->getServer()->getMountManager(); |
|
144 | + }); |
|
145 | + $this->registerService(IDiscoveryService::class, function($c) { |
|
146 | + return $this->getServer()->getOCSDiscoveryService(); |
|
147 | + }); |
|
148 | + |
|
149 | + // commonly used attributes |
|
150 | + $this->registerService('UserId', function ($c) { |
|
151 | + return $c->query('OCP\\IUserSession')->getSession()->get('user_id'); |
|
152 | + }); |
|
153 | + |
|
154 | + $this->registerService('WebRoot', function ($c) { |
|
155 | + return $c->query('ServerContainer')->getWebRoot(); |
|
156 | + }); |
|
157 | + |
|
158 | + $this->registerService('fromMailAddress', function() { |
|
159 | + return Util::getDefaultEmailAddress('no-reply'); |
|
160 | + }); |
|
161 | + |
|
162 | + $this->registerService('OC_Defaults', function ($c) { |
|
163 | + return $c->getServer()->getThemingDefaults(); |
|
164 | + }); |
|
165 | + |
|
166 | + $this->registerService('OCP\Encryption\IManager', function ($c) { |
|
167 | + return $this->getServer()->getEncryptionManager(); |
|
168 | + }); |
|
169 | + |
|
170 | + $this->registerService(IValidator::class, function($c) { |
|
171 | + return $c->query(Validator::class); |
|
172 | + }); |
|
173 | + |
|
174 | + $this->registerService(\OC\Security\IdentityProof\Manager::class, function ($c) { |
|
175 | + return new \OC\Security\IdentityProof\Manager( |
|
176 | + $this->getServer()->getAppDataDir('identityproof'), |
|
177 | + $this->getServer()->getCrypto() |
|
178 | + ); |
|
179 | + }); |
|
180 | + |
|
181 | + |
|
182 | + /** |
|
183 | + * App Framework APIs |
|
184 | + */ |
|
185 | + $this->registerService('API', function($c){ |
|
186 | + $c->query('OCP\\ILogger')->debug( |
|
187 | + 'Accessing the API class is deprecated! Use the appropriate ' . |
|
188 | + 'services instead!' |
|
189 | + ); |
|
190 | + return new API($c['AppName']); |
|
191 | + }); |
|
192 | + |
|
193 | + $this->registerService('Protocol', function($c){ |
|
194 | + /** @var \OC\Server $server */ |
|
195 | + $server = $c->query('ServerContainer'); |
|
196 | + $protocol = $server->getRequest()->getHttpProtocol(); |
|
197 | + return new Http($_SERVER, $protocol); |
|
198 | + }); |
|
199 | + |
|
200 | + $this->registerService('Dispatcher', function($c) { |
|
201 | + return new Dispatcher( |
|
202 | + $c['Protocol'], |
|
203 | + $c['MiddlewareDispatcher'], |
|
204 | + $c['ControllerMethodReflector'], |
|
205 | + $c['Request'] |
|
206 | + ); |
|
207 | + }); |
|
208 | + |
|
209 | + /** |
|
210 | + * App Framework default arguments |
|
211 | + */ |
|
212 | + $this->registerParameter('corsMethods', 'PUT, POST, GET, DELETE, PATCH'); |
|
213 | + $this->registerParameter('corsAllowedHeaders', 'Authorization, Content-Type, Accept'); |
|
214 | + $this->registerParameter('corsMaxAge', 1728000); |
|
215 | + |
|
216 | + /** |
|
217 | + * Middleware |
|
218 | + */ |
|
219 | + $app = $this; |
|
220 | + $this->registerService('SecurityMiddleware', function($c) use ($app){ |
|
221 | + /** @var \OC\Server $server */ |
|
222 | + $server = $app->getServer(); |
|
223 | + |
|
224 | + return new SecurityMiddleware( |
|
225 | + $c['Request'], |
|
226 | + $c['ControllerMethodReflector'], |
|
227 | + $server->getNavigationManager(), |
|
228 | + $server->getURLGenerator(), |
|
229 | + $server->getLogger(), |
|
230 | + $server->getSession(), |
|
231 | + $c['AppName'], |
|
232 | + $app->isLoggedIn(), |
|
233 | + $app->isAdminUser(), |
|
234 | + $server->getContentSecurityPolicyManager(), |
|
235 | + $server->getCsrfTokenManager(), |
|
236 | + $server->getContentSecurityPolicyNonceManager(), |
|
237 | + $server->getBruteForceThrottler() |
|
238 | + ); |
|
239 | + |
|
240 | + }); |
|
241 | + |
|
242 | + $this->registerService('CORSMiddleware', function($c) { |
|
243 | + return new CORSMiddleware( |
|
244 | + $c['Request'], |
|
245 | + $c['ControllerMethodReflector'], |
|
246 | + $c->query(IUserSession::class), |
|
247 | + $c->getServer()->getBruteForceThrottler() |
|
248 | + ); |
|
249 | + }); |
|
250 | + |
|
251 | + $this->registerService('SessionMiddleware', function($c) use ($app) { |
|
252 | + return new SessionMiddleware( |
|
253 | + $c['Request'], |
|
254 | + $c['ControllerMethodReflector'], |
|
255 | + $app->getServer()->getSession() |
|
256 | + ); |
|
257 | + }); |
|
258 | + |
|
259 | + $this->registerService('TwoFactorMiddleware', function (SimpleContainer $c) use ($app) { |
|
260 | + $twoFactorManager = $c->getServer()->getTwoFactorAuthManager(); |
|
261 | + $userSession = $app->getServer()->getUserSession(); |
|
262 | + $session = $app->getServer()->getSession(); |
|
263 | + $urlGenerator = $app->getServer()->getURLGenerator(); |
|
264 | + $reflector = $c['ControllerMethodReflector']; |
|
265 | + $request = $app->getServer()->getRequest(); |
|
266 | + return new TwoFactorMiddleware($twoFactorManager, $userSession, $session, $urlGenerator, $reflector, $request); |
|
267 | + }); |
|
268 | + |
|
269 | + $this->registerService('OCSMiddleware', function (SimpleContainer $c) { |
|
270 | + return new OCSMiddleware( |
|
271 | + $c['Request'] |
|
272 | + ); |
|
273 | + }); |
|
274 | + |
|
275 | + $middleWares = &$this->middleWares; |
|
276 | + $this->registerService('MiddlewareDispatcher', function($c) use (&$middleWares) { |
|
277 | + $dispatcher = new MiddlewareDispatcher(); |
|
278 | + $dispatcher->registerMiddleware($c['CORSMiddleware']); |
|
279 | + $dispatcher->registerMiddleware($c['OCSMiddleware']); |
|
280 | + $dispatcher->registerMiddleware($c['SecurityMiddleware']); |
|
281 | + $dispatcher->registerMiddleWare($c['TwoFactorMiddleware']); |
|
282 | + |
|
283 | + foreach($middleWares as $middleWare) { |
|
284 | + $dispatcher->registerMiddleware($c[$middleWare]); |
|
285 | + } |
|
286 | + |
|
287 | + $dispatcher->registerMiddleware($c['SessionMiddleware']); |
|
288 | + return $dispatcher; |
|
289 | + }); |
|
290 | + |
|
291 | + } |
|
292 | + |
|
293 | + |
|
294 | + /** |
|
295 | + * @deprecated implements only deprecated methods |
|
296 | + * @return IApi |
|
297 | + */ |
|
298 | + function getCoreApi() |
|
299 | + { |
|
300 | + return $this->query('API'); |
|
301 | + } |
|
302 | + |
|
303 | + /** |
|
304 | + * @return \OCP\IServerContainer |
|
305 | + */ |
|
306 | + function getServer() |
|
307 | + { |
|
308 | + return $this->server; |
|
309 | + } |
|
310 | + |
|
311 | + /** |
|
312 | + * @param string $middleWare |
|
313 | + * @return boolean|null |
|
314 | + */ |
|
315 | + function registerMiddleWare($middleWare) { |
|
316 | + array_push($this->middleWares, $middleWare); |
|
317 | + } |
|
318 | + |
|
319 | + /** |
|
320 | + * used to return the appname of the set application |
|
321 | + * @return string the name of your application |
|
322 | + */ |
|
323 | + function getAppName() { |
|
324 | + return $this->query('AppName'); |
|
325 | + } |
|
326 | + |
|
327 | + /** |
|
328 | + * @deprecated use IUserSession->isLoggedIn() |
|
329 | + * @return boolean |
|
330 | + */ |
|
331 | + function isLoggedIn() { |
|
332 | + return \OC::$server->getUserSession()->isLoggedIn(); |
|
333 | + } |
|
334 | + |
|
335 | + /** |
|
336 | + * @deprecated use IGroupManager->isAdmin($userId) |
|
337 | + * @return boolean |
|
338 | + */ |
|
339 | + function isAdminUser() { |
|
340 | + $uid = $this->getUserId(); |
|
341 | + return \OC_User::isAdminUser($uid); |
|
342 | + } |
|
343 | + |
|
344 | + private function getUserId() { |
|
345 | + return $this->getServer()->getSession()->get('user_id'); |
|
346 | + } |
|
347 | + |
|
348 | + /** |
|
349 | + * @deprecated use the ILogger instead |
|
350 | + * @param string $message |
|
351 | + * @param string $level |
|
352 | + * @return mixed |
|
353 | + */ |
|
354 | + function log($message, $level) { |
|
355 | + switch($level){ |
|
356 | + case 'debug': |
|
357 | + $level = \OCP\Util::DEBUG; |
|
358 | + break; |
|
359 | + case 'info': |
|
360 | + $level = \OCP\Util::INFO; |
|
361 | + break; |
|
362 | + case 'warn': |
|
363 | + $level = \OCP\Util::WARN; |
|
364 | + break; |
|
365 | + case 'fatal': |
|
366 | + $level = \OCP\Util::FATAL; |
|
367 | + break; |
|
368 | + default: |
|
369 | + $level = \OCP\Util::ERROR; |
|
370 | + break; |
|
371 | + } |
|
372 | + \OCP\Util::writeLog($this->getAppName(), $message, $level); |
|
373 | + } |
|
374 | + |
|
375 | + /** |
|
376 | + * Register a capability |
|
377 | + * |
|
378 | + * @param string $serviceName e.g. 'OCA\Files\Capabilities' |
|
379 | + */ |
|
380 | + public function registerCapability($serviceName) { |
|
381 | + $this->query('OC\CapabilitiesManager')->registerCapability(function() use ($serviceName) { |
|
382 | + return $this->query($serviceName); |
|
383 | + }); |
|
384 | + } |
|
385 | + |
|
386 | + /** |
|
387 | + * @param string $name |
|
388 | + * @return mixed |
|
389 | + * @throws QueryException if the query could not be resolved |
|
390 | + */ |
|
391 | + public function query($name) { |
|
392 | + try { |
|
393 | + return $this->queryNoFallback($name); |
|
394 | + } catch (QueryException $e) { |
|
395 | + return $this->getServer()->query($name); |
|
396 | + } |
|
397 | + } |
|
398 | + |
|
399 | + /** |
|
400 | + * @param string $name |
|
401 | + * @return mixed |
|
402 | + * @throws QueryException if the query could not be resolved |
|
403 | + */ |
|
404 | + public function queryNoFallback($name) { |
|
405 | + $name = $this->sanitizeName($name); |
|
406 | + |
|
407 | + if ($this->offsetExists($name)) { |
|
408 | + return parent::query($name); |
|
409 | + } else { |
|
410 | + if ($this['AppName'] === 'settings' && strpos($name, 'OC\\Settings\\') === 0) { |
|
411 | + return parent::query($name); |
|
412 | + } else if ($this['AppName'] === 'core' && strpos($name, 'OC\\Core\\') === 0) { |
|
413 | + return parent::query($name); |
|
414 | + } else if (strpos($name, \OC\AppFramework\App::buildAppNamespace($this['AppName']) . '\\') === 0) { |
|
415 | + return parent::query($name); |
|
416 | + } |
|
417 | + } |
|
418 | + |
|
419 | + throw new QueryException('Could not resolve ' . $name . '!' . |
|
420 | + ' Class can not be instantiated'); |
|
421 | + } |
|
422 | 422 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @param array $urlParams |
78 | 78 | * @param ServerContainer $server |
79 | 79 | */ |
80 | - public function __construct($appName, $urlParams = array(), ServerContainer $server = null){ |
|
80 | + public function __construct($appName, $urlParams = array(), ServerContainer $server = null) { |
|
81 | 81 | parent::__construct(); |
82 | 82 | $this['AppName'] = $appName; |
83 | 83 | $this['urlParams'] = $urlParams; |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | /** |
98 | 98 | * Core services |
99 | 99 | */ |
100 | - $this->registerService(IOutput::class, function($c){ |
|
100 | + $this->registerService(IOutput::class, function($c) { |
|
101 | 101 | return new Output($this->getServer()->getWebRoot()); |
102 | 102 | }); |
103 | 103 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | return $this->getServer()->getUserFolder(); |
106 | 106 | }); |
107 | 107 | |
108 | - $this->registerService(IAppData::class, function (SimpleContainer $c) { |
|
108 | + $this->registerService(IAppData::class, function(SimpleContainer $c) { |
|
109 | 109 | return $this->getServer()->getAppDataDir($c->query('AppName')); |
110 | 110 | }); |
111 | 111 | |
@@ -126,20 +126,20 @@ discard block |
||
126 | 126 | |
127 | 127 | $this->registerAlias(\OC\User\Session::class, \OCP\IUserSession::class); |
128 | 128 | |
129 | - $this->registerService(IServerContainer::class, function ($c) { |
|
129 | + $this->registerService(IServerContainer::class, function($c) { |
|
130 | 130 | return $this->getServer(); |
131 | 131 | }); |
132 | 132 | $this->registerAlias('ServerContainer', IServerContainer::class); |
133 | 133 | |
134 | - $this->registerService(\OCP\WorkflowEngine\IManager::class, function ($c) { |
|
134 | + $this->registerService(\OCP\WorkflowEngine\IManager::class, function($c) { |
|
135 | 135 | return $c->query('OCA\WorkflowEngine\Manager'); |
136 | 136 | }); |
137 | 137 | |
138 | - $this->registerService(\OCP\AppFramework\IAppContainer::class, function ($c) { |
|
138 | + $this->registerService(\OCP\AppFramework\IAppContainer::class, function($c) { |
|
139 | 139 | return $c; |
140 | 140 | }); |
141 | 141 | |
142 | - $this->registerService(IMountManager::class, function () { |
|
142 | + $this->registerService(IMountManager::class, function() { |
|
143 | 143 | return $this->getServer()->getMountManager(); |
144 | 144 | }); |
145 | 145 | $this->registerService(IDiscoveryService::class, function($c) { |
@@ -147,11 +147,11 @@ discard block |
||
147 | 147 | }); |
148 | 148 | |
149 | 149 | // commonly used attributes |
150 | - $this->registerService('UserId', function ($c) { |
|
150 | + $this->registerService('UserId', function($c) { |
|
151 | 151 | return $c->query('OCP\\IUserSession')->getSession()->get('user_id'); |
152 | 152 | }); |
153 | 153 | |
154 | - $this->registerService('WebRoot', function ($c) { |
|
154 | + $this->registerService('WebRoot', function($c) { |
|
155 | 155 | return $c->query('ServerContainer')->getWebRoot(); |
156 | 156 | }); |
157 | 157 | |
@@ -159,11 +159,11 @@ discard block |
||
159 | 159 | return Util::getDefaultEmailAddress('no-reply'); |
160 | 160 | }); |
161 | 161 | |
162 | - $this->registerService('OC_Defaults', function ($c) { |
|
162 | + $this->registerService('OC_Defaults', function($c) { |
|
163 | 163 | return $c->getServer()->getThemingDefaults(); |
164 | 164 | }); |
165 | 165 | |
166 | - $this->registerService('OCP\Encryption\IManager', function ($c) { |
|
166 | + $this->registerService('OCP\Encryption\IManager', function($c) { |
|
167 | 167 | return $this->getServer()->getEncryptionManager(); |
168 | 168 | }); |
169 | 169 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | return $c->query(Validator::class); |
172 | 172 | }); |
173 | 173 | |
174 | - $this->registerService(\OC\Security\IdentityProof\Manager::class, function ($c) { |
|
174 | + $this->registerService(\OC\Security\IdentityProof\Manager::class, function($c) { |
|
175 | 175 | return new \OC\Security\IdentityProof\Manager( |
176 | 176 | $this->getServer()->getAppDataDir('identityproof'), |
177 | 177 | $this->getServer()->getCrypto() |
@@ -182,15 +182,15 @@ discard block |
||
182 | 182 | /** |
183 | 183 | * App Framework APIs |
184 | 184 | */ |
185 | - $this->registerService('API', function($c){ |
|
185 | + $this->registerService('API', function($c) { |
|
186 | 186 | $c->query('OCP\\ILogger')->debug( |
187 | - 'Accessing the API class is deprecated! Use the appropriate ' . |
|
187 | + 'Accessing the API class is deprecated! Use the appropriate '. |
|
188 | 188 | 'services instead!' |
189 | 189 | ); |
190 | 190 | return new API($c['AppName']); |
191 | 191 | }); |
192 | 192 | |
193 | - $this->registerService('Protocol', function($c){ |
|
193 | + $this->registerService('Protocol', function($c) { |
|
194 | 194 | /** @var \OC\Server $server */ |
195 | 195 | $server = $c->query('ServerContainer'); |
196 | 196 | $protocol = $server->getRequest()->getHttpProtocol(); |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | ); |
257 | 257 | }); |
258 | 258 | |
259 | - $this->registerService('TwoFactorMiddleware', function (SimpleContainer $c) use ($app) { |
|
259 | + $this->registerService('TwoFactorMiddleware', function(SimpleContainer $c) use ($app) { |
|
260 | 260 | $twoFactorManager = $c->getServer()->getTwoFactorAuthManager(); |
261 | 261 | $userSession = $app->getServer()->getUserSession(); |
262 | 262 | $session = $app->getServer()->getSession(); |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | return new TwoFactorMiddleware($twoFactorManager, $userSession, $session, $urlGenerator, $reflector, $request); |
267 | 267 | }); |
268 | 268 | |
269 | - $this->registerService('OCSMiddleware', function (SimpleContainer $c) { |
|
269 | + $this->registerService('OCSMiddleware', function(SimpleContainer $c) { |
|
270 | 270 | return new OCSMiddleware( |
271 | 271 | $c['Request'] |
272 | 272 | ); |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | $dispatcher->registerMiddleware($c['SecurityMiddleware']); |
281 | 281 | $dispatcher->registerMiddleWare($c['TwoFactorMiddleware']); |
282 | 282 | |
283 | - foreach($middleWares as $middleWare) { |
|
283 | + foreach ($middleWares as $middleWare) { |
|
284 | 284 | $dispatcher->registerMiddleware($c[$middleWare]); |
285 | 285 | } |
286 | 286 | |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | * @return mixed |
353 | 353 | */ |
354 | 354 | function log($message, $level) { |
355 | - switch($level){ |
|
355 | + switch ($level) { |
|
356 | 356 | case 'debug': |
357 | 357 | $level = \OCP\Util::DEBUG; |
358 | 358 | break; |
@@ -411,12 +411,12 @@ discard block |
||
411 | 411 | return parent::query($name); |
412 | 412 | } else if ($this['AppName'] === 'core' && strpos($name, 'OC\\Core\\') === 0) { |
413 | 413 | return parent::query($name); |
414 | - } else if (strpos($name, \OC\AppFramework\App::buildAppNamespace($this['AppName']) . '\\') === 0) { |
|
414 | + } else if (strpos($name, \OC\AppFramework\App::buildAppNamespace($this['AppName']).'\\') === 0) { |
|
415 | 415 | return parent::query($name); |
416 | 416 | } |
417 | 417 | } |
418 | 418 | |
419 | - throw new QueryException('Could not resolve ' . $name . '!' . |
|
419 | + throw new QueryException('Could not resolve '.$name.'!'. |
|
420 | 420 | ' Class can not be instantiated'); |
421 | 421 | } |
422 | 422 | } |
@@ -116,1606 +116,1606 @@ |
||
116 | 116 | * TODO: hookup all manager classes |
117 | 117 | */ |
118 | 118 | class Server extends ServerContainer implements IServerContainer { |
119 | - /** @var string */ |
|
120 | - private $webRoot; |
|
121 | - |
|
122 | - /** |
|
123 | - * @param string $webRoot |
|
124 | - * @param \OC\Config $config |
|
125 | - */ |
|
126 | - public function __construct($webRoot, \OC\Config $config) { |
|
127 | - parent::__construct(); |
|
128 | - $this->webRoot = $webRoot; |
|
129 | - |
|
130 | - $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
131 | - $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
132 | - |
|
133 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
134 | - return new PreviewManager( |
|
135 | - $c->getConfig(), |
|
136 | - $c->getRootFolder(), |
|
137 | - $c->getAppDataDir('preview'), |
|
138 | - $c->getEventDispatcher(), |
|
139 | - $c->getSession()->get('user_id') |
|
140 | - ); |
|
141 | - }); |
|
142 | - $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
143 | - |
|
144 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
145 | - return new \OC\Preview\Watcher( |
|
146 | - $c->getAppDataDir('preview') |
|
147 | - ); |
|
148 | - }); |
|
149 | - |
|
150 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
151 | - $view = new View(); |
|
152 | - $util = new Encryption\Util( |
|
153 | - $view, |
|
154 | - $c->getUserManager(), |
|
155 | - $c->getGroupManager(), |
|
156 | - $c->getConfig() |
|
157 | - ); |
|
158 | - return new Encryption\Manager( |
|
159 | - $c->getConfig(), |
|
160 | - $c->getLogger(), |
|
161 | - $c->getL10N('core'), |
|
162 | - new View(), |
|
163 | - $util, |
|
164 | - new ArrayCache() |
|
165 | - ); |
|
166 | - }); |
|
167 | - |
|
168 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
169 | - $util = new Encryption\Util( |
|
170 | - new View(), |
|
171 | - $c->getUserManager(), |
|
172 | - $c->getGroupManager(), |
|
173 | - $c->getConfig() |
|
174 | - ); |
|
175 | - return new Encryption\File($util); |
|
176 | - }); |
|
177 | - |
|
178 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
179 | - $view = new View(); |
|
180 | - $util = new Encryption\Util( |
|
181 | - $view, |
|
182 | - $c->getUserManager(), |
|
183 | - $c->getGroupManager(), |
|
184 | - $c->getConfig() |
|
185 | - ); |
|
186 | - |
|
187 | - return new Encryption\Keys\Storage($view, $util); |
|
188 | - }); |
|
189 | - $this->registerService('TagMapper', function (Server $c) { |
|
190 | - return new TagMapper($c->getDatabaseConnection()); |
|
191 | - }); |
|
192 | - |
|
193 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
194 | - $tagMapper = $c->query('TagMapper'); |
|
195 | - return new TagManager($tagMapper, $c->getUserSession()); |
|
196 | - }); |
|
197 | - $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
198 | - |
|
199 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
200 | - $config = $c->getConfig(); |
|
201 | - $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
|
202 | - /** @var \OC\SystemTag\ManagerFactory $factory */ |
|
203 | - $factory = new $factoryClass($this); |
|
204 | - return $factory; |
|
205 | - }); |
|
206 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
207 | - return $c->query('SystemTagManagerFactory')->getManager(); |
|
208 | - }); |
|
209 | - $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
210 | - |
|
211 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
212 | - return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
213 | - }); |
|
214 | - $this->registerService('RootFolder', function (Server $c) { |
|
215 | - $manager = \OC\Files\Filesystem::getMountManager(null); |
|
216 | - $view = new View(); |
|
217 | - $root = new Root( |
|
218 | - $manager, |
|
219 | - $view, |
|
220 | - null, |
|
221 | - $c->getUserMountCache(), |
|
222 | - $this->getLogger(), |
|
223 | - $this->getUserManager() |
|
224 | - ); |
|
225 | - $connector = new HookConnector($root, $view); |
|
226 | - $connector->viewToNode(); |
|
227 | - |
|
228 | - $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
229 | - $previewConnector->connectWatcher(); |
|
230 | - |
|
231 | - return $root; |
|
232 | - }); |
|
233 | - $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
234 | - |
|
235 | - $this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) { |
|
236 | - return new LazyRoot(function() use ($c) { |
|
237 | - return $c->query('RootFolder'); |
|
238 | - }); |
|
239 | - }); |
|
240 | - $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
241 | - |
|
242 | - $this->registerService(\OCP\IUserManager::class, function (Server $c) { |
|
243 | - $config = $c->getConfig(); |
|
244 | - return new \OC\User\Manager($config); |
|
245 | - }); |
|
246 | - $this->registerAlias('UserManager', \OCP\IUserManager::class); |
|
247 | - |
|
248 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
249 | - $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
250 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
251 | - \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
252 | - }); |
|
253 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
254 | - \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
255 | - }); |
|
256 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
257 | - \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
258 | - }); |
|
259 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
260 | - \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
261 | - }); |
|
262 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
263 | - \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
264 | - }); |
|
265 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
266 | - \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
267 | - //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
268 | - \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
269 | - }); |
|
270 | - return $groupManager; |
|
271 | - }); |
|
272 | - $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
273 | - |
|
274 | - $this->registerService(Store::class, function(Server $c) { |
|
275 | - $session = $c->getSession(); |
|
276 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
277 | - $tokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
278 | - } else { |
|
279 | - $tokenProvider = null; |
|
280 | - } |
|
281 | - $logger = $c->getLogger(); |
|
282 | - return new Store($session, $logger, $tokenProvider); |
|
283 | - }); |
|
284 | - $this->registerAlias(IStore::class, Store::class); |
|
285 | - $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
286 | - $dbConnection = $c->getDatabaseConnection(); |
|
287 | - return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
288 | - }); |
|
289 | - $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
290 | - $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
|
291 | - $crypto = $c->getCrypto(); |
|
292 | - $config = $c->getConfig(); |
|
293 | - $logger = $c->getLogger(); |
|
294 | - $timeFactory = new TimeFactory(); |
|
295 | - return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
|
296 | - }); |
|
297 | - $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
|
298 | - |
|
299 | - $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
300 | - $manager = $c->getUserManager(); |
|
301 | - $session = new \OC\Session\Memory(''); |
|
302 | - $timeFactory = new TimeFactory(); |
|
303 | - // Token providers might require a working database. This code |
|
304 | - // might however be called when ownCloud is not yet setup. |
|
305 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
306 | - $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
307 | - } else { |
|
308 | - $defaultTokenProvider = null; |
|
309 | - } |
|
310 | - |
|
311 | - $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom()); |
|
312 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
313 | - \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
314 | - }); |
|
315 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
316 | - /** @var $user \OC\User\User */ |
|
317 | - \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
318 | - }); |
|
319 | - $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
320 | - /** @var $user \OC\User\User */ |
|
321 | - \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
322 | - }); |
|
323 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
324 | - /** @var $user \OC\User\User */ |
|
325 | - \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
326 | - }); |
|
327 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
328 | - /** @var $user \OC\User\User */ |
|
329 | - \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
330 | - }); |
|
331 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
332 | - /** @var $user \OC\User\User */ |
|
333 | - \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
334 | - }); |
|
335 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
336 | - \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
337 | - }); |
|
338 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
339 | - /** @var $user \OC\User\User */ |
|
340 | - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
341 | - }); |
|
342 | - $userSession->listen('\OC\User', 'logout', function () { |
|
343 | - \OC_Hook::emit('OC_User', 'logout', array()); |
|
344 | - }); |
|
345 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) { |
|
346 | - /** @var $user \OC\User\User */ |
|
347 | - \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value)); |
|
348 | - }); |
|
349 | - return $userSession; |
|
350 | - }); |
|
351 | - $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
352 | - |
|
353 | - $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
354 | - return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
|
355 | - }); |
|
356 | - |
|
357 | - $this->registerService(\OCP\INavigationManager::class, function (Server $c) { |
|
358 | - return new \OC\NavigationManager($c->getAppManager(), |
|
359 | - $c->getURLGenerator(), |
|
360 | - $c->getL10NFactory(), |
|
361 | - $c->getUserSession(), |
|
362 | - $c->getGroupManager()); |
|
363 | - }); |
|
364 | - $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
365 | - |
|
366 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
367 | - return new \OC\AllConfig( |
|
368 | - $c->getSystemConfig() |
|
369 | - ); |
|
370 | - }); |
|
371 | - $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
372 | - $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
373 | - |
|
374 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
375 | - return new \OC\SystemConfig($config); |
|
376 | - }); |
|
377 | - |
|
378 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
379 | - return new \OC\AppConfig($c->getDatabaseConnection()); |
|
380 | - }); |
|
381 | - $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
382 | - $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
383 | - |
|
384 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
385 | - return new \OC\L10N\Factory( |
|
386 | - $c->getConfig(), |
|
387 | - $c->getRequest(), |
|
388 | - $c->getUserSession(), |
|
389 | - \OC::$SERVERROOT |
|
390 | - ); |
|
391 | - }); |
|
392 | - $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
393 | - |
|
394 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
395 | - $config = $c->getConfig(); |
|
396 | - $cacheFactory = $c->getMemCacheFactory(); |
|
397 | - return new \OC\URLGenerator( |
|
398 | - $config, |
|
399 | - $cacheFactory |
|
400 | - ); |
|
401 | - }); |
|
402 | - $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
403 | - |
|
404 | - $this->registerService('AppHelper', function ($c) { |
|
405 | - return new \OC\AppHelper(); |
|
406 | - }); |
|
407 | - $this->registerService('AppFetcher', function ($c) { |
|
408 | - return new AppFetcher( |
|
409 | - $this->getAppDataDir('appstore'), |
|
410 | - $this->getHTTPClientService(), |
|
411 | - $this->query(TimeFactory::class), |
|
412 | - $this->getConfig() |
|
413 | - ); |
|
414 | - }); |
|
415 | - $this->registerService('CategoryFetcher', function ($c) { |
|
416 | - return new CategoryFetcher( |
|
417 | - $this->getAppDataDir('appstore'), |
|
418 | - $this->getHTTPClientService(), |
|
419 | - $this->query(TimeFactory::class), |
|
420 | - $this->getConfig() |
|
421 | - ); |
|
422 | - }); |
|
423 | - |
|
424 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
425 | - return new Cache\File(); |
|
426 | - }); |
|
427 | - $this->registerAlias('UserCache', \OCP\ICache::class); |
|
428 | - |
|
429 | - $this->registerService(Factory::class, function (Server $c) { |
|
430 | - $config = $c->getConfig(); |
|
431 | - |
|
432 | - if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
433 | - $v = \OC_App::getAppVersions(); |
|
434 | - $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
435 | - $version = implode(',', $v); |
|
436 | - $instanceId = \OC_Util::getInstanceId(); |
|
437 | - $path = \OC::$SERVERROOT; |
|
438 | - $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
439 | - return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
440 | - $config->getSystemValue('memcache.local', null), |
|
441 | - $config->getSystemValue('memcache.distributed', null), |
|
442 | - $config->getSystemValue('memcache.locking', null) |
|
443 | - ); |
|
444 | - } |
|
445 | - |
|
446 | - return new \OC\Memcache\Factory('', $c->getLogger(), |
|
447 | - '\\OC\\Memcache\\ArrayCache', |
|
448 | - '\\OC\\Memcache\\ArrayCache', |
|
449 | - '\\OC\\Memcache\\ArrayCache' |
|
450 | - ); |
|
451 | - }); |
|
452 | - $this->registerAlias('MemCacheFactory', Factory::class); |
|
453 | - $this->registerAlias(ICacheFactory::class, Factory::class); |
|
454 | - |
|
455 | - $this->registerService('RedisFactory', function (Server $c) { |
|
456 | - $systemConfig = $c->getSystemConfig(); |
|
457 | - return new RedisFactory($systemConfig); |
|
458 | - }); |
|
459 | - |
|
460 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
461 | - return new \OC\Activity\Manager( |
|
462 | - $c->getRequest(), |
|
463 | - $c->getUserSession(), |
|
464 | - $c->getConfig(), |
|
465 | - $c->query(IValidator::class) |
|
466 | - ); |
|
467 | - }); |
|
468 | - $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
469 | - |
|
470 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
471 | - return new \OC\Activity\EventMerger( |
|
472 | - $c->getL10N('lib') |
|
473 | - ); |
|
474 | - }); |
|
475 | - $this->registerAlias(IValidator::class, Validator::class); |
|
476 | - |
|
477 | - $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
478 | - return new AvatarManager( |
|
479 | - $c->getUserManager(), |
|
480 | - $c->getAppDataDir('avatar'), |
|
481 | - $c->getL10N('lib'), |
|
482 | - $c->getLogger(), |
|
483 | - $c->getConfig() |
|
484 | - ); |
|
485 | - }); |
|
486 | - $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
487 | - |
|
488 | - $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
489 | - $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
490 | - $logger = Log::getLogClass($logType); |
|
491 | - call_user_func(array($logger, 'init')); |
|
492 | - |
|
493 | - return new Log($logger); |
|
494 | - }); |
|
495 | - $this->registerAlias('Logger', \OCP\ILogger::class); |
|
496 | - |
|
497 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
498 | - $config = $c->getConfig(); |
|
499 | - return new \OC\BackgroundJob\JobList( |
|
500 | - $c->getDatabaseConnection(), |
|
501 | - $config, |
|
502 | - new TimeFactory() |
|
503 | - ); |
|
504 | - }); |
|
505 | - $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
506 | - |
|
507 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
508 | - $cacheFactory = $c->getMemCacheFactory(); |
|
509 | - $logger = $c->getLogger(); |
|
510 | - if ($cacheFactory->isAvailable()) { |
|
511 | - $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger); |
|
512 | - } else { |
|
513 | - $router = new \OC\Route\Router($logger); |
|
514 | - } |
|
515 | - return $router; |
|
516 | - }); |
|
517 | - $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
518 | - |
|
519 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
520 | - return new Search(); |
|
521 | - }); |
|
522 | - $this->registerAlias('Search', \OCP\ISearch::class); |
|
523 | - |
|
524 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
525 | - return new SecureRandom(); |
|
526 | - }); |
|
527 | - $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
528 | - |
|
529 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
530 | - return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
531 | - }); |
|
532 | - $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
533 | - |
|
534 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
535 | - return new Hasher($c->getConfig()); |
|
536 | - }); |
|
537 | - $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
538 | - |
|
539 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
540 | - return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
541 | - }); |
|
542 | - $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
543 | - |
|
544 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
545 | - $systemConfig = $c->getSystemConfig(); |
|
546 | - $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
547 | - $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
548 | - if (!$factory->isValidType($type)) { |
|
549 | - throw new \OC\DatabaseException('Invalid database type'); |
|
550 | - } |
|
551 | - $connectionParams = $factory->createConnectionParams(); |
|
552 | - $connection = $factory->getConnection($type, $connectionParams); |
|
553 | - $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
554 | - return $connection; |
|
555 | - }); |
|
556 | - $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
557 | - |
|
558 | - $this->registerService('HTTPHelper', function (Server $c) { |
|
559 | - $config = $c->getConfig(); |
|
560 | - return new HTTPHelper( |
|
561 | - $config, |
|
562 | - $c->getHTTPClientService() |
|
563 | - ); |
|
564 | - }); |
|
565 | - |
|
566 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
567 | - $user = \OC_User::getUser(); |
|
568 | - $uid = $user ? $user : null; |
|
569 | - return new ClientService( |
|
570 | - $c->getConfig(), |
|
571 | - new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger()) |
|
572 | - ); |
|
573 | - }); |
|
574 | - $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
575 | - |
|
576 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
577 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
578 | - return new EventLogger(); |
|
579 | - } else { |
|
580 | - return new NullEventLogger(); |
|
581 | - } |
|
582 | - }); |
|
583 | - $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
584 | - |
|
585 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
586 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
587 | - return new QueryLogger(); |
|
588 | - } else { |
|
589 | - return new NullQueryLogger(); |
|
590 | - } |
|
591 | - }); |
|
592 | - $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
593 | - |
|
594 | - $this->registerService(TempManager::class, function (Server $c) { |
|
595 | - return new TempManager( |
|
596 | - $c->getLogger(), |
|
597 | - $c->getConfig() |
|
598 | - ); |
|
599 | - }); |
|
600 | - $this->registerAlias('TempManager', TempManager::class); |
|
601 | - $this->registerAlias(ITempManager::class, TempManager::class); |
|
602 | - |
|
603 | - $this->registerService(AppManager::class, function (Server $c) { |
|
604 | - return new \OC\App\AppManager( |
|
605 | - $c->getUserSession(), |
|
606 | - $c->getAppConfig(), |
|
607 | - $c->getGroupManager(), |
|
608 | - $c->getMemCacheFactory(), |
|
609 | - $c->getEventDispatcher() |
|
610 | - ); |
|
611 | - }); |
|
612 | - $this->registerAlias('AppManager', AppManager::class); |
|
613 | - $this->registerAlias(IAppManager::class, AppManager::class); |
|
614 | - |
|
615 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
616 | - return new DateTimeZone( |
|
617 | - $c->getConfig(), |
|
618 | - $c->getSession() |
|
619 | - ); |
|
620 | - }); |
|
621 | - $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
622 | - |
|
623 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
624 | - $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
625 | - |
|
626 | - return new DateTimeFormatter( |
|
627 | - $c->getDateTimeZone()->getTimeZone(), |
|
628 | - $c->getL10N('lib', $language) |
|
629 | - ); |
|
630 | - }); |
|
631 | - $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
632 | - |
|
633 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
634 | - $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
635 | - $listener = new UserMountCacheListener($mountCache); |
|
636 | - $listener->listen($c->getUserManager()); |
|
637 | - return $mountCache; |
|
638 | - }); |
|
639 | - $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
640 | - |
|
641 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
642 | - $loader = \OC\Files\Filesystem::getLoader(); |
|
643 | - $mountCache = $c->query('UserMountCache'); |
|
644 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
645 | - |
|
646 | - // builtin providers |
|
647 | - |
|
648 | - $config = $c->getConfig(); |
|
649 | - $manager->registerProvider(new CacheMountProvider($config)); |
|
650 | - $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
651 | - $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
652 | - |
|
653 | - return $manager; |
|
654 | - }); |
|
655 | - $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
656 | - |
|
657 | - $this->registerService('IniWrapper', function ($c) { |
|
658 | - return new IniGetWrapper(); |
|
659 | - }); |
|
660 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
661 | - $jobList = $c->getJobList(); |
|
662 | - return new AsyncBus($jobList); |
|
663 | - }); |
|
664 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
665 | - return new TrustedDomainHelper($this->getConfig()); |
|
666 | - }); |
|
667 | - $this->registerService('Throttler', function(Server $c) { |
|
668 | - return new Throttler( |
|
669 | - $c->getDatabaseConnection(), |
|
670 | - new TimeFactory(), |
|
671 | - $c->getLogger(), |
|
672 | - $c->getConfig() |
|
673 | - ); |
|
674 | - }); |
|
675 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
676 | - // IConfig and IAppManager requires a working database. This code |
|
677 | - // might however be called when ownCloud is not yet setup. |
|
678 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
679 | - $config = $c->getConfig(); |
|
680 | - $appManager = $c->getAppManager(); |
|
681 | - } else { |
|
682 | - $config = null; |
|
683 | - $appManager = null; |
|
684 | - } |
|
685 | - |
|
686 | - return new Checker( |
|
687 | - new EnvironmentHelper(), |
|
688 | - new FileAccessHelper(), |
|
689 | - new AppLocator(), |
|
690 | - $config, |
|
691 | - $c->getMemCacheFactory(), |
|
692 | - $appManager, |
|
693 | - $c->getTempManager() |
|
694 | - ); |
|
695 | - }); |
|
696 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
697 | - if (isset($this['urlParams'])) { |
|
698 | - $urlParams = $this['urlParams']; |
|
699 | - } else { |
|
700 | - $urlParams = []; |
|
701 | - } |
|
702 | - |
|
703 | - if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
704 | - && in_array('fakeinput', stream_get_wrappers()) |
|
705 | - ) { |
|
706 | - $stream = 'fakeinput://data'; |
|
707 | - } else { |
|
708 | - $stream = 'php://input'; |
|
709 | - } |
|
710 | - |
|
711 | - return new Request( |
|
712 | - [ |
|
713 | - 'get' => $_GET, |
|
714 | - 'post' => $_POST, |
|
715 | - 'files' => $_FILES, |
|
716 | - 'server' => $_SERVER, |
|
717 | - 'env' => $_ENV, |
|
718 | - 'cookies' => $_COOKIE, |
|
719 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
720 | - ? $_SERVER['REQUEST_METHOD'] |
|
721 | - : null, |
|
722 | - 'urlParams' => $urlParams, |
|
723 | - ], |
|
724 | - $this->getSecureRandom(), |
|
725 | - $this->getConfig(), |
|
726 | - $this->getCsrfTokenManager(), |
|
727 | - $stream |
|
728 | - ); |
|
729 | - }); |
|
730 | - $this->registerAlias('Request', \OCP\IRequest::class); |
|
731 | - |
|
732 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
733 | - return new Mailer( |
|
734 | - $c->getConfig(), |
|
735 | - $c->getLogger(), |
|
736 | - $c->getThemingDefaults() |
|
737 | - ); |
|
738 | - }); |
|
739 | - $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
740 | - |
|
741 | - $this->registerService('LDAPProvider', function(Server $c) { |
|
742 | - $config = $c->getConfig(); |
|
743 | - $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
744 | - if(is_null($factoryClass)) { |
|
745 | - throw new \Exception('ldapProviderFactory not set'); |
|
746 | - } |
|
747 | - /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
748 | - $factory = new $factoryClass($this); |
|
749 | - return $factory->getLDAPProvider(); |
|
750 | - }); |
|
751 | - $this->registerService('LockingProvider', function (Server $c) { |
|
752 | - $ini = $c->getIniWrapper(); |
|
753 | - $config = $c->getConfig(); |
|
754 | - $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
755 | - if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
756 | - /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
757 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
758 | - $memcache = $memcacheFactory->createLocking('lock'); |
|
759 | - if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
760 | - return new MemcacheLockingProvider($memcache, $ttl); |
|
761 | - } |
|
762 | - return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl); |
|
763 | - } |
|
764 | - return new NoopLockingProvider(); |
|
765 | - }); |
|
766 | - |
|
767 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
768 | - return new \OC\Files\Mount\Manager(); |
|
769 | - }); |
|
770 | - $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
771 | - |
|
772 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
773 | - return new \OC\Files\Type\Detection( |
|
774 | - $c->getURLGenerator(), |
|
775 | - \OC::$configDir, |
|
776 | - \OC::$SERVERROOT . '/resources/config/' |
|
777 | - ); |
|
778 | - }); |
|
779 | - $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
780 | - |
|
781 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
782 | - return new \OC\Files\Type\Loader( |
|
783 | - $c->getDatabaseConnection() |
|
784 | - ); |
|
785 | - }); |
|
786 | - $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
787 | - |
|
788 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
789 | - return new Manager( |
|
790 | - $c->query(IValidator::class) |
|
791 | - ); |
|
792 | - }); |
|
793 | - $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
794 | - |
|
795 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
796 | - $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
797 | - $manager->registerCapability(function () use ($c) { |
|
798 | - return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
799 | - }); |
|
800 | - return $manager; |
|
801 | - }); |
|
802 | - $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
803 | - |
|
804 | - $this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) { |
|
805 | - $config = $c->getConfig(); |
|
806 | - $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); |
|
807 | - /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
808 | - $factory = new $factoryClass($this); |
|
809 | - return $factory->getManager(); |
|
810 | - }); |
|
811 | - $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
812 | - |
|
813 | - $this->registerService('ThemingDefaults', function(Server $c) { |
|
814 | - /* |
|
119 | + /** @var string */ |
|
120 | + private $webRoot; |
|
121 | + |
|
122 | + /** |
|
123 | + * @param string $webRoot |
|
124 | + * @param \OC\Config $config |
|
125 | + */ |
|
126 | + public function __construct($webRoot, \OC\Config $config) { |
|
127 | + parent::__construct(); |
|
128 | + $this->webRoot = $webRoot; |
|
129 | + |
|
130 | + $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
131 | + $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
132 | + |
|
133 | + $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
134 | + return new PreviewManager( |
|
135 | + $c->getConfig(), |
|
136 | + $c->getRootFolder(), |
|
137 | + $c->getAppDataDir('preview'), |
|
138 | + $c->getEventDispatcher(), |
|
139 | + $c->getSession()->get('user_id') |
|
140 | + ); |
|
141 | + }); |
|
142 | + $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
143 | + |
|
144 | + $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
145 | + return new \OC\Preview\Watcher( |
|
146 | + $c->getAppDataDir('preview') |
|
147 | + ); |
|
148 | + }); |
|
149 | + |
|
150 | + $this->registerService('EncryptionManager', function (Server $c) { |
|
151 | + $view = new View(); |
|
152 | + $util = new Encryption\Util( |
|
153 | + $view, |
|
154 | + $c->getUserManager(), |
|
155 | + $c->getGroupManager(), |
|
156 | + $c->getConfig() |
|
157 | + ); |
|
158 | + return new Encryption\Manager( |
|
159 | + $c->getConfig(), |
|
160 | + $c->getLogger(), |
|
161 | + $c->getL10N('core'), |
|
162 | + new View(), |
|
163 | + $util, |
|
164 | + new ArrayCache() |
|
165 | + ); |
|
166 | + }); |
|
167 | + |
|
168 | + $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
169 | + $util = new Encryption\Util( |
|
170 | + new View(), |
|
171 | + $c->getUserManager(), |
|
172 | + $c->getGroupManager(), |
|
173 | + $c->getConfig() |
|
174 | + ); |
|
175 | + return new Encryption\File($util); |
|
176 | + }); |
|
177 | + |
|
178 | + $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
179 | + $view = new View(); |
|
180 | + $util = new Encryption\Util( |
|
181 | + $view, |
|
182 | + $c->getUserManager(), |
|
183 | + $c->getGroupManager(), |
|
184 | + $c->getConfig() |
|
185 | + ); |
|
186 | + |
|
187 | + return new Encryption\Keys\Storage($view, $util); |
|
188 | + }); |
|
189 | + $this->registerService('TagMapper', function (Server $c) { |
|
190 | + return new TagMapper($c->getDatabaseConnection()); |
|
191 | + }); |
|
192 | + |
|
193 | + $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
194 | + $tagMapper = $c->query('TagMapper'); |
|
195 | + return new TagManager($tagMapper, $c->getUserSession()); |
|
196 | + }); |
|
197 | + $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
198 | + |
|
199 | + $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
200 | + $config = $c->getConfig(); |
|
201 | + $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
|
202 | + /** @var \OC\SystemTag\ManagerFactory $factory */ |
|
203 | + $factory = new $factoryClass($this); |
|
204 | + return $factory; |
|
205 | + }); |
|
206 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
207 | + return $c->query('SystemTagManagerFactory')->getManager(); |
|
208 | + }); |
|
209 | + $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
210 | + |
|
211 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
212 | + return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
213 | + }); |
|
214 | + $this->registerService('RootFolder', function (Server $c) { |
|
215 | + $manager = \OC\Files\Filesystem::getMountManager(null); |
|
216 | + $view = new View(); |
|
217 | + $root = new Root( |
|
218 | + $manager, |
|
219 | + $view, |
|
220 | + null, |
|
221 | + $c->getUserMountCache(), |
|
222 | + $this->getLogger(), |
|
223 | + $this->getUserManager() |
|
224 | + ); |
|
225 | + $connector = new HookConnector($root, $view); |
|
226 | + $connector->viewToNode(); |
|
227 | + |
|
228 | + $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
229 | + $previewConnector->connectWatcher(); |
|
230 | + |
|
231 | + return $root; |
|
232 | + }); |
|
233 | + $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
234 | + |
|
235 | + $this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) { |
|
236 | + return new LazyRoot(function() use ($c) { |
|
237 | + return $c->query('RootFolder'); |
|
238 | + }); |
|
239 | + }); |
|
240 | + $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
241 | + |
|
242 | + $this->registerService(\OCP\IUserManager::class, function (Server $c) { |
|
243 | + $config = $c->getConfig(); |
|
244 | + return new \OC\User\Manager($config); |
|
245 | + }); |
|
246 | + $this->registerAlias('UserManager', \OCP\IUserManager::class); |
|
247 | + |
|
248 | + $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
249 | + $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
250 | + $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
251 | + \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
252 | + }); |
|
253 | + $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
254 | + \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
255 | + }); |
|
256 | + $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
257 | + \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
258 | + }); |
|
259 | + $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
260 | + \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
261 | + }); |
|
262 | + $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
263 | + \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
264 | + }); |
|
265 | + $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
266 | + \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
267 | + //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
268 | + \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
269 | + }); |
|
270 | + return $groupManager; |
|
271 | + }); |
|
272 | + $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
273 | + |
|
274 | + $this->registerService(Store::class, function(Server $c) { |
|
275 | + $session = $c->getSession(); |
|
276 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
277 | + $tokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
278 | + } else { |
|
279 | + $tokenProvider = null; |
|
280 | + } |
|
281 | + $logger = $c->getLogger(); |
|
282 | + return new Store($session, $logger, $tokenProvider); |
|
283 | + }); |
|
284 | + $this->registerAlias(IStore::class, Store::class); |
|
285 | + $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
286 | + $dbConnection = $c->getDatabaseConnection(); |
|
287 | + return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
288 | + }); |
|
289 | + $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
290 | + $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
|
291 | + $crypto = $c->getCrypto(); |
|
292 | + $config = $c->getConfig(); |
|
293 | + $logger = $c->getLogger(); |
|
294 | + $timeFactory = new TimeFactory(); |
|
295 | + return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
|
296 | + }); |
|
297 | + $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
|
298 | + |
|
299 | + $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
300 | + $manager = $c->getUserManager(); |
|
301 | + $session = new \OC\Session\Memory(''); |
|
302 | + $timeFactory = new TimeFactory(); |
|
303 | + // Token providers might require a working database. This code |
|
304 | + // might however be called when ownCloud is not yet setup. |
|
305 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
306 | + $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
307 | + } else { |
|
308 | + $defaultTokenProvider = null; |
|
309 | + } |
|
310 | + |
|
311 | + $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom()); |
|
312 | + $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
313 | + \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
314 | + }); |
|
315 | + $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
316 | + /** @var $user \OC\User\User */ |
|
317 | + \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
318 | + }); |
|
319 | + $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
320 | + /** @var $user \OC\User\User */ |
|
321 | + \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
322 | + }); |
|
323 | + $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
324 | + /** @var $user \OC\User\User */ |
|
325 | + \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
326 | + }); |
|
327 | + $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
328 | + /** @var $user \OC\User\User */ |
|
329 | + \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
330 | + }); |
|
331 | + $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
332 | + /** @var $user \OC\User\User */ |
|
333 | + \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
334 | + }); |
|
335 | + $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
336 | + \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
337 | + }); |
|
338 | + $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
339 | + /** @var $user \OC\User\User */ |
|
340 | + \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
341 | + }); |
|
342 | + $userSession->listen('\OC\User', 'logout', function () { |
|
343 | + \OC_Hook::emit('OC_User', 'logout', array()); |
|
344 | + }); |
|
345 | + $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) { |
|
346 | + /** @var $user \OC\User\User */ |
|
347 | + \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value)); |
|
348 | + }); |
|
349 | + return $userSession; |
|
350 | + }); |
|
351 | + $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
352 | + |
|
353 | + $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
354 | + return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
|
355 | + }); |
|
356 | + |
|
357 | + $this->registerService(\OCP\INavigationManager::class, function (Server $c) { |
|
358 | + return new \OC\NavigationManager($c->getAppManager(), |
|
359 | + $c->getURLGenerator(), |
|
360 | + $c->getL10NFactory(), |
|
361 | + $c->getUserSession(), |
|
362 | + $c->getGroupManager()); |
|
363 | + }); |
|
364 | + $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
365 | + |
|
366 | + $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
367 | + return new \OC\AllConfig( |
|
368 | + $c->getSystemConfig() |
|
369 | + ); |
|
370 | + }); |
|
371 | + $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
372 | + $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
373 | + |
|
374 | + $this->registerService('SystemConfig', function ($c) use ($config) { |
|
375 | + return new \OC\SystemConfig($config); |
|
376 | + }); |
|
377 | + |
|
378 | + $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
379 | + return new \OC\AppConfig($c->getDatabaseConnection()); |
|
380 | + }); |
|
381 | + $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
382 | + $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
383 | + |
|
384 | + $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
385 | + return new \OC\L10N\Factory( |
|
386 | + $c->getConfig(), |
|
387 | + $c->getRequest(), |
|
388 | + $c->getUserSession(), |
|
389 | + \OC::$SERVERROOT |
|
390 | + ); |
|
391 | + }); |
|
392 | + $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
393 | + |
|
394 | + $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
395 | + $config = $c->getConfig(); |
|
396 | + $cacheFactory = $c->getMemCacheFactory(); |
|
397 | + return new \OC\URLGenerator( |
|
398 | + $config, |
|
399 | + $cacheFactory |
|
400 | + ); |
|
401 | + }); |
|
402 | + $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
403 | + |
|
404 | + $this->registerService('AppHelper', function ($c) { |
|
405 | + return new \OC\AppHelper(); |
|
406 | + }); |
|
407 | + $this->registerService('AppFetcher', function ($c) { |
|
408 | + return new AppFetcher( |
|
409 | + $this->getAppDataDir('appstore'), |
|
410 | + $this->getHTTPClientService(), |
|
411 | + $this->query(TimeFactory::class), |
|
412 | + $this->getConfig() |
|
413 | + ); |
|
414 | + }); |
|
415 | + $this->registerService('CategoryFetcher', function ($c) { |
|
416 | + return new CategoryFetcher( |
|
417 | + $this->getAppDataDir('appstore'), |
|
418 | + $this->getHTTPClientService(), |
|
419 | + $this->query(TimeFactory::class), |
|
420 | + $this->getConfig() |
|
421 | + ); |
|
422 | + }); |
|
423 | + |
|
424 | + $this->registerService(\OCP\ICache::class, function ($c) { |
|
425 | + return new Cache\File(); |
|
426 | + }); |
|
427 | + $this->registerAlias('UserCache', \OCP\ICache::class); |
|
428 | + |
|
429 | + $this->registerService(Factory::class, function (Server $c) { |
|
430 | + $config = $c->getConfig(); |
|
431 | + |
|
432 | + if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
433 | + $v = \OC_App::getAppVersions(); |
|
434 | + $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
435 | + $version = implode(',', $v); |
|
436 | + $instanceId = \OC_Util::getInstanceId(); |
|
437 | + $path = \OC::$SERVERROOT; |
|
438 | + $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
439 | + return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
440 | + $config->getSystemValue('memcache.local', null), |
|
441 | + $config->getSystemValue('memcache.distributed', null), |
|
442 | + $config->getSystemValue('memcache.locking', null) |
|
443 | + ); |
|
444 | + } |
|
445 | + |
|
446 | + return new \OC\Memcache\Factory('', $c->getLogger(), |
|
447 | + '\\OC\\Memcache\\ArrayCache', |
|
448 | + '\\OC\\Memcache\\ArrayCache', |
|
449 | + '\\OC\\Memcache\\ArrayCache' |
|
450 | + ); |
|
451 | + }); |
|
452 | + $this->registerAlias('MemCacheFactory', Factory::class); |
|
453 | + $this->registerAlias(ICacheFactory::class, Factory::class); |
|
454 | + |
|
455 | + $this->registerService('RedisFactory', function (Server $c) { |
|
456 | + $systemConfig = $c->getSystemConfig(); |
|
457 | + return new RedisFactory($systemConfig); |
|
458 | + }); |
|
459 | + |
|
460 | + $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
461 | + return new \OC\Activity\Manager( |
|
462 | + $c->getRequest(), |
|
463 | + $c->getUserSession(), |
|
464 | + $c->getConfig(), |
|
465 | + $c->query(IValidator::class) |
|
466 | + ); |
|
467 | + }); |
|
468 | + $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
469 | + |
|
470 | + $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
471 | + return new \OC\Activity\EventMerger( |
|
472 | + $c->getL10N('lib') |
|
473 | + ); |
|
474 | + }); |
|
475 | + $this->registerAlias(IValidator::class, Validator::class); |
|
476 | + |
|
477 | + $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
478 | + return new AvatarManager( |
|
479 | + $c->getUserManager(), |
|
480 | + $c->getAppDataDir('avatar'), |
|
481 | + $c->getL10N('lib'), |
|
482 | + $c->getLogger(), |
|
483 | + $c->getConfig() |
|
484 | + ); |
|
485 | + }); |
|
486 | + $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
487 | + |
|
488 | + $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
489 | + $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
490 | + $logger = Log::getLogClass($logType); |
|
491 | + call_user_func(array($logger, 'init')); |
|
492 | + |
|
493 | + return new Log($logger); |
|
494 | + }); |
|
495 | + $this->registerAlias('Logger', \OCP\ILogger::class); |
|
496 | + |
|
497 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
498 | + $config = $c->getConfig(); |
|
499 | + return new \OC\BackgroundJob\JobList( |
|
500 | + $c->getDatabaseConnection(), |
|
501 | + $config, |
|
502 | + new TimeFactory() |
|
503 | + ); |
|
504 | + }); |
|
505 | + $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
506 | + |
|
507 | + $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
508 | + $cacheFactory = $c->getMemCacheFactory(); |
|
509 | + $logger = $c->getLogger(); |
|
510 | + if ($cacheFactory->isAvailable()) { |
|
511 | + $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger); |
|
512 | + } else { |
|
513 | + $router = new \OC\Route\Router($logger); |
|
514 | + } |
|
515 | + return $router; |
|
516 | + }); |
|
517 | + $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
518 | + |
|
519 | + $this->registerService(\OCP\ISearch::class, function ($c) { |
|
520 | + return new Search(); |
|
521 | + }); |
|
522 | + $this->registerAlias('Search', \OCP\ISearch::class); |
|
523 | + |
|
524 | + $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
525 | + return new SecureRandom(); |
|
526 | + }); |
|
527 | + $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
528 | + |
|
529 | + $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
530 | + return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
531 | + }); |
|
532 | + $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
533 | + |
|
534 | + $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
535 | + return new Hasher($c->getConfig()); |
|
536 | + }); |
|
537 | + $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
538 | + |
|
539 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
540 | + return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
541 | + }); |
|
542 | + $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
543 | + |
|
544 | + $this->registerService(IDBConnection::class, function (Server $c) { |
|
545 | + $systemConfig = $c->getSystemConfig(); |
|
546 | + $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
547 | + $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
548 | + if (!$factory->isValidType($type)) { |
|
549 | + throw new \OC\DatabaseException('Invalid database type'); |
|
550 | + } |
|
551 | + $connectionParams = $factory->createConnectionParams(); |
|
552 | + $connection = $factory->getConnection($type, $connectionParams); |
|
553 | + $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
554 | + return $connection; |
|
555 | + }); |
|
556 | + $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
557 | + |
|
558 | + $this->registerService('HTTPHelper', function (Server $c) { |
|
559 | + $config = $c->getConfig(); |
|
560 | + return new HTTPHelper( |
|
561 | + $config, |
|
562 | + $c->getHTTPClientService() |
|
563 | + ); |
|
564 | + }); |
|
565 | + |
|
566 | + $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
567 | + $user = \OC_User::getUser(); |
|
568 | + $uid = $user ? $user : null; |
|
569 | + return new ClientService( |
|
570 | + $c->getConfig(), |
|
571 | + new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger()) |
|
572 | + ); |
|
573 | + }); |
|
574 | + $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
575 | + |
|
576 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
577 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
578 | + return new EventLogger(); |
|
579 | + } else { |
|
580 | + return new NullEventLogger(); |
|
581 | + } |
|
582 | + }); |
|
583 | + $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
584 | + |
|
585 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
586 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
587 | + return new QueryLogger(); |
|
588 | + } else { |
|
589 | + return new NullQueryLogger(); |
|
590 | + } |
|
591 | + }); |
|
592 | + $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
593 | + |
|
594 | + $this->registerService(TempManager::class, function (Server $c) { |
|
595 | + return new TempManager( |
|
596 | + $c->getLogger(), |
|
597 | + $c->getConfig() |
|
598 | + ); |
|
599 | + }); |
|
600 | + $this->registerAlias('TempManager', TempManager::class); |
|
601 | + $this->registerAlias(ITempManager::class, TempManager::class); |
|
602 | + |
|
603 | + $this->registerService(AppManager::class, function (Server $c) { |
|
604 | + return new \OC\App\AppManager( |
|
605 | + $c->getUserSession(), |
|
606 | + $c->getAppConfig(), |
|
607 | + $c->getGroupManager(), |
|
608 | + $c->getMemCacheFactory(), |
|
609 | + $c->getEventDispatcher() |
|
610 | + ); |
|
611 | + }); |
|
612 | + $this->registerAlias('AppManager', AppManager::class); |
|
613 | + $this->registerAlias(IAppManager::class, AppManager::class); |
|
614 | + |
|
615 | + $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
616 | + return new DateTimeZone( |
|
617 | + $c->getConfig(), |
|
618 | + $c->getSession() |
|
619 | + ); |
|
620 | + }); |
|
621 | + $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
622 | + |
|
623 | + $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
624 | + $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
625 | + |
|
626 | + return new DateTimeFormatter( |
|
627 | + $c->getDateTimeZone()->getTimeZone(), |
|
628 | + $c->getL10N('lib', $language) |
|
629 | + ); |
|
630 | + }); |
|
631 | + $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
632 | + |
|
633 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
634 | + $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
635 | + $listener = new UserMountCacheListener($mountCache); |
|
636 | + $listener->listen($c->getUserManager()); |
|
637 | + return $mountCache; |
|
638 | + }); |
|
639 | + $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
640 | + |
|
641 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
642 | + $loader = \OC\Files\Filesystem::getLoader(); |
|
643 | + $mountCache = $c->query('UserMountCache'); |
|
644 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
645 | + |
|
646 | + // builtin providers |
|
647 | + |
|
648 | + $config = $c->getConfig(); |
|
649 | + $manager->registerProvider(new CacheMountProvider($config)); |
|
650 | + $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
651 | + $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
652 | + |
|
653 | + return $manager; |
|
654 | + }); |
|
655 | + $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
656 | + |
|
657 | + $this->registerService('IniWrapper', function ($c) { |
|
658 | + return new IniGetWrapper(); |
|
659 | + }); |
|
660 | + $this->registerService('AsyncCommandBus', function (Server $c) { |
|
661 | + $jobList = $c->getJobList(); |
|
662 | + return new AsyncBus($jobList); |
|
663 | + }); |
|
664 | + $this->registerService('TrustedDomainHelper', function ($c) { |
|
665 | + return new TrustedDomainHelper($this->getConfig()); |
|
666 | + }); |
|
667 | + $this->registerService('Throttler', function(Server $c) { |
|
668 | + return new Throttler( |
|
669 | + $c->getDatabaseConnection(), |
|
670 | + new TimeFactory(), |
|
671 | + $c->getLogger(), |
|
672 | + $c->getConfig() |
|
673 | + ); |
|
674 | + }); |
|
675 | + $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
676 | + // IConfig and IAppManager requires a working database. This code |
|
677 | + // might however be called when ownCloud is not yet setup. |
|
678 | + if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
679 | + $config = $c->getConfig(); |
|
680 | + $appManager = $c->getAppManager(); |
|
681 | + } else { |
|
682 | + $config = null; |
|
683 | + $appManager = null; |
|
684 | + } |
|
685 | + |
|
686 | + return new Checker( |
|
687 | + new EnvironmentHelper(), |
|
688 | + new FileAccessHelper(), |
|
689 | + new AppLocator(), |
|
690 | + $config, |
|
691 | + $c->getMemCacheFactory(), |
|
692 | + $appManager, |
|
693 | + $c->getTempManager() |
|
694 | + ); |
|
695 | + }); |
|
696 | + $this->registerService(\OCP\IRequest::class, function ($c) { |
|
697 | + if (isset($this['urlParams'])) { |
|
698 | + $urlParams = $this['urlParams']; |
|
699 | + } else { |
|
700 | + $urlParams = []; |
|
701 | + } |
|
702 | + |
|
703 | + if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
704 | + && in_array('fakeinput', stream_get_wrappers()) |
|
705 | + ) { |
|
706 | + $stream = 'fakeinput://data'; |
|
707 | + } else { |
|
708 | + $stream = 'php://input'; |
|
709 | + } |
|
710 | + |
|
711 | + return new Request( |
|
712 | + [ |
|
713 | + 'get' => $_GET, |
|
714 | + 'post' => $_POST, |
|
715 | + 'files' => $_FILES, |
|
716 | + 'server' => $_SERVER, |
|
717 | + 'env' => $_ENV, |
|
718 | + 'cookies' => $_COOKIE, |
|
719 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
720 | + ? $_SERVER['REQUEST_METHOD'] |
|
721 | + : null, |
|
722 | + 'urlParams' => $urlParams, |
|
723 | + ], |
|
724 | + $this->getSecureRandom(), |
|
725 | + $this->getConfig(), |
|
726 | + $this->getCsrfTokenManager(), |
|
727 | + $stream |
|
728 | + ); |
|
729 | + }); |
|
730 | + $this->registerAlias('Request', \OCP\IRequest::class); |
|
731 | + |
|
732 | + $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
733 | + return new Mailer( |
|
734 | + $c->getConfig(), |
|
735 | + $c->getLogger(), |
|
736 | + $c->getThemingDefaults() |
|
737 | + ); |
|
738 | + }); |
|
739 | + $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
740 | + |
|
741 | + $this->registerService('LDAPProvider', function(Server $c) { |
|
742 | + $config = $c->getConfig(); |
|
743 | + $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
744 | + if(is_null($factoryClass)) { |
|
745 | + throw new \Exception('ldapProviderFactory not set'); |
|
746 | + } |
|
747 | + /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
748 | + $factory = new $factoryClass($this); |
|
749 | + return $factory->getLDAPProvider(); |
|
750 | + }); |
|
751 | + $this->registerService('LockingProvider', function (Server $c) { |
|
752 | + $ini = $c->getIniWrapper(); |
|
753 | + $config = $c->getConfig(); |
|
754 | + $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
755 | + if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
756 | + /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
757 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
758 | + $memcache = $memcacheFactory->createLocking('lock'); |
|
759 | + if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
760 | + return new MemcacheLockingProvider($memcache, $ttl); |
|
761 | + } |
|
762 | + return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl); |
|
763 | + } |
|
764 | + return new NoopLockingProvider(); |
|
765 | + }); |
|
766 | + |
|
767 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
768 | + return new \OC\Files\Mount\Manager(); |
|
769 | + }); |
|
770 | + $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
771 | + |
|
772 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
773 | + return new \OC\Files\Type\Detection( |
|
774 | + $c->getURLGenerator(), |
|
775 | + \OC::$configDir, |
|
776 | + \OC::$SERVERROOT . '/resources/config/' |
|
777 | + ); |
|
778 | + }); |
|
779 | + $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
780 | + |
|
781 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
782 | + return new \OC\Files\Type\Loader( |
|
783 | + $c->getDatabaseConnection() |
|
784 | + ); |
|
785 | + }); |
|
786 | + $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
787 | + |
|
788 | + $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
789 | + return new Manager( |
|
790 | + $c->query(IValidator::class) |
|
791 | + ); |
|
792 | + }); |
|
793 | + $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
794 | + |
|
795 | + $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
796 | + $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
797 | + $manager->registerCapability(function () use ($c) { |
|
798 | + return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
799 | + }); |
|
800 | + return $manager; |
|
801 | + }); |
|
802 | + $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
803 | + |
|
804 | + $this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) { |
|
805 | + $config = $c->getConfig(); |
|
806 | + $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); |
|
807 | + /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
808 | + $factory = new $factoryClass($this); |
|
809 | + return $factory->getManager(); |
|
810 | + }); |
|
811 | + $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
812 | + |
|
813 | + $this->registerService('ThemingDefaults', function(Server $c) { |
|
814 | + /* |
|
815 | 815 | * Dark magic for autoloader. |
816 | 816 | * If we do a class_exists it will try to load the class which will |
817 | 817 | * make composer cache the result. Resulting in errors when enabling |
818 | 818 | * the theming app. |
819 | 819 | */ |
820 | - $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
821 | - if (isset($prefixes['OCA\\Theming\\'])) { |
|
822 | - $classExists = true; |
|
823 | - } else { |
|
824 | - $classExists = false; |
|
825 | - } |
|
826 | - |
|
827 | - if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) { |
|
828 | - return new ThemingDefaults( |
|
829 | - $c->getConfig(), |
|
830 | - $c->getL10N('theming'), |
|
831 | - $c->getURLGenerator(), |
|
832 | - new \OC_Defaults(), |
|
833 | - $c->getLazyRootFolder(), |
|
834 | - $c->getMemCacheFactory() |
|
835 | - ); |
|
836 | - } |
|
837 | - return new \OC_Defaults(); |
|
838 | - }); |
|
839 | - $this->registerService(EventDispatcher::class, function () { |
|
840 | - return new EventDispatcher(); |
|
841 | - }); |
|
842 | - $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
843 | - $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
844 | - |
|
845 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
846 | - // FIXME: Instantiiated here due to cyclic dependency |
|
847 | - $request = new Request( |
|
848 | - [ |
|
849 | - 'get' => $_GET, |
|
850 | - 'post' => $_POST, |
|
851 | - 'files' => $_FILES, |
|
852 | - 'server' => $_SERVER, |
|
853 | - 'env' => $_ENV, |
|
854 | - 'cookies' => $_COOKIE, |
|
855 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
856 | - ? $_SERVER['REQUEST_METHOD'] |
|
857 | - : null, |
|
858 | - ], |
|
859 | - $c->getSecureRandom(), |
|
860 | - $c->getConfig() |
|
861 | - ); |
|
862 | - |
|
863 | - return new CryptoWrapper( |
|
864 | - $c->getConfig(), |
|
865 | - $c->getCrypto(), |
|
866 | - $c->getSecureRandom(), |
|
867 | - $request |
|
868 | - ); |
|
869 | - }); |
|
870 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
871 | - $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
872 | - |
|
873 | - return new CsrfTokenManager( |
|
874 | - $tokenGenerator, |
|
875 | - $c->query(SessionStorage::class) |
|
876 | - ); |
|
877 | - }); |
|
878 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
879 | - return new SessionStorage($c->getSession()); |
|
880 | - }); |
|
881 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
882 | - return new ContentSecurityPolicyManager(); |
|
883 | - }); |
|
884 | - $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
885 | - |
|
886 | - $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) { |
|
887 | - return new ContentSecurityPolicyNonceManager( |
|
888 | - $c->getCsrfTokenManager(), |
|
889 | - $c->getRequest() |
|
890 | - ); |
|
891 | - }); |
|
892 | - |
|
893 | - $this->registerService(\OCP\Share\IManager::class, function(Server $c) { |
|
894 | - $config = $c->getConfig(); |
|
895 | - $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory'); |
|
896 | - /** @var \OCP\Share\IProviderFactory $factory */ |
|
897 | - $factory = new $factoryClass($this); |
|
898 | - |
|
899 | - $manager = new \OC\Share20\Manager( |
|
900 | - $c->getLogger(), |
|
901 | - $c->getConfig(), |
|
902 | - $c->getSecureRandom(), |
|
903 | - $c->getHasher(), |
|
904 | - $c->getMountManager(), |
|
905 | - $c->getGroupManager(), |
|
906 | - $c->getL10N('core'), |
|
907 | - $factory, |
|
908 | - $c->getUserManager(), |
|
909 | - $c->getLazyRootFolder(), |
|
910 | - $c->getEventDispatcher() |
|
911 | - ); |
|
912 | - |
|
913 | - return $manager; |
|
914 | - }); |
|
915 | - $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
916 | - |
|
917 | - $this->registerService('SettingsManager', function(Server $c) { |
|
918 | - $manager = new \OC\Settings\Manager( |
|
919 | - $c->getLogger(), |
|
920 | - $c->getDatabaseConnection(), |
|
921 | - $c->getL10N('lib'), |
|
922 | - $c->getConfig(), |
|
923 | - $c->getEncryptionManager(), |
|
924 | - $c->getUserManager(), |
|
925 | - $c->getLockingProvider(), |
|
926 | - $c->getRequest(), |
|
927 | - new \OC\Settings\Mapper($c->getDatabaseConnection()), |
|
928 | - $c->getURLGenerator() |
|
929 | - ); |
|
930 | - return $manager; |
|
931 | - }); |
|
932 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
933 | - return new \OC\Files\AppData\Factory( |
|
934 | - $c->getRootFolder(), |
|
935 | - $c->getSystemConfig() |
|
936 | - ); |
|
937 | - }); |
|
938 | - |
|
939 | - $this->registerService('LockdownManager', function (Server $c) { |
|
940 | - return new LockdownManager(); |
|
941 | - }); |
|
942 | - |
|
943 | - $this->registerService('OCSDiscoveryService', function (Server $c) { |
|
944 | - return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
945 | - }); |
|
946 | - |
|
947 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
948 | - return new CloudIdManager(); |
|
949 | - }); |
|
950 | - |
|
951 | - /* To trick DI since we don't extend the DIContainer here */ |
|
952 | - $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
953 | - return new CleanPreviewsBackgroundJob( |
|
954 | - $c->getRootFolder(), |
|
955 | - $c->getLogger(), |
|
956 | - $c->getJobList(), |
|
957 | - new TimeFactory() |
|
958 | - ); |
|
959 | - }); |
|
960 | - |
|
961 | - $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
962 | - $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
963 | - |
|
964 | - $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
965 | - $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
966 | - |
|
967 | - $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) { |
|
968 | - return $c->query(\OCP\IUserSession::class)->getSession(); |
|
969 | - }); |
|
970 | - } |
|
971 | - |
|
972 | - /** |
|
973 | - * @return \OCP\Contacts\IManager |
|
974 | - */ |
|
975 | - public function getContactsManager() { |
|
976 | - return $this->query('ContactsManager'); |
|
977 | - } |
|
978 | - |
|
979 | - /** |
|
980 | - * @return \OC\Encryption\Manager |
|
981 | - */ |
|
982 | - public function getEncryptionManager() { |
|
983 | - return $this->query('EncryptionManager'); |
|
984 | - } |
|
985 | - |
|
986 | - /** |
|
987 | - * @return \OC\Encryption\File |
|
988 | - */ |
|
989 | - public function getEncryptionFilesHelper() { |
|
990 | - return $this->query('EncryptionFileHelper'); |
|
991 | - } |
|
992 | - |
|
993 | - /** |
|
994 | - * @return \OCP\Encryption\Keys\IStorage |
|
995 | - */ |
|
996 | - public function getEncryptionKeyStorage() { |
|
997 | - return $this->query('EncryptionKeyStorage'); |
|
998 | - } |
|
999 | - |
|
1000 | - /** |
|
1001 | - * @return \OC\OCS\DiscoveryService |
|
1002 | - */ |
|
1003 | - public function getOCSDiscoveryService() { |
|
1004 | - return $this->query('OCSDiscoveryService'); |
|
1005 | - } |
|
1006 | - |
|
1007 | - |
|
1008 | - /** |
|
1009 | - * The current request object holding all information about the request |
|
1010 | - * currently being processed is returned from this method. |
|
1011 | - * In case the current execution was not initiated by a web request null is returned |
|
1012 | - * |
|
1013 | - * @return \OCP\IRequest |
|
1014 | - */ |
|
1015 | - public function getRequest() { |
|
1016 | - return $this->query('Request'); |
|
1017 | - } |
|
1018 | - |
|
1019 | - /** |
|
1020 | - * Returns the preview manager which can create preview images for a given file |
|
1021 | - * |
|
1022 | - * @return \OCP\IPreview |
|
1023 | - */ |
|
1024 | - public function getPreviewManager() { |
|
1025 | - return $this->query('PreviewManager'); |
|
1026 | - } |
|
1027 | - |
|
1028 | - /** |
|
1029 | - * Returns the tag manager which can get and set tags for different object types |
|
1030 | - * |
|
1031 | - * @see \OCP\ITagManager::load() |
|
1032 | - * @return \OCP\ITagManager |
|
1033 | - */ |
|
1034 | - public function getTagManager() { |
|
1035 | - return $this->query('TagManager'); |
|
1036 | - } |
|
1037 | - |
|
1038 | - /** |
|
1039 | - * Returns the system-tag manager |
|
1040 | - * |
|
1041 | - * @return \OCP\SystemTag\ISystemTagManager |
|
1042 | - * |
|
1043 | - * @since 9.0.0 |
|
1044 | - */ |
|
1045 | - public function getSystemTagManager() { |
|
1046 | - return $this->query('SystemTagManager'); |
|
1047 | - } |
|
1048 | - |
|
1049 | - /** |
|
1050 | - * Returns the system-tag object mapper |
|
1051 | - * |
|
1052 | - * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
1053 | - * |
|
1054 | - * @since 9.0.0 |
|
1055 | - */ |
|
1056 | - public function getSystemTagObjectMapper() { |
|
1057 | - return $this->query('SystemTagObjectMapper'); |
|
1058 | - } |
|
1059 | - |
|
1060 | - /** |
|
1061 | - * Returns the avatar manager, used for avatar functionality |
|
1062 | - * |
|
1063 | - * @return \OCP\IAvatarManager |
|
1064 | - */ |
|
1065 | - public function getAvatarManager() { |
|
1066 | - return $this->query('AvatarManager'); |
|
1067 | - } |
|
1068 | - |
|
1069 | - /** |
|
1070 | - * Returns the root folder of ownCloud's data directory |
|
1071 | - * |
|
1072 | - * @return \OCP\Files\IRootFolder |
|
1073 | - */ |
|
1074 | - public function getRootFolder() { |
|
1075 | - return $this->query('LazyRootFolder'); |
|
1076 | - } |
|
1077 | - |
|
1078 | - /** |
|
1079 | - * Returns the root folder of ownCloud's data directory |
|
1080 | - * This is the lazy variant so this gets only initialized once it |
|
1081 | - * is actually used. |
|
1082 | - * |
|
1083 | - * @return \OCP\Files\IRootFolder |
|
1084 | - */ |
|
1085 | - public function getLazyRootFolder() { |
|
1086 | - return $this->query('LazyRootFolder'); |
|
1087 | - } |
|
1088 | - |
|
1089 | - /** |
|
1090 | - * Returns a view to ownCloud's files folder |
|
1091 | - * |
|
1092 | - * @param string $userId user ID |
|
1093 | - * @return \OCP\Files\Folder|null |
|
1094 | - */ |
|
1095 | - public function getUserFolder($userId = null) { |
|
1096 | - if ($userId === null) { |
|
1097 | - $user = $this->getUserSession()->getUser(); |
|
1098 | - if (!$user) { |
|
1099 | - return null; |
|
1100 | - } |
|
1101 | - $userId = $user->getUID(); |
|
1102 | - } |
|
1103 | - $root = $this->getRootFolder(); |
|
1104 | - return $root->getUserFolder($userId); |
|
1105 | - } |
|
1106 | - |
|
1107 | - /** |
|
1108 | - * Returns an app-specific view in ownClouds data directory |
|
1109 | - * |
|
1110 | - * @return \OCP\Files\Folder |
|
1111 | - * @deprecated since 9.2.0 use IAppData |
|
1112 | - */ |
|
1113 | - public function getAppFolder() { |
|
1114 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
1115 | - $root = $this->getRootFolder(); |
|
1116 | - if (!$root->nodeExists($dir)) { |
|
1117 | - $folder = $root->newFolder($dir); |
|
1118 | - } else { |
|
1119 | - $folder = $root->get($dir); |
|
1120 | - } |
|
1121 | - return $folder; |
|
1122 | - } |
|
1123 | - |
|
1124 | - /** |
|
1125 | - * @return \OC\User\Manager |
|
1126 | - */ |
|
1127 | - public function getUserManager() { |
|
1128 | - return $this->query('UserManager'); |
|
1129 | - } |
|
1130 | - |
|
1131 | - /** |
|
1132 | - * @return \OC\Group\Manager |
|
1133 | - */ |
|
1134 | - public function getGroupManager() { |
|
1135 | - return $this->query('GroupManager'); |
|
1136 | - } |
|
1137 | - |
|
1138 | - /** |
|
1139 | - * @return \OC\User\Session |
|
1140 | - */ |
|
1141 | - public function getUserSession() { |
|
1142 | - return $this->query('UserSession'); |
|
1143 | - } |
|
1144 | - |
|
1145 | - /** |
|
1146 | - * @return \OCP\ISession |
|
1147 | - */ |
|
1148 | - public function getSession() { |
|
1149 | - return $this->query('UserSession')->getSession(); |
|
1150 | - } |
|
1151 | - |
|
1152 | - /** |
|
1153 | - * @param \OCP\ISession $session |
|
1154 | - */ |
|
1155 | - public function setSession(\OCP\ISession $session) { |
|
1156 | - $this->query(SessionStorage::class)->setSession($session); |
|
1157 | - $this->query('UserSession')->setSession($session); |
|
1158 | - $this->query(Store::class)->setSession($session); |
|
1159 | - } |
|
1160 | - |
|
1161 | - /** |
|
1162 | - * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1163 | - */ |
|
1164 | - public function getTwoFactorAuthManager() { |
|
1165 | - return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1166 | - } |
|
1167 | - |
|
1168 | - /** |
|
1169 | - * @return \OC\NavigationManager |
|
1170 | - */ |
|
1171 | - public function getNavigationManager() { |
|
1172 | - return $this->query('NavigationManager'); |
|
1173 | - } |
|
1174 | - |
|
1175 | - /** |
|
1176 | - * @return \OCP\IConfig |
|
1177 | - */ |
|
1178 | - public function getConfig() { |
|
1179 | - return $this->query('AllConfig'); |
|
1180 | - } |
|
1181 | - |
|
1182 | - /** |
|
1183 | - * @internal For internal use only |
|
1184 | - * @return \OC\SystemConfig |
|
1185 | - */ |
|
1186 | - public function getSystemConfig() { |
|
1187 | - return $this->query('SystemConfig'); |
|
1188 | - } |
|
1189 | - |
|
1190 | - /** |
|
1191 | - * Returns the app config manager |
|
1192 | - * |
|
1193 | - * @return \OCP\IAppConfig |
|
1194 | - */ |
|
1195 | - public function getAppConfig() { |
|
1196 | - return $this->query('AppConfig'); |
|
1197 | - } |
|
1198 | - |
|
1199 | - /** |
|
1200 | - * @return \OCP\L10N\IFactory |
|
1201 | - */ |
|
1202 | - public function getL10NFactory() { |
|
1203 | - return $this->query('L10NFactory'); |
|
1204 | - } |
|
1205 | - |
|
1206 | - /** |
|
1207 | - * get an L10N instance |
|
1208 | - * |
|
1209 | - * @param string $app appid |
|
1210 | - * @param string $lang |
|
1211 | - * @return IL10N |
|
1212 | - */ |
|
1213 | - public function getL10N($app, $lang = null) { |
|
1214 | - return $this->getL10NFactory()->get($app, $lang); |
|
1215 | - } |
|
1216 | - |
|
1217 | - /** |
|
1218 | - * @return \OCP\IURLGenerator |
|
1219 | - */ |
|
1220 | - public function getURLGenerator() { |
|
1221 | - return $this->query('URLGenerator'); |
|
1222 | - } |
|
1223 | - |
|
1224 | - /** |
|
1225 | - * @return \OCP\IHelper |
|
1226 | - */ |
|
1227 | - public function getHelper() { |
|
1228 | - return $this->query('AppHelper'); |
|
1229 | - } |
|
1230 | - |
|
1231 | - /** |
|
1232 | - * @return AppFetcher |
|
1233 | - */ |
|
1234 | - public function getAppFetcher() { |
|
1235 | - return $this->query('AppFetcher'); |
|
1236 | - } |
|
1237 | - |
|
1238 | - /** |
|
1239 | - * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1240 | - * getMemCacheFactory() instead. |
|
1241 | - * |
|
1242 | - * @return \OCP\ICache |
|
1243 | - * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1244 | - */ |
|
1245 | - public function getCache() { |
|
1246 | - return $this->query('UserCache'); |
|
1247 | - } |
|
1248 | - |
|
1249 | - /** |
|
1250 | - * Returns an \OCP\CacheFactory instance |
|
1251 | - * |
|
1252 | - * @return \OCP\ICacheFactory |
|
1253 | - */ |
|
1254 | - public function getMemCacheFactory() { |
|
1255 | - return $this->query('MemCacheFactory'); |
|
1256 | - } |
|
1257 | - |
|
1258 | - /** |
|
1259 | - * Returns an \OC\RedisFactory instance |
|
1260 | - * |
|
1261 | - * @return \OC\RedisFactory |
|
1262 | - */ |
|
1263 | - public function getGetRedisFactory() { |
|
1264 | - return $this->query('RedisFactory'); |
|
1265 | - } |
|
1266 | - |
|
1267 | - |
|
1268 | - /** |
|
1269 | - * Returns the current session |
|
1270 | - * |
|
1271 | - * @return \OCP\IDBConnection |
|
1272 | - */ |
|
1273 | - public function getDatabaseConnection() { |
|
1274 | - return $this->query('DatabaseConnection'); |
|
1275 | - } |
|
1276 | - |
|
1277 | - /** |
|
1278 | - * Returns the activity manager |
|
1279 | - * |
|
1280 | - * @return \OCP\Activity\IManager |
|
1281 | - */ |
|
1282 | - public function getActivityManager() { |
|
1283 | - return $this->query('ActivityManager'); |
|
1284 | - } |
|
1285 | - |
|
1286 | - /** |
|
1287 | - * Returns an job list for controlling background jobs |
|
1288 | - * |
|
1289 | - * @return \OCP\BackgroundJob\IJobList |
|
1290 | - */ |
|
1291 | - public function getJobList() { |
|
1292 | - return $this->query('JobList'); |
|
1293 | - } |
|
1294 | - |
|
1295 | - /** |
|
1296 | - * Returns a logger instance |
|
1297 | - * |
|
1298 | - * @return \OCP\ILogger |
|
1299 | - */ |
|
1300 | - public function getLogger() { |
|
1301 | - return $this->query('Logger'); |
|
1302 | - } |
|
1303 | - |
|
1304 | - /** |
|
1305 | - * Returns a router for generating and matching urls |
|
1306 | - * |
|
1307 | - * @return \OCP\Route\IRouter |
|
1308 | - */ |
|
1309 | - public function getRouter() { |
|
1310 | - return $this->query('Router'); |
|
1311 | - } |
|
1312 | - |
|
1313 | - /** |
|
1314 | - * Returns a search instance |
|
1315 | - * |
|
1316 | - * @return \OCP\ISearch |
|
1317 | - */ |
|
1318 | - public function getSearch() { |
|
1319 | - return $this->query('Search'); |
|
1320 | - } |
|
1321 | - |
|
1322 | - /** |
|
1323 | - * Returns a SecureRandom instance |
|
1324 | - * |
|
1325 | - * @return \OCP\Security\ISecureRandom |
|
1326 | - */ |
|
1327 | - public function getSecureRandom() { |
|
1328 | - return $this->query('SecureRandom'); |
|
1329 | - } |
|
1330 | - |
|
1331 | - /** |
|
1332 | - * Returns a Crypto instance |
|
1333 | - * |
|
1334 | - * @return \OCP\Security\ICrypto |
|
1335 | - */ |
|
1336 | - public function getCrypto() { |
|
1337 | - return $this->query('Crypto'); |
|
1338 | - } |
|
1339 | - |
|
1340 | - /** |
|
1341 | - * Returns a Hasher instance |
|
1342 | - * |
|
1343 | - * @return \OCP\Security\IHasher |
|
1344 | - */ |
|
1345 | - public function getHasher() { |
|
1346 | - return $this->query('Hasher'); |
|
1347 | - } |
|
1348 | - |
|
1349 | - /** |
|
1350 | - * Returns a CredentialsManager instance |
|
1351 | - * |
|
1352 | - * @return \OCP\Security\ICredentialsManager |
|
1353 | - */ |
|
1354 | - public function getCredentialsManager() { |
|
1355 | - return $this->query('CredentialsManager'); |
|
1356 | - } |
|
1357 | - |
|
1358 | - /** |
|
1359 | - * Returns an instance of the HTTP helper class |
|
1360 | - * |
|
1361 | - * @deprecated Use getHTTPClientService() |
|
1362 | - * @return \OC\HTTPHelper |
|
1363 | - */ |
|
1364 | - public function getHTTPHelper() { |
|
1365 | - return $this->query('HTTPHelper'); |
|
1366 | - } |
|
1367 | - |
|
1368 | - /** |
|
1369 | - * Get the certificate manager for the user |
|
1370 | - * |
|
1371 | - * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1372 | - * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1373 | - */ |
|
1374 | - public function getCertificateManager($userId = '') { |
|
1375 | - if ($userId === '') { |
|
1376 | - $userSession = $this->getUserSession(); |
|
1377 | - $user = $userSession->getUser(); |
|
1378 | - if (is_null($user)) { |
|
1379 | - return null; |
|
1380 | - } |
|
1381 | - $userId = $user->getUID(); |
|
1382 | - } |
|
1383 | - return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger()); |
|
1384 | - } |
|
1385 | - |
|
1386 | - /** |
|
1387 | - * Returns an instance of the HTTP client service |
|
1388 | - * |
|
1389 | - * @return \OCP\Http\Client\IClientService |
|
1390 | - */ |
|
1391 | - public function getHTTPClientService() { |
|
1392 | - return $this->query('HttpClientService'); |
|
1393 | - } |
|
1394 | - |
|
1395 | - /** |
|
1396 | - * Create a new event source |
|
1397 | - * |
|
1398 | - * @return \OCP\IEventSource |
|
1399 | - */ |
|
1400 | - public function createEventSource() { |
|
1401 | - return new \OC_EventSource(); |
|
1402 | - } |
|
1403 | - |
|
1404 | - /** |
|
1405 | - * Get the active event logger |
|
1406 | - * |
|
1407 | - * The returned logger only logs data when debug mode is enabled |
|
1408 | - * |
|
1409 | - * @return \OCP\Diagnostics\IEventLogger |
|
1410 | - */ |
|
1411 | - public function getEventLogger() { |
|
1412 | - return $this->query('EventLogger'); |
|
1413 | - } |
|
1414 | - |
|
1415 | - /** |
|
1416 | - * Get the active query logger |
|
1417 | - * |
|
1418 | - * The returned logger only logs data when debug mode is enabled |
|
1419 | - * |
|
1420 | - * @return \OCP\Diagnostics\IQueryLogger |
|
1421 | - */ |
|
1422 | - public function getQueryLogger() { |
|
1423 | - return $this->query('QueryLogger'); |
|
1424 | - } |
|
1425 | - |
|
1426 | - /** |
|
1427 | - * Get the manager for temporary files and folders |
|
1428 | - * |
|
1429 | - * @return \OCP\ITempManager |
|
1430 | - */ |
|
1431 | - public function getTempManager() { |
|
1432 | - return $this->query('TempManager'); |
|
1433 | - } |
|
1434 | - |
|
1435 | - /** |
|
1436 | - * Get the app manager |
|
1437 | - * |
|
1438 | - * @return \OCP\App\IAppManager |
|
1439 | - */ |
|
1440 | - public function getAppManager() { |
|
1441 | - return $this->query('AppManager'); |
|
1442 | - } |
|
1443 | - |
|
1444 | - /** |
|
1445 | - * Creates a new mailer |
|
1446 | - * |
|
1447 | - * @return \OCP\Mail\IMailer |
|
1448 | - */ |
|
1449 | - public function getMailer() { |
|
1450 | - return $this->query('Mailer'); |
|
1451 | - } |
|
1452 | - |
|
1453 | - /** |
|
1454 | - * Get the webroot |
|
1455 | - * |
|
1456 | - * @return string |
|
1457 | - */ |
|
1458 | - public function getWebRoot() { |
|
1459 | - return $this->webRoot; |
|
1460 | - } |
|
1461 | - |
|
1462 | - /** |
|
1463 | - * @return \OC\OCSClient |
|
1464 | - */ |
|
1465 | - public function getOcsClient() { |
|
1466 | - return $this->query('OcsClient'); |
|
1467 | - } |
|
1468 | - |
|
1469 | - /** |
|
1470 | - * @return \OCP\IDateTimeZone |
|
1471 | - */ |
|
1472 | - public function getDateTimeZone() { |
|
1473 | - return $this->query('DateTimeZone'); |
|
1474 | - } |
|
1475 | - |
|
1476 | - /** |
|
1477 | - * @return \OCP\IDateTimeFormatter |
|
1478 | - */ |
|
1479 | - public function getDateTimeFormatter() { |
|
1480 | - return $this->query('DateTimeFormatter'); |
|
1481 | - } |
|
1482 | - |
|
1483 | - /** |
|
1484 | - * @return \OCP\Files\Config\IMountProviderCollection |
|
1485 | - */ |
|
1486 | - public function getMountProviderCollection() { |
|
1487 | - return $this->query('MountConfigManager'); |
|
1488 | - } |
|
1489 | - |
|
1490 | - /** |
|
1491 | - * Get the IniWrapper |
|
1492 | - * |
|
1493 | - * @return IniGetWrapper |
|
1494 | - */ |
|
1495 | - public function getIniWrapper() { |
|
1496 | - return $this->query('IniWrapper'); |
|
1497 | - } |
|
1498 | - |
|
1499 | - /** |
|
1500 | - * @return \OCP\Command\IBus |
|
1501 | - */ |
|
1502 | - public function getCommandBus() { |
|
1503 | - return $this->query('AsyncCommandBus'); |
|
1504 | - } |
|
1505 | - |
|
1506 | - /** |
|
1507 | - * Get the trusted domain helper |
|
1508 | - * |
|
1509 | - * @return TrustedDomainHelper |
|
1510 | - */ |
|
1511 | - public function getTrustedDomainHelper() { |
|
1512 | - return $this->query('TrustedDomainHelper'); |
|
1513 | - } |
|
1514 | - |
|
1515 | - /** |
|
1516 | - * Get the locking provider |
|
1517 | - * |
|
1518 | - * @return \OCP\Lock\ILockingProvider |
|
1519 | - * @since 8.1.0 |
|
1520 | - */ |
|
1521 | - public function getLockingProvider() { |
|
1522 | - return $this->query('LockingProvider'); |
|
1523 | - } |
|
1524 | - |
|
1525 | - /** |
|
1526 | - * @return \OCP\Files\Mount\IMountManager |
|
1527 | - **/ |
|
1528 | - function getMountManager() { |
|
1529 | - return $this->query('MountManager'); |
|
1530 | - } |
|
1531 | - |
|
1532 | - /** @return \OCP\Files\Config\IUserMountCache */ |
|
1533 | - function getUserMountCache() { |
|
1534 | - return $this->query('UserMountCache'); |
|
1535 | - } |
|
1536 | - |
|
1537 | - /** |
|
1538 | - * Get the MimeTypeDetector |
|
1539 | - * |
|
1540 | - * @return \OCP\Files\IMimeTypeDetector |
|
1541 | - */ |
|
1542 | - public function getMimeTypeDetector() { |
|
1543 | - return $this->query('MimeTypeDetector'); |
|
1544 | - } |
|
1545 | - |
|
1546 | - /** |
|
1547 | - * Get the MimeTypeLoader |
|
1548 | - * |
|
1549 | - * @return \OCP\Files\IMimeTypeLoader |
|
1550 | - */ |
|
1551 | - public function getMimeTypeLoader() { |
|
1552 | - return $this->query('MimeTypeLoader'); |
|
1553 | - } |
|
1554 | - |
|
1555 | - /** |
|
1556 | - * Get the manager of all the capabilities |
|
1557 | - * |
|
1558 | - * @return \OC\CapabilitiesManager |
|
1559 | - */ |
|
1560 | - public function getCapabilitiesManager() { |
|
1561 | - return $this->query('CapabilitiesManager'); |
|
1562 | - } |
|
1563 | - |
|
1564 | - /** |
|
1565 | - * Get the EventDispatcher |
|
1566 | - * |
|
1567 | - * @return EventDispatcherInterface |
|
1568 | - * @since 8.2.0 |
|
1569 | - */ |
|
1570 | - public function getEventDispatcher() { |
|
1571 | - return $this->query('EventDispatcher'); |
|
1572 | - } |
|
1573 | - |
|
1574 | - /** |
|
1575 | - * Get the Notification Manager |
|
1576 | - * |
|
1577 | - * @return \OCP\Notification\IManager |
|
1578 | - * @since 8.2.0 |
|
1579 | - */ |
|
1580 | - public function getNotificationManager() { |
|
1581 | - return $this->query('NotificationManager'); |
|
1582 | - } |
|
1583 | - |
|
1584 | - /** |
|
1585 | - * @return \OCP\Comments\ICommentsManager |
|
1586 | - */ |
|
1587 | - public function getCommentsManager() { |
|
1588 | - return $this->query('CommentsManager'); |
|
1589 | - } |
|
1590 | - |
|
1591 | - /** |
|
1592 | - * @return \OC_Defaults |
|
1593 | - */ |
|
1594 | - public function getThemingDefaults() { |
|
1595 | - return $this->query('ThemingDefaults'); |
|
1596 | - } |
|
1597 | - |
|
1598 | - /** |
|
1599 | - * @return \OC\IntegrityCheck\Checker |
|
1600 | - */ |
|
1601 | - public function getIntegrityCodeChecker() { |
|
1602 | - return $this->query('IntegrityCodeChecker'); |
|
1603 | - } |
|
1604 | - |
|
1605 | - /** |
|
1606 | - * @return \OC\Session\CryptoWrapper |
|
1607 | - */ |
|
1608 | - public function getSessionCryptoWrapper() { |
|
1609 | - return $this->query('CryptoWrapper'); |
|
1610 | - } |
|
1611 | - |
|
1612 | - /** |
|
1613 | - * @return CsrfTokenManager |
|
1614 | - */ |
|
1615 | - public function getCsrfTokenManager() { |
|
1616 | - return $this->query('CsrfTokenManager'); |
|
1617 | - } |
|
1618 | - |
|
1619 | - /** |
|
1620 | - * @return Throttler |
|
1621 | - */ |
|
1622 | - public function getBruteForceThrottler() { |
|
1623 | - return $this->query('Throttler'); |
|
1624 | - } |
|
1625 | - |
|
1626 | - /** |
|
1627 | - * @return IContentSecurityPolicyManager |
|
1628 | - */ |
|
1629 | - public function getContentSecurityPolicyManager() { |
|
1630 | - return $this->query('ContentSecurityPolicyManager'); |
|
1631 | - } |
|
1632 | - |
|
1633 | - /** |
|
1634 | - * @return ContentSecurityPolicyNonceManager |
|
1635 | - */ |
|
1636 | - public function getContentSecurityPolicyNonceManager() { |
|
1637 | - return $this->query('ContentSecurityPolicyNonceManager'); |
|
1638 | - } |
|
1639 | - |
|
1640 | - /** |
|
1641 | - * Not a public API as of 8.2, wait for 9.0 |
|
1642 | - * |
|
1643 | - * @return \OCA\Files_External\Service\BackendService |
|
1644 | - */ |
|
1645 | - public function getStoragesBackendService() { |
|
1646 | - return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1647 | - } |
|
1648 | - |
|
1649 | - /** |
|
1650 | - * Not a public API as of 8.2, wait for 9.0 |
|
1651 | - * |
|
1652 | - * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1653 | - */ |
|
1654 | - public function getGlobalStoragesService() { |
|
1655 | - return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1656 | - } |
|
1657 | - |
|
1658 | - /** |
|
1659 | - * Not a public API as of 8.2, wait for 9.0 |
|
1660 | - * |
|
1661 | - * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1662 | - */ |
|
1663 | - public function getUserGlobalStoragesService() { |
|
1664 | - return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1665 | - } |
|
1666 | - |
|
1667 | - /** |
|
1668 | - * Not a public API as of 8.2, wait for 9.0 |
|
1669 | - * |
|
1670 | - * @return \OCA\Files_External\Service\UserStoragesService |
|
1671 | - */ |
|
1672 | - public function getUserStoragesService() { |
|
1673 | - return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1674 | - } |
|
1675 | - |
|
1676 | - /** |
|
1677 | - * @return \OCP\Share\IManager |
|
1678 | - */ |
|
1679 | - public function getShareManager() { |
|
1680 | - return $this->query('ShareManager'); |
|
1681 | - } |
|
1682 | - |
|
1683 | - /** |
|
1684 | - * Returns the LDAP Provider |
|
1685 | - * |
|
1686 | - * @return \OCP\LDAP\ILDAPProvider |
|
1687 | - */ |
|
1688 | - public function getLDAPProvider() { |
|
1689 | - return $this->query('LDAPProvider'); |
|
1690 | - } |
|
1691 | - |
|
1692 | - /** |
|
1693 | - * @return \OCP\Settings\IManager |
|
1694 | - */ |
|
1695 | - public function getSettingsManager() { |
|
1696 | - return $this->query('SettingsManager'); |
|
1697 | - } |
|
1698 | - |
|
1699 | - /** |
|
1700 | - * @return \OCP\Files\IAppData |
|
1701 | - */ |
|
1702 | - public function getAppDataDir($app) { |
|
1703 | - /** @var \OC\Files\AppData\Factory $factory */ |
|
1704 | - $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
1705 | - return $factory->get($app); |
|
1706 | - } |
|
1707 | - |
|
1708 | - /** |
|
1709 | - * @return \OCP\Lockdown\ILockdownManager |
|
1710 | - */ |
|
1711 | - public function getLockdownManager() { |
|
1712 | - return $this->query('LockdownManager'); |
|
1713 | - } |
|
1714 | - |
|
1715 | - /** |
|
1716 | - * @return \OCP\Federation\ICloudIdManager |
|
1717 | - */ |
|
1718 | - public function getCloudIdManager() { |
|
1719 | - return $this->query(ICloudIdManager::class); |
|
1720 | - } |
|
820 | + $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
821 | + if (isset($prefixes['OCA\\Theming\\'])) { |
|
822 | + $classExists = true; |
|
823 | + } else { |
|
824 | + $classExists = false; |
|
825 | + } |
|
826 | + |
|
827 | + if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) { |
|
828 | + return new ThemingDefaults( |
|
829 | + $c->getConfig(), |
|
830 | + $c->getL10N('theming'), |
|
831 | + $c->getURLGenerator(), |
|
832 | + new \OC_Defaults(), |
|
833 | + $c->getLazyRootFolder(), |
|
834 | + $c->getMemCacheFactory() |
|
835 | + ); |
|
836 | + } |
|
837 | + return new \OC_Defaults(); |
|
838 | + }); |
|
839 | + $this->registerService(EventDispatcher::class, function () { |
|
840 | + return new EventDispatcher(); |
|
841 | + }); |
|
842 | + $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
843 | + $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
844 | + |
|
845 | + $this->registerService('CryptoWrapper', function (Server $c) { |
|
846 | + // FIXME: Instantiiated here due to cyclic dependency |
|
847 | + $request = new Request( |
|
848 | + [ |
|
849 | + 'get' => $_GET, |
|
850 | + 'post' => $_POST, |
|
851 | + 'files' => $_FILES, |
|
852 | + 'server' => $_SERVER, |
|
853 | + 'env' => $_ENV, |
|
854 | + 'cookies' => $_COOKIE, |
|
855 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
856 | + ? $_SERVER['REQUEST_METHOD'] |
|
857 | + : null, |
|
858 | + ], |
|
859 | + $c->getSecureRandom(), |
|
860 | + $c->getConfig() |
|
861 | + ); |
|
862 | + |
|
863 | + return new CryptoWrapper( |
|
864 | + $c->getConfig(), |
|
865 | + $c->getCrypto(), |
|
866 | + $c->getSecureRandom(), |
|
867 | + $request |
|
868 | + ); |
|
869 | + }); |
|
870 | + $this->registerService('CsrfTokenManager', function (Server $c) { |
|
871 | + $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
872 | + |
|
873 | + return new CsrfTokenManager( |
|
874 | + $tokenGenerator, |
|
875 | + $c->query(SessionStorage::class) |
|
876 | + ); |
|
877 | + }); |
|
878 | + $this->registerService(SessionStorage::class, function (Server $c) { |
|
879 | + return new SessionStorage($c->getSession()); |
|
880 | + }); |
|
881 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
882 | + return new ContentSecurityPolicyManager(); |
|
883 | + }); |
|
884 | + $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
885 | + |
|
886 | + $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) { |
|
887 | + return new ContentSecurityPolicyNonceManager( |
|
888 | + $c->getCsrfTokenManager(), |
|
889 | + $c->getRequest() |
|
890 | + ); |
|
891 | + }); |
|
892 | + |
|
893 | + $this->registerService(\OCP\Share\IManager::class, function(Server $c) { |
|
894 | + $config = $c->getConfig(); |
|
895 | + $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory'); |
|
896 | + /** @var \OCP\Share\IProviderFactory $factory */ |
|
897 | + $factory = new $factoryClass($this); |
|
898 | + |
|
899 | + $manager = new \OC\Share20\Manager( |
|
900 | + $c->getLogger(), |
|
901 | + $c->getConfig(), |
|
902 | + $c->getSecureRandom(), |
|
903 | + $c->getHasher(), |
|
904 | + $c->getMountManager(), |
|
905 | + $c->getGroupManager(), |
|
906 | + $c->getL10N('core'), |
|
907 | + $factory, |
|
908 | + $c->getUserManager(), |
|
909 | + $c->getLazyRootFolder(), |
|
910 | + $c->getEventDispatcher() |
|
911 | + ); |
|
912 | + |
|
913 | + return $manager; |
|
914 | + }); |
|
915 | + $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
916 | + |
|
917 | + $this->registerService('SettingsManager', function(Server $c) { |
|
918 | + $manager = new \OC\Settings\Manager( |
|
919 | + $c->getLogger(), |
|
920 | + $c->getDatabaseConnection(), |
|
921 | + $c->getL10N('lib'), |
|
922 | + $c->getConfig(), |
|
923 | + $c->getEncryptionManager(), |
|
924 | + $c->getUserManager(), |
|
925 | + $c->getLockingProvider(), |
|
926 | + $c->getRequest(), |
|
927 | + new \OC\Settings\Mapper($c->getDatabaseConnection()), |
|
928 | + $c->getURLGenerator() |
|
929 | + ); |
|
930 | + return $manager; |
|
931 | + }); |
|
932 | + $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
933 | + return new \OC\Files\AppData\Factory( |
|
934 | + $c->getRootFolder(), |
|
935 | + $c->getSystemConfig() |
|
936 | + ); |
|
937 | + }); |
|
938 | + |
|
939 | + $this->registerService('LockdownManager', function (Server $c) { |
|
940 | + return new LockdownManager(); |
|
941 | + }); |
|
942 | + |
|
943 | + $this->registerService('OCSDiscoveryService', function (Server $c) { |
|
944 | + return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
945 | + }); |
|
946 | + |
|
947 | + $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
948 | + return new CloudIdManager(); |
|
949 | + }); |
|
950 | + |
|
951 | + /* To trick DI since we don't extend the DIContainer here */ |
|
952 | + $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
953 | + return new CleanPreviewsBackgroundJob( |
|
954 | + $c->getRootFolder(), |
|
955 | + $c->getLogger(), |
|
956 | + $c->getJobList(), |
|
957 | + new TimeFactory() |
|
958 | + ); |
|
959 | + }); |
|
960 | + |
|
961 | + $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
962 | + $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
963 | + |
|
964 | + $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
965 | + $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
966 | + |
|
967 | + $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) { |
|
968 | + return $c->query(\OCP\IUserSession::class)->getSession(); |
|
969 | + }); |
|
970 | + } |
|
971 | + |
|
972 | + /** |
|
973 | + * @return \OCP\Contacts\IManager |
|
974 | + */ |
|
975 | + public function getContactsManager() { |
|
976 | + return $this->query('ContactsManager'); |
|
977 | + } |
|
978 | + |
|
979 | + /** |
|
980 | + * @return \OC\Encryption\Manager |
|
981 | + */ |
|
982 | + public function getEncryptionManager() { |
|
983 | + return $this->query('EncryptionManager'); |
|
984 | + } |
|
985 | + |
|
986 | + /** |
|
987 | + * @return \OC\Encryption\File |
|
988 | + */ |
|
989 | + public function getEncryptionFilesHelper() { |
|
990 | + return $this->query('EncryptionFileHelper'); |
|
991 | + } |
|
992 | + |
|
993 | + /** |
|
994 | + * @return \OCP\Encryption\Keys\IStorage |
|
995 | + */ |
|
996 | + public function getEncryptionKeyStorage() { |
|
997 | + return $this->query('EncryptionKeyStorage'); |
|
998 | + } |
|
999 | + |
|
1000 | + /** |
|
1001 | + * @return \OC\OCS\DiscoveryService |
|
1002 | + */ |
|
1003 | + public function getOCSDiscoveryService() { |
|
1004 | + return $this->query('OCSDiscoveryService'); |
|
1005 | + } |
|
1006 | + |
|
1007 | + |
|
1008 | + /** |
|
1009 | + * The current request object holding all information about the request |
|
1010 | + * currently being processed is returned from this method. |
|
1011 | + * In case the current execution was not initiated by a web request null is returned |
|
1012 | + * |
|
1013 | + * @return \OCP\IRequest |
|
1014 | + */ |
|
1015 | + public function getRequest() { |
|
1016 | + return $this->query('Request'); |
|
1017 | + } |
|
1018 | + |
|
1019 | + /** |
|
1020 | + * Returns the preview manager which can create preview images for a given file |
|
1021 | + * |
|
1022 | + * @return \OCP\IPreview |
|
1023 | + */ |
|
1024 | + public function getPreviewManager() { |
|
1025 | + return $this->query('PreviewManager'); |
|
1026 | + } |
|
1027 | + |
|
1028 | + /** |
|
1029 | + * Returns the tag manager which can get and set tags for different object types |
|
1030 | + * |
|
1031 | + * @see \OCP\ITagManager::load() |
|
1032 | + * @return \OCP\ITagManager |
|
1033 | + */ |
|
1034 | + public function getTagManager() { |
|
1035 | + return $this->query('TagManager'); |
|
1036 | + } |
|
1037 | + |
|
1038 | + /** |
|
1039 | + * Returns the system-tag manager |
|
1040 | + * |
|
1041 | + * @return \OCP\SystemTag\ISystemTagManager |
|
1042 | + * |
|
1043 | + * @since 9.0.0 |
|
1044 | + */ |
|
1045 | + public function getSystemTagManager() { |
|
1046 | + return $this->query('SystemTagManager'); |
|
1047 | + } |
|
1048 | + |
|
1049 | + /** |
|
1050 | + * Returns the system-tag object mapper |
|
1051 | + * |
|
1052 | + * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
1053 | + * |
|
1054 | + * @since 9.0.0 |
|
1055 | + */ |
|
1056 | + public function getSystemTagObjectMapper() { |
|
1057 | + return $this->query('SystemTagObjectMapper'); |
|
1058 | + } |
|
1059 | + |
|
1060 | + /** |
|
1061 | + * Returns the avatar manager, used for avatar functionality |
|
1062 | + * |
|
1063 | + * @return \OCP\IAvatarManager |
|
1064 | + */ |
|
1065 | + public function getAvatarManager() { |
|
1066 | + return $this->query('AvatarManager'); |
|
1067 | + } |
|
1068 | + |
|
1069 | + /** |
|
1070 | + * Returns the root folder of ownCloud's data directory |
|
1071 | + * |
|
1072 | + * @return \OCP\Files\IRootFolder |
|
1073 | + */ |
|
1074 | + public function getRootFolder() { |
|
1075 | + return $this->query('LazyRootFolder'); |
|
1076 | + } |
|
1077 | + |
|
1078 | + /** |
|
1079 | + * Returns the root folder of ownCloud's data directory |
|
1080 | + * This is the lazy variant so this gets only initialized once it |
|
1081 | + * is actually used. |
|
1082 | + * |
|
1083 | + * @return \OCP\Files\IRootFolder |
|
1084 | + */ |
|
1085 | + public function getLazyRootFolder() { |
|
1086 | + return $this->query('LazyRootFolder'); |
|
1087 | + } |
|
1088 | + |
|
1089 | + /** |
|
1090 | + * Returns a view to ownCloud's files folder |
|
1091 | + * |
|
1092 | + * @param string $userId user ID |
|
1093 | + * @return \OCP\Files\Folder|null |
|
1094 | + */ |
|
1095 | + public function getUserFolder($userId = null) { |
|
1096 | + if ($userId === null) { |
|
1097 | + $user = $this->getUserSession()->getUser(); |
|
1098 | + if (!$user) { |
|
1099 | + return null; |
|
1100 | + } |
|
1101 | + $userId = $user->getUID(); |
|
1102 | + } |
|
1103 | + $root = $this->getRootFolder(); |
|
1104 | + return $root->getUserFolder($userId); |
|
1105 | + } |
|
1106 | + |
|
1107 | + /** |
|
1108 | + * Returns an app-specific view in ownClouds data directory |
|
1109 | + * |
|
1110 | + * @return \OCP\Files\Folder |
|
1111 | + * @deprecated since 9.2.0 use IAppData |
|
1112 | + */ |
|
1113 | + public function getAppFolder() { |
|
1114 | + $dir = '/' . \OC_App::getCurrentApp(); |
|
1115 | + $root = $this->getRootFolder(); |
|
1116 | + if (!$root->nodeExists($dir)) { |
|
1117 | + $folder = $root->newFolder($dir); |
|
1118 | + } else { |
|
1119 | + $folder = $root->get($dir); |
|
1120 | + } |
|
1121 | + return $folder; |
|
1122 | + } |
|
1123 | + |
|
1124 | + /** |
|
1125 | + * @return \OC\User\Manager |
|
1126 | + */ |
|
1127 | + public function getUserManager() { |
|
1128 | + return $this->query('UserManager'); |
|
1129 | + } |
|
1130 | + |
|
1131 | + /** |
|
1132 | + * @return \OC\Group\Manager |
|
1133 | + */ |
|
1134 | + public function getGroupManager() { |
|
1135 | + return $this->query('GroupManager'); |
|
1136 | + } |
|
1137 | + |
|
1138 | + /** |
|
1139 | + * @return \OC\User\Session |
|
1140 | + */ |
|
1141 | + public function getUserSession() { |
|
1142 | + return $this->query('UserSession'); |
|
1143 | + } |
|
1144 | + |
|
1145 | + /** |
|
1146 | + * @return \OCP\ISession |
|
1147 | + */ |
|
1148 | + public function getSession() { |
|
1149 | + return $this->query('UserSession')->getSession(); |
|
1150 | + } |
|
1151 | + |
|
1152 | + /** |
|
1153 | + * @param \OCP\ISession $session |
|
1154 | + */ |
|
1155 | + public function setSession(\OCP\ISession $session) { |
|
1156 | + $this->query(SessionStorage::class)->setSession($session); |
|
1157 | + $this->query('UserSession')->setSession($session); |
|
1158 | + $this->query(Store::class)->setSession($session); |
|
1159 | + } |
|
1160 | + |
|
1161 | + /** |
|
1162 | + * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1163 | + */ |
|
1164 | + public function getTwoFactorAuthManager() { |
|
1165 | + return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1166 | + } |
|
1167 | + |
|
1168 | + /** |
|
1169 | + * @return \OC\NavigationManager |
|
1170 | + */ |
|
1171 | + public function getNavigationManager() { |
|
1172 | + return $this->query('NavigationManager'); |
|
1173 | + } |
|
1174 | + |
|
1175 | + /** |
|
1176 | + * @return \OCP\IConfig |
|
1177 | + */ |
|
1178 | + public function getConfig() { |
|
1179 | + return $this->query('AllConfig'); |
|
1180 | + } |
|
1181 | + |
|
1182 | + /** |
|
1183 | + * @internal For internal use only |
|
1184 | + * @return \OC\SystemConfig |
|
1185 | + */ |
|
1186 | + public function getSystemConfig() { |
|
1187 | + return $this->query('SystemConfig'); |
|
1188 | + } |
|
1189 | + |
|
1190 | + /** |
|
1191 | + * Returns the app config manager |
|
1192 | + * |
|
1193 | + * @return \OCP\IAppConfig |
|
1194 | + */ |
|
1195 | + public function getAppConfig() { |
|
1196 | + return $this->query('AppConfig'); |
|
1197 | + } |
|
1198 | + |
|
1199 | + /** |
|
1200 | + * @return \OCP\L10N\IFactory |
|
1201 | + */ |
|
1202 | + public function getL10NFactory() { |
|
1203 | + return $this->query('L10NFactory'); |
|
1204 | + } |
|
1205 | + |
|
1206 | + /** |
|
1207 | + * get an L10N instance |
|
1208 | + * |
|
1209 | + * @param string $app appid |
|
1210 | + * @param string $lang |
|
1211 | + * @return IL10N |
|
1212 | + */ |
|
1213 | + public function getL10N($app, $lang = null) { |
|
1214 | + return $this->getL10NFactory()->get($app, $lang); |
|
1215 | + } |
|
1216 | + |
|
1217 | + /** |
|
1218 | + * @return \OCP\IURLGenerator |
|
1219 | + */ |
|
1220 | + public function getURLGenerator() { |
|
1221 | + return $this->query('URLGenerator'); |
|
1222 | + } |
|
1223 | + |
|
1224 | + /** |
|
1225 | + * @return \OCP\IHelper |
|
1226 | + */ |
|
1227 | + public function getHelper() { |
|
1228 | + return $this->query('AppHelper'); |
|
1229 | + } |
|
1230 | + |
|
1231 | + /** |
|
1232 | + * @return AppFetcher |
|
1233 | + */ |
|
1234 | + public function getAppFetcher() { |
|
1235 | + return $this->query('AppFetcher'); |
|
1236 | + } |
|
1237 | + |
|
1238 | + /** |
|
1239 | + * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1240 | + * getMemCacheFactory() instead. |
|
1241 | + * |
|
1242 | + * @return \OCP\ICache |
|
1243 | + * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1244 | + */ |
|
1245 | + public function getCache() { |
|
1246 | + return $this->query('UserCache'); |
|
1247 | + } |
|
1248 | + |
|
1249 | + /** |
|
1250 | + * Returns an \OCP\CacheFactory instance |
|
1251 | + * |
|
1252 | + * @return \OCP\ICacheFactory |
|
1253 | + */ |
|
1254 | + public function getMemCacheFactory() { |
|
1255 | + return $this->query('MemCacheFactory'); |
|
1256 | + } |
|
1257 | + |
|
1258 | + /** |
|
1259 | + * Returns an \OC\RedisFactory instance |
|
1260 | + * |
|
1261 | + * @return \OC\RedisFactory |
|
1262 | + */ |
|
1263 | + public function getGetRedisFactory() { |
|
1264 | + return $this->query('RedisFactory'); |
|
1265 | + } |
|
1266 | + |
|
1267 | + |
|
1268 | + /** |
|
1269 | + * Returns the current session |
|
1270 | + * |
|
1271 | + * @return \OCP\IDBConnection |
|
1272 | + */ |
|
1273 | + public function getDatabaseConnection() { |
|
1274 | + return $this->query('DatabaseConnection'); |
|
1275 | + } |
|
1276 | + |
|
1277 | + /** |
|
1278 | + * Returns the activity manager |
|
1279 | + * |
|
1280 | + * @return \OCP\Activity\IManager |
|
1281 | + */ |
|
1282 | + public function getActivityManager() { |
|
1283 | + return $this->query('ActivityManager'); |
|
1284 | + } |
|
1285 | + |
|
1286 | + /** |
|
1287 | + * Returns an job list for controlling background jobs |
|
1288 | + * |
|
1289 | + * @return \OCP\BackgroundJob\IJobList |
|
1290 | + */ |
|
1291 | + public function getJobList() { |
|
1292 | + return $this->query('JobList'); |
|
1293 | + } |
|
1294 | + |
|
1295 | + /** |
|
1296 | + * Returns a logger instance |
|
1297 | + * |
|
1298 | + * @return \OCP\ILogger |
|
1299 | + */ |
|
1300 | + public function getLogger() { |
|
1301 | + return $this->query('Logger'); |
|
1302 | + } |
|
1303 | + |
|
1304 | + /** |
|
1305 | + * Returns a router for generating and matching urls |
|
1306 | + * |
|
1307 | + * @return \OCP\Route\IRouter |
|
1308 | + */ |
|
1309 | + public function getRouter() { |
|
1310 | + return $this->query('Router'); |
|
1311 | + } |
|
1312 | + |
|
1313 | + /** |
|
1314 | + * Returns a search instance |
|
1315 | + * |
|
1316 | + * @return \OCP\ISearch |
|
1317 | + */ |
|
1318 | + public function getSearch() { |
|
1319 | + return $this->query('Search'); |
|
1320 | + } |
|
1321 | + |
|
1322 | + /** |
|
1323 | + * Returns a SecureRandom instance |
|
1324 | + * |
|
1325 | + * @return \OCP\Security\ISecureRandom |
|
1326 | + */ |
|
1327 | + public function getSecureRandom() { |
|
1328 | + return $this->query('SecureRandom'); |
|
1329 | + } |
|
1330 | + |
|
1331 | + /** |
|
1332 | + * Returns a Crypto instance |
|
1333 | + * |
|
1334 | + * @return \OCP\Security\ICrypto |
|
1335 | + */ |
|
1336 | + public function getCrypto() { |
|
1337 | + return $this->query('Crypto'); |
|
1338 | + } |
|
1339 | + |
|
1340 | + /** |
|
1341 | + * Returns a Hasher instance |
|
1342 | + * |
|
1343 | + * @return \OCP\Security\IHasher |
|
1344 | + */ |
|
1345 | + public function getHasher() { |
|
1346 | + return $this->query('Hasher'); |
|
1347 | + } |
|
1348 | + |
|
1349 | + /** |
|
1350 | + * Returns a CredentialsManager instance |
|
1351 | + * |
|
1352 | + * @return \OCP\Security\ICredentialsManager |
|
1353 | + */ |
|
1354 | + public function getCredentialsManager() { |
|
1355 | + return $this->query('CredentialsManager'); |
|
1356 | + } |
|
1357 | + |
|
1358 | + /** |
|
1359 | + * Returns an instance of the HTTP helper class |
|
1360 | + * |
|
1361 | + * @deprecated Use getHTTPClientService() |
|
1362 | + * @return \OC\HTTPHelper |
|
1363 | + */ |
|
1364 | + public function getHTTPHelper() { |
|
1365 | + return $this->query('HTTPHelper'); |
|
1366 | + } |
|
1367 | + |
|
1368 | + /** |
|
1369 | + * Get the certificate manager for the user |
|
1370 | + * |
|
1371 | + * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1372 | + * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1373 | + */ |
|
1374 | + public function getCertificateManager($userId = '') { |
|
1375 | + if ($userId === '') { |
|
1376 | + $userSession = $this->getUserSession(); |
|
1377 | + $user = $userSession->getUser(); |
|
1378 | + if (is_null($user)) { |
|
1379 | + return null; |
|
1380 | + } |
|
1381 | + $userId = $user->getUID(); |
|
1382 | + } |
|
1383 | + return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger()); |
|
1384 | + } |
|
1385 | + |
|
1386 | + /** |
|
1387 | + * Returns an instance of the HTTP client service |
|
1388 | + * |
|
1389 | + * @return \OCP\Http\Client\IClientService |
|
1390 | + */ |
|
1391 | + public function getHTTPClientService() { |
|
1392 | + return $this->query('HttpClientService'); |
|
1393 | + } |
|
1394 | + |
|
1395 | + /** |
|
1396 | + * Create a new event source |
|
1397 | + * |
|
1398 | + * @return \OCP\IEventSource |
|
1399 | + */ |
|
1400 | + public function createEventSource() { |
|
1401 | + return new \OC_EventSource(); |
|
1402 | + } |
|
1403 | + |
|
1404 | + /** |
|
1405 | + * Get the active event logger |
|
1406 | + * |
|
1407 | + * The returned logger only logs data when debug mode is enabled |
|
1408 | + * |
|
1409 | + * @return \OCP\Diagnostics\IEventLogger |
|
1410 | + */ |
|
1411 | + public function getEventLogger() { |
|
1412 | + return $this->query('EventLogger'); |
|
1413 | + } |
|
1414 | + |
|
1415 | + /** |
|
1416 | + * Get the active query logger |
|
1417 | + * |
|
1418 | + * The returned logger only logs data when debug mode is enabled |
|
1419 | + * |
|
1420 | + * @return \OCP\Diagnostics\IQueryLogger |
|
1421 | + */ |
|
1422 | + public function getQueryLogger() { |
|
1423 | + return $this->query('QueryLogger'); |
|
1424 | + } |
|
1425 | + |
|
1426 | + /** |
|
1427 | + * Get the manager for temporary files and folders |
|
1428 | + * |
|
1429 | + * @return \OCP\ITempManager |
|
1430 | + */ |
|
1431 | + public function getTempManager() { |
|
1432 | + return $this->query('TempManager'); |
|
1433 | + } |
|
1434 | + |
|
1435 | + /** |
|
1436 | + * Get the app manager |
|
1437 | + * |
|
1438 | + * @return \OCP\App\IAppManager |
|
1439 | + */ |
|
1440 | + public function getAppManager() { |
|
1441 | + return $this->query('AppManager'); |
|
1442 | + } |
|
1443 | + |
|
1444 | + /** |
|
1445 | + * Creates a new mailer |
|
1446 | + * |
|
1447 | + * @return \OCP\Mail\IMailer |
|
1448 | + */ |
|
1449 | + public function getMailer() { |
|
1450 | + return $this->query('Mailer'); |
|
1451 | + } |
|
1452 | + |
|
1453 | + /** |
|
1454 | + * Get the webroot |
|
1455 | + * |
|
1456 | + * @return string |
|
1457 | + */ |
|
1458 | + public function getWebRoot() { |
|
1459 | + return $this->webRoot; |
|
1460 | + } |
|
1461 | + |
|
1462 | + /** |
|
1463 | + * @return \OC\OCSClient |
|
1464 | + */ |
|
1465 | + public function getOcsClient() { |
|
1466 | + return $this->query('OcsClient'); |
|
1467 | + } |
|
1468 | + |
|
1469 | + /** |
|
1470 | + * @return \OCP\IDateTimeZone |
|
1471 | + */ |
|
1472 | + public function getDateTimeZone() { |
|
1473 | + return $this->query('DateTimeZone'); |
|
1474 | + } |
|
1475 | + |
|
1476 | + /** |
|
1477 | + * @return \OCP\IDateTimeFormatter |
|
1478 | + */ |
|
1479 | + public function getDateTimeFormatter() { |
|
1480 | + return $this->query('DateTimeFormatter'); |
|
1481 | + } |
|
1482 | + |
|
1483 | + /** |
|
1484 | + * @return \OCP\Files\Config\IMountProviderCollection |
|
1485 | + */ |
|
1486 | + public function getMountProviderCollection() { |
|
1487 | + return $this->query('MountConfigManager'); |
|
1488 | + } |
|
1489 | + |
|
1490 | + /** |
|
1491 | + * Get the IniWrapper |
|
1492 | + * |
|
1493 | + * @return IniGetWrapper |
|
1494 | + */ |
|
1495 | + public function getIniWrapper() { |
|
1496 | + return $this->query('IniWrapper'); |
|
1497 | + } |
|
1498 | + |
|
1499 | + /** |
|
1500 | + * @return \OCP\Command\IBus |
|
1501 | + */ |
|
1502 | + public function getCommandBus() { |
|
1503 | + return $this->query('AsyncCommandBus'); |
|
1504 | + } |
|
1505 | + |
|
1506 | + /** |
|
1507 | + * Get the trusted domain helper |
|
1508 | + * |
|
1509 | + * @return TrustedDomainHelper |
|
1510 | + */ |
|
1511 | + public function getTrustedDomainHelper() { |
|
1512 | + return $this->query('TrustedDomainHelper'); |
|
1513 | + } |
|
1514 | + |
|
1515 | + /** |
|
1516 | + * Get the locking provider |
|
1517 | + * |
|
1518 | + * @return \OCP\Lock\ILockingProvider |
|
1519 | + * @since 8.1.0 |
|
1520 | + */ |
|
1521 | + public function getLockingProvider() { |
|
1522 | + return $this->query('LockingProvider'); |
|
1523 | + } |
|
1524 | + |
|
1525 | + /** |
|
1526 | + * @return \OCP\Files\Mount\IMountManager |
|
1527 | + **/ |
|
1528 | + function getMountManager() { |
|
1529 | + return $this->query('MountManager'); |
|
1530 | + } |
|
1531 | + |
|
1532 | + /** @return \OCP\Files\Config\IUserMountCache */ |
|
1533 | + function getUserMountCache() { |
|
1534 | + return $this->query('UserMountCache'); |
|
1535 | + } |
|
1536 | + |
|
1537 | + /** |
|
1538 | + * Get the MimeTypeDetector |
|
1539 | + * |
|
1540 | + * @return \OCP\Files\IMimeTypeDetector |
|
1541 | + */ |
|
1542 | + public function getMimeTypeDetector() { |
|
1543 | + return $this->query('MimeTypeDetector'); |
|
1544 | + } |
|
1545 | + |
|
1546 | + /** |
|
1547 | + * Get the MimeTypeLoader |
|
1548 | + * |
|
1549 | + * @return \OCP\Files\IMimeTypeLoader |
|
1550 | + */ |
|
1551 | + public function getMimeTypeLoader() { |
|
1552 | + return $this->query('MimeTypeLoader'); |
|
1553 | + } |
|
1554 | + |
|
1555 | + /** |
|
1556 | + * Get the manager of all the capabilities |
|
1557 | + * |
|
1558 | + * @return \OC\CapabilitiesManager |
|
1559 | + */ |
|
1560 | + public function getCapabilitiesManager() { |
|
1561 | + return $this->query('CapabilitiesManager'); |
|
1562 | + } |
|
1563 | + |
|
1564 | + /** |
|
1565 | + * Get the EventDispatcher |
|
1566 | + * |
|
1567 | + * @return EventDispatcherInterface |
|
1568 | + * @since 8.2.0 |
|
1569 | + */ |
|
1570 | + public function getEventDispatcher() { |
|
1571 | + return $this->query('EventDispatcher'); |
|
1572 | + } |
|
1573 | + |
|
1574 | + /** |
|
1575 | + * Get the Notification Manager |
|
1576 | + * |
|
1577 | + * @return \OCP\Notification\IManager |
|
1578 | + * @since 8.2.0 |
|
1579 | + */ |
|
1580 | + public function getNotificationManager() { |
|
1581 | + return $this->query('NotificationManager'); |
|
1582 | + } |
|
1583 | + |
|
1584 | + /** |
|
1585 | + * @return \OCP\Comments\ICommentsManager |
|
1586 | + */ |
|
1587 | + public function getCommentsManager() { |
|
1588 | + return $this->query('CommentsManager'); |
|
1589 | + } |
|
1590 | + |
|
1591 | + /** |
|
1592 | + * @return \OC_Defaults |
|
1593 | + */ |
|
1594 | + public function getThemingDefaults() { |
|
1595 | + return $this->query('ThemingDefaults'); |
|
1596 | + } |
|
1597 | + |
|
1598 | + /** |
|
1599 | + * @return \OC\IntegrityCheck\Checker |
|
1600 | + */ |
|
1601 | + public function getIntegrityCodeChecker() { |
|
1602 | + return $this->query('IntegrityCodeChecker'); |
|
1603 | + } |
|
1604 | + |
|
1605 | + /** |
|
1606 | + * @return \OC\Session\CryptoWrapper |
|
1607 | + */ |
|
1608 | + public function getSessionCryptoWrapper() { |
|
1609 | + return $this->query('CryptoWrapper'); |
|
1610 | + } |
|
1611 | + |
|
1612 | + /** |
|
1613 | + * @return CsrfTokenManager |
|
1614 | + */ |
|
1615 | + public function getCsrfTokenManager() { |
|
1616 | + return $this->query('CsrfTokenManager'); |
|
1617 | + } |
|
1618 | + |
|
1619 | + /** |
|
1620 | + * @return Throttler |
|
1621 | + */ |
|
1622 | + public function getBruteForceThrottler() { |
|
1623 | + return $this->query('Throttler'); |
|
1624 | + } |
|
1625 | + |
|
1626 | + /** |
|
1627 | + * @return IContentSecurityPolicyManager |
|
1628 | + */ |
|
1629 | + public function getContentSecurityPolicyManager() { |
|
1630 | + return $this->query('ContentSecurityPolicyManager'); |
|
1631 | + } |
|
1632 | + |
|
1633 | + /** |
|
1634 | + * @return ContentSecurityPolicyNonceManager |
|
1635 | + */ |
|
1636 | + public function getContentSecurityPolicyNonceManager() { |
|
1637 | + return $this->query('ContentSecurityPolicyNonceManager'); |
|
1638 | + } |
|
1639 | + |
|
1640 | + /** |
|
1641 | + * Not a public API as of 8.2, wait for 9.0 |
|
1642 | + * |
|
1643 | + * @return \OCA\Files_External\Service\BackendService |
|
1644 | + */ |
|
1645 | + public function getStoragesBackendService() { |
|
1646 | + return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1647 | + } |
|
1648 | + |
|
1649 | + /** |
|
1650 | + * Not a public API as of 8.2, wait for 9.0 |
|
1651 | + * |
|
1652 | + * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1653 | + */ |
|
1654 | + public function getGlobalStoragesService() { |
|
1655 | + return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1656 | + } |
|
1657 | + |
|
1658 | + /** |
|
1659 | + * Not a public API as of 8.2, wait for 9.0 |
|
1660 | + * |
|
1661 | + * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1662 | + */ |
|
1663 | + public function getUserGlobalStoragesService() { |
|
1664 | + return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1665 | + } |
|
1666 | + |
|
1667 | + /** |
|
1668 | + * Not a public API as of 8.2, wait for 9.0 |
|
1669 | + * |
|
1670 | + * @return \OCA\Files_External\Service\UserStoragesService |
|
1671 | + */ |
|
1672 | + public function getUserStoragesService() { |
|
1673 | + return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1674 | + } |
|
1675 | + |
|
1676 | + /** |
|
1677 | + * @return \OCP\Share\IManager |
|
1678 | + */ |
|
1679 | + public function getShareManager() { |
|
1680 | + return $this->query('ShareManager'); |
|
1681 | + } |
|
1682 | + |
|
1683 | + /** |
|
1684 | + * Returns the LDAP Provider |
|
1685 | + * |
|
1686 | + * @return \OCP\LDAP\ILDAPProvider |
|
1687 | + */ |
|
1688 | + public function getLDAPProvider() { |
|
1689 | + return $this->query('LDAPProvider'); |
|
1690 | + } |
|
1691 | + |
|
1692 | + /** |
|
1693 | + * @return \OCP\Settings\IManager |
|
1694 | + */ |
|
1695 | + public function getSettingsManager() { |
|
1696 | + return $this->query('SettingsManager'); |
|
1697 | + } |
|
1698 | + |
|
1699 | + /** |
|
1700 | + * @return \OCP\Files\IAppData |
|
1701 | + */ |
|
1702 | + public function getAppDataDir($app) { |
|
1703 | + /** @var \OC\Files\AppData\Factory $factory */ |
|
1704 | + $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
1705 | + return $factory->get($app); |
|
1706 | + } |
|
1707 | + |
|
1708 | + /** |
|
1709 | + * @return \OCP\Lockdown\ILockdownManager |
|
1710 | + */ |
|
1711 | + public function getLockdownManager() { |
|
1712 | + return $this->query('LockdownManager'); |
|
1713 | + } |
|
1714 | + |
|
1715 | + /** |
|
1716 | + * @return \OCP\Federation\ICloudIdManager |
|
1717 | + */ |
|
1718 | + public function getCloudIdManager() { |
|
1719 | + return $this->query(ICloudIdManager::class); |
|
1720 | + } |
|
1721 | 1721 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
131 | 131 | $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
132 | 132 | |
133 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
133 | + $this->registerService(\OCP\IPreview::class, function(Server $c) { |
|
134 | 134 | return new PreviewManager( |
135 | 135 | $c->getConfig(), |
136 | 136 | $c->getRootFolder(), |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | }); |
142 | 142 | $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
143 | 143 | |
144 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
144 | + $this->registerService(\OC\Preview\Watcher::class, function(Server $c) { |
|
145 | 145 | return new \OC\Preview\Watcher( |
146 | 146 | $c->getAppDataDir('preview') |
147 | 147 | ); |
148 | 148 | }); |
149 | 149 | |
150 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
150 | + $this->registerService('EncryptionManager', function(Server $c) { |
|
151 | 151 | $view = new View(); |
152 | 152 | $util = new Encryption\Util( |
153 | 153 | $view, |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | ); |
166 | 166 | }); |
167 | 167 | |
168 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
168 | + $this->registerService('EncryptionFileHelper', function(Server $c) { |
|
169 | 169 | $util = new Encryption\Util( |
170 | 170 | new View(), |
171 | 171 | $c->getUserManager(), |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | return new Encryption\File($util); |
176 | 176 | }); |
177 | 177 | |
178 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
178 | + $this->registerService('EncryptionKeyStorage', function(Server $c) { |
|
179 | 179 | $view = new View(); |
180 | 180 | $util = new Encryption\Util( |
181 | 181 | $view, |
@@ -186,32 +186,32 @@ discard block |
||
186 | 186 | |
187 | 187 | return new Encryption\Keys\Storage($view, $util); |
188 | 188 | }); |
189 | - $this->registerService('TagMapper', function (Server $c) { |
|
189 | + $this->registerService('TagMapper', function(Server $c) { |
|
190 | 190 | return new TagMapper($c->getDatabaseConnection()); |
191 | 191 | }); |
192 | 192 | |
193 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
193 | + $this->registerService(\OCP\ITagManager::class, function(Server $c) { |
|
194 | 194 | $tagMapper = $c->query('TagMapper'); |
195 | 195 | return new TagManager($tagMapper, $c->getUserSession()); |
196 | 196 | }); |
197 | 197 | $this->registerAlias('TagManager', \OCP\ITagManager::class); |
198 | 198 | |
199 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
199 | + $this->registerService('SystemTagManagerFactory', function(Server $c) { |
|
200 | 200 | $config = $c->getConfig(); |
201 | 201 | $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
202 | 202 | /** @var \OC\SystemTag\ManagerFactory $factory */ |
203 | 203 | $factory = new $factoryClass($this); |
204 | 204 | return $factory; |
205 | 205 | }); |
206 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
206 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function(Server $c) { |
|
207 | 207 | return $c->query('SystemTagManagerFactory')->getManager(); |
208 | 208 | }); |
209 | 209 | $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
210 | 210 | |
211 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
211 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function(Server $c) { |
|
212 | 212 | return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
213 | 213 | }); |
214 | - $this->registerService('RootFolder', function (Server $c) { |
|
214 | + $this->registerService('RootFolder', function(Server $c) { |
|
215 | 215 | $manager = \OC\Files\Filesystem::getMountManager(null); |
216 | 216 | $view = new View(); |
217 | 217 | $root = new Root( |
@@ -239,30 +239,30 @@ discard block |
||
239 | 239 | }); |
240 | 240 | $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
241 | 241 | |
242 | - $this->registerService(\OCP\IUserManager::class, function (Server $c) { |
|
242 | + $this->registerService(\OCP\IUserManager::class, function(Server $c) { |
|
243 | 243 | $config = $c->getConfig(); |
244 | 244 | return new \OC\User\Manager($config); |
245 | 245 | }); |
246 | 246 | $this->registerAlias('UserManager', \OCP\IUserManager::class); |
247 | 247 | |
248 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
248 | + $this->registerService(\OCP\IGroupManager::class, function(Server $c) { |
|
249 | 249 | $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
250 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
250 | + $groupManager->listen('\OC\Group', 'preCreate', function($gid) { |
|
251 | 251 | \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
252 | 252 | }); |
253 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
253 | + $groupManager->listen('\OC\Group', 'postCreate', function(\OC\Group\Group $gid) { |
|
254 | 254 | \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
255 | 255 | }); |
256 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
256 | + $groupManager->listen('\OC\Group', 'preDelete', function(\OC\Group\Group $group) { |
|
257 | 257 | \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
258 | 258 | }); |
259 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
259 | + $groupManager->listen('\OC\Group', 'postDelete', function(\OC\Group\Group $group) { |
|
260 | 260 | \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
261 | 261 | }); |
262 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
262 | + $groupManager->listen('\OC\Group', 'preAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
263 | 263 | \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
264 | 264 | }); |
265 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
265 | + $groupManager->listen('\OC\Group', 'postAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
266 | 266 | \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
267 | 267 | //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
268 | 268 | \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
@@ -282,11 +282,11 @@ discard block |
||
282 | 282 | return new Store($session, $logger, $tokenProvider); |
283 | 283 | }); |
284 | 284 | $this->registerAlias(IStore::class, Store::class); |
285 | - $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
285 | + $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function(Server $c) { |
|
286 | 286 | $dbConnection = $c->getDatabaseConnection(); |
287 | 287 | return new Authentication\Token\DefaultTokenMapper($dbConnection); |
288 | 288 | }); |
289 | - $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
289 | + $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function(Server $c) { |
|
290 | 290 | $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
291 | 291 | $crypto = $c->getCrypto(); |
292 | 292 | $config = $c->getConfig(); |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | }); |
297 | 297 | $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
298 | 298 | |
299 | - $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
299 | + $this->registerService(\OCP\IUserSession::class, function(Server $c) { |
|
300 | 300 | $manager = $c->getUserManager(); |
301 | 301 | $session = new \OC\Session\Memory(''); |
302 | 302 | $timeFactory = new TimeFactory(); |
@@ -309,40 +309,40 @@ discard block |
||
309 | 309 | } |
310 | 310 | |
311 | 311 | $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom()); |
312 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
312 | + $userSession->listen('\OC\User', 'preCreateUser', function($uid, $password) { |
|
313 | 313 | \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
314 | 314 | }); |
315 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
315 | + $userSession->listen('\OC\User', 'postCreateUser', function($user, $password) { |
|
316 | 316 | /** @var $user \OC\User\User */ |
317 | 317 | \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
318 | 318 | }); |
319 | - $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
319 | + $userSession->listen('\OC\User', 'preDelete', function($user) { |
|
320 | 320 | /** @var $user \OC\User\User */ |
321 | 321 | \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
322 | 322 | }); |
323 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
323 | + $userSession->listen('\OC\User', 'postDelete', function($user) { |
|
324 | 324 | /** @var $user \OC\User\User */ |
325 | 325 | \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
326 | 326 | }); |
327 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
327 | + $userSession->listen('\OC\User', 'preSetPassword', function($user, $password, $recoveryPassword) { |
|
328 | 328 | /** @var $user \OC\User\User */ |
329 | 329 | \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
330 | 330 | }); |
331 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
331 | + $userSession->listen('\OC\User', 'postSetPassword', function($user, $password, $recoveryPassword) { |
|
332 | 332 | /** @var $user \OC\User\User */ |
333 | 333 | \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
334 | 334 | }); |
335 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
335 | + $userSession->listen('\OC\User', 'preLogin', function($uid, $password) { |
|
336 | 336 | \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
337 | 337 | }); |
338 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
338 | + $userSession->listen('\OC\User', 'postLogin', function($user, $password) { |
|
339 | 339 | /** @var $user \OC\User\User */ |
340 | 340 | \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
341 | 341 | }); |
342 | - $userSession->listen('\OC\User', 'logout', function () { |
|
342 | + $userSession->listen('\OC\User', 'logout', function() { |
|
343 | 343 | \OC_Hook::emit('OC_User', 'logout', array()); |
344 | 344 | }); |
345 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) { |
|
345 | + $userSession->listen('\OC\User', 'changeUser', function($user, $feature, $value) { |
|
346 | 346 | /** @var $user \OC\User\User */ |
347 | 347 | \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value)); |
348 | 348 | }); |
@@ -350,11 +350,11 @@ discard block |
||
350 | 350 | }); |
351 | 351 | $this->registerAlias('UserSession', \OCP\IUserSession::class); |
352 | 352 | |
353 | - $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
353 | + $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function(Server $c) { |
|
354 | 354 | return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
355 | 355 | }); |
356 | 356 | |
357 | - $this->registerService(\OCP\INavigationManager::class, function (Server $c) { |
|
357 | + $this->registerService(\OCP\INavigationManager::class, function(Server $c) { |
|
358 | 358 | return new \OC\NavigationManager($c->getAppManager(), |
359 | 359 | $c->getURLGenerator(), |
360 | 360 | $c->getL10NFactory(), |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | }); |
364 | 364 | $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
365 | 365 | |
366 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
366 | + $this->registerService(\OC\AllConfig::class, function(Server $c) { |
|
367 | 367 | return new \OC\AllConfig( |
368 | 368 | $c->getSystemConfig() |
369 | 369 | ); |
@@ -371,17 +371,17 @@ discard block |
||
371 | 371 | $this->registerAlias('AllConfig', \OC\AllConfig::class); |
372 | 372 | $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
373 | 373 | |
374 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
374 | + $this->registerService('SystemConfig', function($c) use ($config) { |
|
375 | 375 | return new \OC\SystemConfig($config); |
376 | 376 | }); |
377 | 377 | |
378 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
378 | + $this->registerService(\OC\AppConfig::class, function(Server $c) { |
|
379 | 379 | return new \OC\AppConfig($c->getDatabaseConnection()); |
380 | 380 | }); |
381 | 381 | $this->registerAlias('AppConfig', \OC\AppConfig::class); |
382 | 382 | $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
383 | 383 | |
384 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
384 | + $this->registerService(\OCP\L10N\IFactory::class, function(Server $c) { |
|
385 | 385 | return new \OC\L10N\Factory( |
386 | 386 | $c->getConfig(), |
387 | 387 | $c->getRequest(), |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | }); |
392 | 392 | $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
393 | 393 | |
394 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
394 | + $this->registerService(\OCP\IURLGenerator::class, function(Server $c) { |
|
395 | 395 | $config = $c->getConfig(); |
396 | 396 | $cacheFactory = $c->getMemCacheFactory(); |
397 | 397 | return new \OC\URLGenerator( |
@@ -401,10 +401,10 @@ discard block |
||
401 | 401 | }); |
402 | 402 | $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
403 | 403 | |
404 | - $this->registerService('AppHelper', function ($c) { |
|
404 | + $this->registerService('AppHelper', function($c) { |
|
405 | 405 | return new \OC\AppHelper(); |
406 | 406 | }); |
407 | - $this->registerService('AppFetcher', function ($c) { |
|
407 | + $this->registerService('AppFetcher', function($c) { |
|
408 | 408 | return new AppFetcher( |
409 | 409 | $this->getAppDataDir('appstore'), |
410 | 410 | $this->getHTTPClientService(), |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | $this->getConfig() |
413 | 413 | ); |
414 | 414 | }); |
415 | - $this->registerService('CategoryFetcher', function ($c) { |
|
415 | + $this->registerService('CategoryFetcher', function($c) { |
|
416 | 416 | return new CategoryFetcher( |
417 | 417 | $this->getAppDataDir('appstore'), |
418 | 418 | $this->getHTTPClientService(), |
@@ -421,21 +421,21 @@ discard block |
||
421 | 421 | ); |
422 | 422 | }); |
423 | 423 | |
424 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
424 | + $this->registerService(\OCP\ICache::class, function($c) { |
|
425 | 425 | return new Cache\File(); |
426 | 426 | }); |
427 | 427 | $this->registerAlias('UserCache', \OCP\ICache::class); |
428 | 428 | |
429 | - $this->registerService(Factory::class, function (Server $c) { |
|
429 | + $this->registerService(Factory::class, function(Server $c) { |
|
430 | 430 | $config = $c->getConfig(); |
431 | 431 | |
432 | 432 | if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
433 | 433 | $v = \OC_App::getAppVersions(); |
434 | - $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
434 | + $v['core'] = md5(file_get_contents(\OC::$SERVERROOT.'/version.php')); |
|
435 | 435 | $version = implode(',', $v); |
436 | 436 | $instanceId = \OC_Util::getInstanceId(); |
437 | 437 | $path = \OC::$SERVERROOT; |
438 | - $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
438 | + $prefix = md5($instanceId.'-'.$version.'-'.$path.'-'.\OC::$WEBROOT); |
|
439 | 439 | return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
440 | 440 | $config->getSystemValue('memcache.local', null), |
441 | 441 | $config->getSystemValue('memcache.distributed', null), |
@@ -452,12 +452,12 @@ discard block |
||
452 | 452 | $this->registerAlias('MemCacheFactory', Factory::class); |
453 | 453 | $this->registerAlias(ICacheFactory::class, Factory::class); |
454 | 454 | |
455 | - $this->registerService('RedisFactory', function (Server $c) { |
|
455 | + $this->registerService('RedisFactory', function(Server $c) { |
|
456 | 456 | $systemConfig = $c->getSystemConfig(); |
457 | 457 | return new RedisFactory($systemConfig); |
458 | 458 | }); |
459 | 459 | |
460 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
460 | + $this->registerService(\OCP\Activity\IManager::class, function(Server $c) { |
|
461 | 461 | return new \OC\Activity\Manager( |
462 | 462 | $c->getRequest(), |
463 | 463 | $c->getUserSession(), |
@@ -467,14 +467,14 @@ discard block |
||
467 | 467 | }); |
468 | 468 | $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
469 | 469 | |
470 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
470 | + $this->registerService(\OCP\Activity\IEventMerger::class, function(Server $c) { |
|
471 | 471 | return new \OC\Activity\EventMerger( |
472 | 472 | $c->getL10N('lib') |
473 | 473 | ); |
474 | 474 | }); |
475 | 475 | $this->registerAlias(IValidator::class, Validator::class); |
476 | 476 | |
477 | - $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
477 | + $this->registerService(\OCP\IAvatarManager::class, function(Server $c) { |
|
478 | 478 | return new AvatarManager( |
479 | 479 | $c->getUserManager(), |
480 | 480 | $c->getAppDataDir('avatar'), |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | }); |
486 | 486 | $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
487 | 487 | |
488 | - $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
488 | + $this->registerService(\OCP\ILogger::class, function(Server $c) { |
|
489 | 489 | $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
490 | 490 | $logger = Log::getLogClass($logType); |
491 | 491 | call_user_func(array($logger, 'init')); |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | }); |
495 | 495 | $this->registerAlias('Logger', \OCP\ILogger::class); |
496 | 496 | |
497 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
497 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function(Server $c) { |
|
498 | 498 | $config = $c->getConfig(); |
499 | 499 | return new \OC\BackgroundJob\JobList( |
500 | 500 | $c->getDatabaseConnection(), |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | }); |
505 | 505 | $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
506 | 506 | |
507 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
507 | + $this->registerService(\OCP\Route\IRouter::class, function(Server $c) { |
|
508 | 508 | $cacheFactory = $c->getMemCacheFactory(); |
509 | 509 | $logger = $c->getLogger(); |
510 | 510 | if ($cacheFactory->isAvailable()) { |
@@ -516,32 +516,32 @@ discard block |
||
516 | 516 | }); |
517 | 517 | $this->registerAlias('Router', \OCP\Route\IRouter::class); |
518 | 518 | |
519 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
519 | + $this->registerService(\OCP\ISearch::class, function($c) { |
|
520 | 520 | return new Search(); |
521 | 521 | }); |
522 | 522 | $this->registerAlias('Search', \OCP\ISearch::class); |
523 | 523 | |
524 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
524 | + $this->registerService(\OCP\Security\ISecureRandom::class, function($c) { |
|
525 | 525 | return new SecureRandom(); |
526 | 526 | }); |
527 | 527 | $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
528 | 528 | |
529 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
529 | + $this->registerService(\OCP\Security\ICrypto::class, function(Server $c) { |
|
530 | 530 | return new Crypto($c->getConfig(), $c->getSecureRandom()); |
531 | 531 | }); |
532 | 532 | $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
533 | 533 | |
534 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
534 | + $this->registerService(\OCP\Security\IHasher::class, function(Server $c) { |
|
535 | 535 | return new Hasher($c->getConfig()); |
536 | 536 | }); |
537 | 537 | $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
538 | 538 | |
539 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
539 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function(Server $c) { |
|
540 | 540 | return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
541 | 541 | }); |
542 | 542 | $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
543 | 543 | |
544 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
544 | + $this->registerService(IDBConnection::class, function(Server $c) { |
|
545 | 545 | $systemConfig = $c->getSystemConfig(); |
546 | 546 | $factory = new \OC\DB\ConnectionFactory($systemConfig); |
547 | 547 | $type = $systemConfig->getValue('dbtype', 'sqlite'); |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | }); |
556 | 556 | $this->registerAlias('DatabaseConnection', IDBConnection::class); |
557 | 557 | |
558 | - $this->registerService('HTTPHelper', function (Server $c) { |
|
558 | + $this->registerService('HTTPHelper', function(Server $c) { |
|
559 | 559 | $config = $c->getConfig(); |
560 | 560 | return new HTTPHelper( |
561 | 561 | $config, |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | ); |
564 | 564 | }); |
565 | 565 | |
566 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
566 | + $this->registerService(\OCP\Http\Client\IClientService::class, function(Server $c) { |
|
567 | 567 | $user = \OC_User::getUser(); |
568 | 568 | $uid = $user ? $user : null; |
569 | 569 | return new ClientService( |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | }); |
574 | 574 | $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
575 | 575 | |
576 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
576 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function(Server $c) { |
|
577 | 577 | if ($c->getSystemConfig()->getValue('debug', false)) { |
578 | 578 | return new EventLogger(); |
579 | 579 | } else { |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | }); |
583 | 583 | $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
584 | 584 | |
585 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
585 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function(Server $c) { |
|
586 | 586 | if ($c->getSystemConfig()->getValue('debug', false)) { |
587 | 587 | return new QueryLogger(); |
588 | 588 | } else { |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | }); |
592 | 592 | $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
593 | 593 | |
594 | - $this->registerService(TempManager::class, function (Server $c) { |
|
594 | + $this->registerService(TempManager::class, function(Server $c) { |
|
595 | 595 | return new TempManager( |
596 | 596 | $c->getLogger(), |
597 | 597 | $c->getConfig() |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | $this->registerAlias('TempManager', TempManager::class); |
601 | 601 | $this->registerAlias(ITempManager::class, TempManager::class); |
602 | 602 | |
603 | - $this->registerService(AppManager::class, function (Server $c) { |
|
603 | + $this->registerService(AppManager::class, function(Server $c) { |
|
604 | 604 | return new \OC\App\AppManager( |
605 | 605 | $c->getUserSession(), |
606 | 606 | $c->getAppConfig(), |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | $this->registerAlias('AppManager', AppManager::class); |
613 | 613 | $this->registerAlias(IAppManager::class, AppManager::class); |
614 | 614 | |
615 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
615 | + $this->registerService(\OCP\IDateTimeZone::class, function(Server $c) { |
|
616 | 616 | return new DateTimeZone( |
617 | 617 | $c->getConfig(), |
618 | 618 | $c->getSession() |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | }); |
621 | 621 | $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
622 | 622 | |
623 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
623 | + $this->registerService(\OCP\IDateTimeFormatter::class, function(Server $c) { |
|
624 | 624 | $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
625 | 625 | |
626 | 626 | return new DateTimeFormatter( |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | }); |
631 | 631 | $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
632 | 632 | |
633 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
633 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function(Server $c) { |
|
634 | 634 | $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
635 | 635 | $listener = new UserMountCacheListener($mountCache); |
636 | 636 | $listener->listen($c->getUserManager()); |
@@ -638,10 +638,10 @@ discard block |
||
638 | 638 | }); |
639 | 639 | $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
640 | 640 | |
641 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
641 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function(Server $c) { |
|
642 | 642 | $loader = \OC\Files\Filesystem::getLoader(); |
643 | 643 | $mountCache = $c->query('UserMountCache'); |
644 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
644 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
645 | 645 | |
646 | 646 | // builtin providers |
647 | 647 | |
@@ -654,14 +654,14 @@ discard block |
||
654 | 654 | }); |
655 | 655 | $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
656 | 656 | |
657 | - $this->registerService('IniWrapper', function ($c) { |
|
657 | + $this->registerService('IniWrapper', function($c) { |
|
658 | 658 | return new IniGetWrapper(); |
659 | 659 | }); |
660 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
660 | + $this->registerService('AsyncCommandBus', function(Server $c) { |
|
661 | 661 | $jobList = $c->getJobList(); |
662 | 662 | return new AsyncBus($jobList); |
663 | 663 | }); |
664 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
664 | + $this->registerService('TrustedDomainHelper', function($c) { |
|
665 | 665 | return new TrustedDomainHelper($this->getConfig()); |
666 | 666 | }); |
667 | 667 | $this->registerService('Throttler', function(Server $c) { |
@@ -672,10 +672,10 @@ discard block |
||
672 | 672 | $c->getConfig() |
673 | 673 | ); |
674 | 674 | }); |
675 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
675 | + $this->registerService('IntegrityCodeChecker', function(Server $c) { |
|
676 | 676 | // IConfig and IAppManager requires a working database. This code |
677 | 677 | // might however be called when ownCloud is not yet setup. |
678 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
678 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
679 | 679 | $config = $c->getConfig(); |
680 | 680 | $appManager = $c->getAppManager(); |
681 | 681 | } else { |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | $c->getTempManager() |
694 | 694 | ); |
695 | 695 | }); |
696 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
696 | + $this->registerService(\OCP\IRequest::class, function($c) { |
|
697 | 697 | if (isset($this['urlParams'])) { |
698 | 698 | $urlParams = $this['urlParams']; |
699 | 699 | } else { |
@@ -729,7 +729,7 @@ discard block |
||
729 | 729 | }); |
730 | 730 | $this->registerAlias('Request', \OCP\IRequest::class); |
731 | 731 | |
732 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
732 | + $this->registerService(\OCP\Mail\IMailer::class, function(Server $c) { |
|
733 | 733 | return new Mailer( |
734 | 734 | $c->getConfig(), |
735 | 735 | $c->getLogger(), |
@@ -741,14 +741,14 @@ discard block |
||
741 | 741 | $this->registerService('LDAPProvider', function(Server $c) { |
742 | 742 | $config = $c->getConfig(); |
743 | 743 | $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
744 | - if(is_null($factoryClass)) { |
|
744 | + if (is_null($factoryClass)) { |
|
745 | 745 | throw new \Exception('ldapProviderFactory not set'); |
746 | 746 | } |
747 | 747 | /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
748 | 748 | $factory = new $factoryClass($this); |
749 | 749 | return $factory->getLDAPProvider(); |
750 | 750 | }); |
751 | - $this->registerService('LockingProvider', function (Server $c) { |
|
751 | + $this->registerService('LockingProvider', function(Server $c) { |
|
752 | 752 | $ini = $c->getIniWrapper(); |
753 | 753 | $config = $c->getConfig(); |
754 | 754 | $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
@@ -764,37 +764,37 @@ discard block |
||
764 | 764 | return new NoopLockingProvider(); |
765 | 765 | }); |
766 | 766 | |
767 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
767 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function() { |
|
768 | 768 | return new \OC\Files\Mount\Manager(); |
769 | 769 | }); |
770 | 770 | $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
771 | 771 | |
772 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
772 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function(Server $c) { |
|
773 | 773 | return new \OC\Files\Type\Detection( |
774 | 774 | $c->getURLGenerator(), |
775 | 775 | \OC::$configDir, |
776 | - \OC::$SERVERROOT . '/resources/config/' |
|
776 | + \OC::$SERVERROOT.'/resources/config/' |
|
777 | 777 | ); |
778 | 778 | }); |
779 | 779 | $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
780 | 780 | |
781 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
781 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function(Server $c) { |
|
782 | 782 | return new \OC\Files\Type\Loader( |
783 | 783 | $c->getDatabaseConnection() |
784 | 784 | ); |
785 | 785 | }); |
786 | 786 | $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
787 | 787 | |
788 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
788 | + $this->registerService(\OCP\Notification\IManager::class, function(Server $c) { |
|
789 | 789 | return new Manager( |
790 | 790 | $c->query(IValidator::class) |
791 | 791 | ); |
792 | 792 | }); |
793 | 793 | $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
794 | 794 | |
795 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
795 | + $this->registerService(\OC\CapabilitiesManager::class, function(Server $c) { |
|
796 | 796 | $manager = new \OC\CapabilitiesManager($c->getLogger()); |
797 | - $manager->registerCapability(function () use ($c) { |
|
797 | + $manager->registerCapability(function() use ($c) { |
|
798 | 798 | return new \OC\OCS\CoreCapabilities($c->getConfig()); |
799 | 799 | }); |
800 | 800 | return $manager; |
@@ -836,13 +836,13 @@ discard block |
||
836 | 836 | } |
837 | 837 | return new \OC_Defaults(); |
838 | 838 | }); |
839 | - $this->registerService(EventDispatcher::class, function () { |
|
839 | + $this->registerService(EventDispatcher::class, function() { |
|
840 | 840 | return new EventDispatcher(); |
841 | 841 | }); |
842 | 842 | $this->registerAlias('EventDispatcher', EventDispatcher::class); |
843 | 843 | $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
844 | 844 | |
845 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
845 | + $this->registerService('CryptoWrapper', function(Server $c) { |
|
846 | 846 | // FIXME: Instantiiated here due to cyclic dependency |
847 | 847 | $request = new Request( |
848 | 848 | [ |
@@ -867,7 +867,7 @@ discard block |
||
867 | 867 | $request |
868 | 868 | ); |
869 | 869 | }); |
870 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
870 | + $this->registerService('CsrfTokenManager', function(Server $c) { |
|
871 | 871 | $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
872 | 872 | |
873 | 873 | return new CsrfTokenManager( |
@@ -875,10 +875,10 @@ discard block |
||
875 | 875 | $c->query(SessionStorage::class) |
876 | 876 | ); |
877 | 877 | }); |
878 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
878 | + $this->registerService(SessionStorage::class, function(Server $c) { |
|
879 | 879 | return new SessionStorage($c->getSession()); |
880 | 880 | }); |
881 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
881 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function(Server $c) { |
|
882 | 882 | return new ContentSecurityPolicyManager(); |
883 | 883 | }); |
884 | 884 | $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
@@ -929,27 +929,27 @@ discard block |
||
929 | 929 | ); |
930 | 930 | return $manager; |
931 | 931 | }); |
932 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
932 | + $this->registerService(\OC\Files\AppData\Factory::class, function(Server $c) { |
|
933 | 933 | return new \OC\Files\AppData\Factory( |
934 | 934 | $c->getRootFolder(), |
935 | 935 | $c->getSystemConfig() |
936 | 936 | ); |
937 | 937 | }); |
938 | 938 | |
939 | - $this->registerService('LockdownManager', function (Server $c) { |
|
939 | + $this->registerService('LockdownManager', function(Server $c) { |
|
940 | 940 | return new LockdownManager(); |
941 | 941 | }); |
942 | 942 | |
943 | - $this->registerService('OCSDiscoveryService', function (Server $c) { |
|
943 | + $this->registerService('OCSDiscoveryService', function(Server $c) { |
|
944 | 944 | return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
945 | 945 | }); |
946 | 946 | |
947 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
947 | + $this->registerService(ICloudIdManager::class, function(Server $c) { |
|
948 | 948 | return new CloudIdManager(); |
949 | 949 | }); |
950 | 950 | |
951 | 951 | /* To trick DI since we don't extend the DIContainer here */ |
952 | - $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
952 | + $this->registerService(CleanPreviewsBackgroundJob::class, function(Server $c) { |
|
953 | 953 | return new CleanPreviewsBackgroundJob( |
954 | 954 | $c->getRootFolder(), |
955 | 955 | $c->getLogger(), |
@@ -1111,7 +1111,7 @@ discard block |
||
1111 | 1111 | * @deprecated since 9.2.0 use IAppData |
1112 | 1112 | */ |
1113 | 1113 | public function getAppFolder() { |
1114 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
1114 | + $dir = '/'.\OC_App::getCurrentApp(); |
|
1115 | 1115 | $root = $this->getRootFolder(); |
1116 | 1116 | if (!$root->nodeExists($dir)) { |
1117 | 1117 | $folder = $root->newFolder($dir); |