@@ -28,10 +28,10 @@ |
||
28 | 28 | */ |
29 | 29 | interface ISubscription { |
30 | 30 | |
31 | - /** |
|
32 | - * Indicates if a valid subscription is available |
|
33 | - * |
|
34 | - * @since 17.0.0 |
|
35 | - */ |
|
36 | - public function hasValidSubscription(): bool; |
|
31 | + /** |
|
32 | + * Indicates if a valid subscription is available |
|
33 | + * |
|
34 | + * @since 17.0.0 |
|
35 | + */ |
|
36 | + public function hasValidSubscription(): bool; |
|
37 | 37 | } |
@@ -30,28 +30,28 @@ |
||
30 | 30 | */ |
31 | 31 | interface IRegistry { |
32 | 32 | |
33 | - /** |
|
34 | - * Register a subscription instance. In case it is called multiple times the |
|
35 | - * first one is used. |
|
36 | - * |
|
37 | - * @param ISubscription $subscription |
|
38 | - * @throws AlreadyRegisteredException |
|
39 | - * |
|
40 | - * @since 17.0.0 |
|
41 | - */ |
|
42 | - public function register(ISubscription $subscription): void; |
|
33 | + /** |
|
34 | + * Register a subscription instance. In case it is called multiple times the |
|
35 | + * first one is used. |
|
36 | + * |
|
37 | + * @param ISubscription $subscription |
|
38 | + * @throws AlreadyRegisteredException |
|
39 | + * |
|
40 | + * @since 17.0.0 |
|
41 | + */ |
|
42 | + public function register(ISubscription $subscription): void; |
|
43 | 43 | |
44 | - /** |
|
45 | - * Fetches the list of app IDs that are supported by the subscription |
|
46 | - * |
|
47 | - * @since 17.0.0 |
|
48 | - */ |
|
49 | - public function delegateGetSupportedApps(): array; |
|
44 | + /** |
|
45 | + * Fetches the list of app IDs that are supported by the subscription |
|
46 | + * |
|
47 | + * @since 17.0.0 |
|
48 | + */ |
|
49 | + public function delegateGetSupportedApps(): array; |
|
50 | 50 | |
51 | - /** |
|
52 | - * Indicates if a valid subscription is available |
|
53 | - * |
|
54 | - * @since 17.0.0 |
|
55 | - */ |
|
56 | - public function delegateHasValidSubscription(): bool; |
|
51 | + /** |
|
52 | + * Indicates if a valid subscription is available |
|
53 | + * |
|
54 | + * @since 17.0.0 |
|
55 | + */ |
|
56 | + public function delegateHasValidSubscription(): bool; |
|
57 | 57 | } |
@@ -28,10 +28,10 @@ |
||
28 | 28 | */ |
29 | 29 | interface ISupportedApps extends ISubscription { |
30 | 30 | |
31 | - /** |
|
32 | - * Fetches the list of app IDs that are supported by the subscription |
|
33 | - * |
|
34 | - * @since 17.0.0 |
|
35 | - */ |
|
36 | - public function getSupportedApps(): array; |
|
31 | + /** |
|
32 | + * Fetches the list of app IDs that are supported by the subscription |
|
33 | + * |
|
34 | + * @since 17.0.0 |
|
35 | + */ |
|
36 | + public function getSupportedApps(): array; |
|
37 | 37 | } |
@@ -30,46 +30,46 @@ |
||
30 | 30 | |
31 | 31 | class Registry implements IRegistry { |
32 | 32 | |
33 | - /** @var ISubscription */ |
|
34 | - private $subscription = null; |
|
33 | + /** @var ISubscription */ |
|
34 | + private $subscription = null; |
|
35 | 35 | |
36 | - /** |
|
37 | - * Register a subscription instance. In case it is called multiple times the |
|
38 | - * first one is used. |
|
39 | - * |
|
40 | - * @param ISubscription $subscription |
|
41 | - * @throws AlreadyRegisteredException |
|
42 | - * |
|
43 | - * @since 17.0.0 |
|
44 | - */ |
|
45 | - public function register(ISubscription $subscription): void { |
|
46 | - if ($this->subscription !== null) { |
|
47 | - throw new AlreadyRegisteredException(); |
|
48 | - } |
|
49 | - $this->subscription = $subscription; |
|
50 | - } |
|
36 | + /** |
|
37 | + * Register a subscription instance. In case it is called multiple times the |
|
38 | + * first one is used. |
|
39 | + * |
|
40 | + * @param ISubscription $subscription |
|
41 | + * @throws AlreadyRegisteredException |
|
42 | + * |
|
43 | + * @since 17.0.0 |
|
44 | + */ |
|
45 | + public function register(ISubscription $subscription): void { |
|
46 | + if ($this->subscription !== null) { |
|
47 | + throw new AlreadyRegisteredException(); |
|
48 | + } |
|
49 | + $this->subscription = $subscription; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Fetches the list of app IDs that are supported by the subscription |
|
54 | - * |
|
55 | - * @since 17.0.0 |
|
56 | - */ |
|
57 | - public function delegateGetSupportedApps(): array { |
|
58 | - if ($this->subscription instanceof ISupportedApps) { |
|
59 | - return $this->subscription->getSupportedApps(); |
|
60 | - } |
|
61 | - return []; |
|
62 | - } |
|
52 | + /** |
|
53 | + * Fetches the list of app IDs that are supported by the subscription |
|
54 | + * |
|
55 | + * @since 17.0.0 |
|
56 | + */ |
|
57 | + public function delegateGetSupportedApps(): array { |
|
58 | + if ($this->subscription instanceof ISupportedApps) { |
|
59 | + return $this->subscription->getSupportedApps(); |
|
60 | + } |
|
61 | + return []; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Indicates if a valid subscription is available |
|
66 | - * |
|
67 | - * @since 17.0.0 |
|
68 | - */ |
|
69 | - public function delegateHasValidSubscription(): bool { |
|
70 | - if ($this->subscription instanceof ISubscription) { |
|
71 | - return $this->subscription->hasValidSubscription(); |
|
72 | - } |
|
73 | - return false; |
|
74 | - } |
|
64 | + /** |
|
65 | + * Indicates if a valid subscription is available |
|
66 | + * |
|
67 | + * @since 17.0.0 |
|
68 | + */ |
|
69 | + public function delegateHasValidSubscription(): bool { |
|
70 | + if ($this->subscription instanceof ISubscription) { |
|
71 | + return $this->subscription->hasValidSubscription(); |
|
72 | + } |
|
73 | + return false; |
|
74 | + } |
|
75 | 75 | } |
@@ -170,1898 +170,1898 @@ |
||
170 | 170 | * TODO: hookup all manager classes |
171 | 171 | */ |
172 | 172 | class Server extends ServerContainer implements IServerContainer { |
173 | - /** @var string */ |
|
174 | - private $webRoot; |
|
175 | - |
|
176 | - /** |
|
177 | - * @param string $webRoot |
|
178 | - * @param \OC\Config $config |
|
179 | - */ |
|
180 | - public function __construct($webRoot, \OC\Config $config) { |
|
181 | - parent::__construct(); |
|
182 | - $this->webRoot = $webRoot; |
|
183 | - |
|
184 | - // To find out if we are running from CLI or not |
|
185 | - $this->registerParameter('isCLI', \OC::$CLI); |
|
186 | - |
|
187 | - $this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) { |
|
188 | - return $c; |
|
189 | - }); |
|
190 | - |
|
191 | - $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class); |
|
192 | - $this->registerAlias('CalendarManager', \OC\Calendar\Manager::class); |
|
193 | - |
|
194 | - $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class); |
|
195 | - $this->registerAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class); |
|
196 | - |
|
197 | - $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class); |
|
198 | - $this->registerAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class); |
|
199 | - |
|
200 | - $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
201 | - $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
202 | - |
|
203 | - $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
204 | - |
|
205 | - |
|
206 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
207 | - return new PreviewManager( |
|
208 | - $c->getConfig(), |
|
209 | - $c->getRootFolder(), |
|
210 | - $c->getAppDataDir('preview'), |
|
211 | - $c->getEventDispatcher(), |
|
212 | - $c->getSession()->get('user_id') |
|
213 | - ); |
|
214 | - }); |
|
215 | - $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
216 | - |
|
217 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
218 | - return new \OC\Preview\Watcher( |
|
219 | - $c->getAppDataDir('preview') |
|
220 | - ); |
|
221 | - }); |
|
222 | - |
|
223 | - $this->registerService(\OCP\Encryption\IManager::class, function (Server $c) { |
|
224 | - $view = new View(); |
|
225 | - $util = new Encryption\Util( |
|
226 | - $view, |
|
227 | - $c->getUserManager(), |
|
228 | - $c->getGroupManager(), |
|
229 | - $c->getConfig() |
|
230 | - ); |
|
231 | - return new Encryption\Manager( |
|
232 | - $c->getConfig(), |
|
233 | - $c->getLogger(), |
|
234 | - $c->getL10N('core'), |
|
235 | - new View(), |
|
236 | - $util, |
|
237 | - new ArrayCache() |
|
238 | - ); |
|
239 | - }); |
|
240 | - $this->registerAlias('EncryptionManager', \OCP\Encryption\IManager::class); |
|
241 | - |
|
242 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
243 | - $util = new Encryption\Util( |
|
244 | - new View(), |
|
245 | - $c->getUserManager(), |
|
246 | - $c->getGroupManager(), |
|
247 | - $c->getConfig() |
|
248 | - ); |
|
249 | - return new Encryption\File( |
|
250 | - $util, |
|
251 | - $c->getRootFolder(), |
|
252 | - $c->getShareManager() |
|
253 | - ); |
|
254 | - }); |
|
255 | - |
|
256 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
257 | - $view = new View(); |
|
258 | - $util = new Encryption\Util( |
|
259 | - $view, |
|
260 | - $c->getUserManager(), |
|
261 | - $c->getGroupManager(), |
|
262 | - $c->getConfig() |
|
263 | - ); |
|
264 | - |
|
265 | - return new Encryption\Keys\Storage($view, $util); |
|
266 | - }); |
|
267 | - $this->registerService('TagMapper', function (Server $c) { |
|
268 | - return new TagMapper($c->getDatabaseConnection()); |
|
269 | - }); |
|
270 | - |
|
271 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
272 | - $tagMapper = $c->query('TagMapper'); |
|
273 | - return new TagManager($tagMapper, $c->getUserSession()); |
|
274 | - }); |
|
275 | - $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
276 | - |
|
277 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
278 | - $config = $c->getConfig(); |
|
279 | - $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class); |
|
280 | - return new $factoryClass($this); |
|
281 | - }); |
|
282 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
283 | - return $c->query('SystemTagManagerFactory')->getManager(); |
|
284 | - }); |
|
285 | - $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
286 | - |
|
287 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
288 | - return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
289 | - }); |
|
290 | - $this->registerService('RootFolder', function (Server $c) { |
|
291 | - $manager = \OC\Files\Filesystem::getMountManager(null); |
|
292 | - $view = new View(); |
|
293 | - $root = new Root( |
|
294 | - $manager, |
|
295 | - $view, |
|
296 | - null, |
|
297 | - $c->getUserMountCache(), |
|
298 | - $this->getLogger(), |
|
299 | - $this->getUserManager() |
|
300 | - ); |
|
301 | - $connector = new HookConnector($root, $view); |
|
302 | - $connector->viewToNode(); |
|
303 | - |
|
304 | - $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
305 | - $previewConnector->connectWatcher(); |
|
306 | - |
|
307 | - return $root; |
|
308 | - }); |
|
309 | - $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
310 | - |
|
311 | - $this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) { |
|
312 | - return new LazyRoot(function () use ($c) { |
|
313 | - return $c->query('RootFolder'); |
|
314 | - }); |
|
315 | - }); |
|
316 | - $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
317 | - |
|
318 | - $this->registerService(\OC\User\Manager::class, function (Server $c) { |
|
319 | - return new \OC\User\Manager($c->getConfig(), $c->getEventDispatcher()); |
|
320 | - }); |
|
321 | - $this->registerAlias('UserManager', \OC\User\Manager::class); |
|
322 | - $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); |
|
323 | - |
|
324 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
325 | - $groupManager = new \OC\Group\Manager($this->getUserManager(), $c->getEventDispatcher(), $this->getLogger()); |
|
326 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
327 | - \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
328 | - }); |
|
329 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
330 | - \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
331 | - }); |
|
332 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
333 | - \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
334 | - }); |
|
335 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
336 | - \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
337 | - }); |
|
338 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
339 | - \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
340 | - }); |
|
341 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
342 | - \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
343 | - //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
344 | - \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
345 | - }); |
|
346 | - return $groupManager; |
|
347 | - }); |
|
348 | - $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
349 | - |
|
350 | - $this->registerService(Store::class, function (Server $c) { |
|
351 | - $session = $c->getSession(); |
|
352 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
353 | - $tokenProvider = $c->query(IProvider::class); |
|
354 | - } else { |
|
355 | - $tokenProvider = null; |
|
356 | - } |
|
357 | - $logger = $c->getLogger(); |
|
358 | - return new Store($session, $logger, $tokenProvider); |
|
359 | - }); |
|
360 | - $this->registerAlias(IStore::class, Store::class); |
|
361 | - $this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) { |
|
362 | - $dbConnection = $c->getDatabaseConnection(); |
|
363 | - return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
364 | - }); |
|
365 | - $this->registerAlias(IProvider::class, Authentication\Token\Manager::class); |
|
366 | - |
|
367 | - $this->registerService(\OC\User\Session::class, function (Server $c) { |
|
368 | - $manager = $c->getUserManager(); |
|
369 | - $session = new \OC\Session\Memory(''); |
|
370 | - $timeFactory = new TimeFactory(); |
|
371 | - // Token providers might require a working database. This code |
|
372 | - // might however be called when ownCloud is not yet setup. |
|
373 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
374 | - $defaultTokenProvider = $c->query(IProvider::class); |
|
375 | - } else { |
|
376 | - $defaultTokenProvider = null; |
|
377 | - } |
|
378 | - |
|
379 | - $dispatcher = $c->getEventDispatcher(); |
|
380 | - |
|
381 | - $userSession = new \OC\User\Session( |
|
382 | - $manager, |
|
383 | - $session, |
|
384 | - $timeFactory, |
|
385 | - $defaultTokenProvider, |
|
386 | - $c->getConfig(), |
|
387 | - $c->getSecureRandom(), |
|
388 | - $c->getLockdownManager(), |
|
389 | - $c->getLogger() |
|
390 | - ); |
|
391 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
392 | - \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
393 | - }); |
|
394 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
395 | - /** @var $user \OC\User\User */ |
|
396 | - \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
397 | - }); |
|
398 | - $userSession->listen('\OC\User', 'preDelete', function ($user) use ($dispatcher) { |
|
399 | - /** @var $user \OC\User\User */ |
|
400 | - \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
401 | - $dispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); |
|
402 | - }); |
|
403 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
404 | - /** @var $user \OC\User\User */ |
|
405 | - \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
406 | - }); |
|
407 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
408 | - /** @var $user \OC\User\User */ |
|
409 | - \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
410 | - }); |
|
411 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
412 | - /** @var $user \OC\User\User */ |
|
413 | - \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
414 | - }); |
|
415 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
416 | - \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
417 | - }); |
|
418 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password, $isTokenLogin) { |
|
419 | - /** @var $user \OC\User\User */ |
|
420 | - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'isTokenLogin' => $isTokenLogin)); |
|
421 | - }); |
|
422 | - $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { |
|
423 | - /** @var $user \OC\User\User */ |
|
424 | - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
425 | - }); |
|
426 | - $userSession->listen('\OC\User', 'logout', function () { |
|
427 | - \OC_Hook::emit('OC_User', 'logout', array()); |
|
428 | - }); |
|
429 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) { |
|
430 | - /** @var $user \OC\User\User */ |
|
431 | - \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
|
432 | - }); |
|
433 | - return $userSession; |
|
434 | - }); |
|
435 | - $this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class); |
|
436 | - $this->registerAlias('UserSession', \OC\User\Session::class); |
|
437 | - |
|
438 | - $this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class); |
|
439 | - |
|
440 | - $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
|
441 | - $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
442 | - |
|
443 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
444 | - return new \OC\AllConfig( |
|
445 | - $c->getSystemConfig() |
|
446 | - ); |
|
447 | - }); |
|
448 | - $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
449 | - $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
450 | - |
|
451 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
452 | - return new \OC\SystemConfig($config); |
|
453 | - }); |
|
454 | - |
|
455 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
456 | - return new \OC\AppConfig($c->getDatabaseConnection()); |
|
457 | - }); |
|
458 | - $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
459 | - $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
460 | - |
|
461 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
462 | - return new \OC\L10N\Factory( |
|
463 | - $c->getConfig(), |
|
464 | - $c->getRequest(), |
|
465 | - $c->getUserSession(), |
|
466 | - \OC::$SERVERROOT |
|
467 | - ); |
|
468 | - }); |
|
469 | - $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
470 | - |
|
471 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
472 | - $config = $c->getConfig(); |
|
473 | - $cacheFactory = $c->getMemCacheFactory(); |
|
474 | - $request = $c->getRequest(); |
|
475 | - return new \OC\URLGenerator( |
|
476 | - $config, |
|
477 | - $cacheFactory, |
|
478 | - $request |
|
479 | - ); |
|
480 | - }); |
|
481 | - $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
482 | - |
|
483 | - $this->registerAlias('AppFetcher', AppFetcher::class); |
|
484 | - $this->registerAlias('CategoryFetcher', CategoryFetcher::class); |
|
485 | - |
|
486 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
487 | - return new Cache\File(); |
|
488 | - }); |
|
489 | - $this->registerAlias('UserCache', \OCP\ICache::class); |
|
490 | - |
|
491 | - $this->registerService(Factory::class, function (Server $c) { |
|
492 | - |
|
493 | - $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), |
|
494 | - ArrayCache::class, |
|
495 | - ArrayCache::class, |
|
496 | - ArrayCache::class |
|
497 | - ); |
|
498 | - $config = $c->getConfig(); |
|
499 | - |
|
500 | - if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
501 | - $v = \OC_App::getAppVersions(); |
|
502 | - $v['core'] = implode(',', \OC_Util::getVersion()); |
|
503 | - $version = implode(',', $v); |
|
504 | - $instanceId = \OC_Util::getInstanceId(); |
|
505 | - $path = \OC::$SERVERROOT; |
|
506 | - $prefix = md5($instanceId . '-' . $version . '-' . $path); |
|
507 | - return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
508 | - $config->getSystemValue('memcache.local', null), |
|
509 | - $config->getSystemValue('memcache.distributed', null), |
|
510 | - $config->getSystemValue('memcache.locking', null) |
|
511 | - ); |
|
512 | - } |
|
513 | - return $arrayCacheFactory; |
|
514 | - |
|
515 | - }); |
|
516 | - $this->registerAlias('MemCacheFactory', Factory::class); |
|
517 | - $this->registerAlias(ICacheFactory::class, Factory::class); |
|
518 | - |
|
519 | - $this->registerService('RedisFactory', function (Server $c) { |
|
520 | - $systemConfig = $c->getSystemConfig(); |
|
521 | - return new RedisFactory($systemConfig); |
|
522 | - }); |
|
523 | - |
|
524 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
525 | - return new \OC\Activity\Manager( |
|
526 | - $c->getRequest(), |
|
527 | - $c->getUserSession(), |
|
528 | - $c->getConfig(), |
|
529 | - $c->query(IValidator::class) |
|
530 | - ); |
|
531 | - }); |
|
532 | - $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
533 | - |
|
534 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
535 | - return new \OC\Activity\EventMerger( |
|
536 | - $c->getL10N('lib') |
|
537 | - ); |
|
538 | - }); |
|
539 | - $this->registerAlias(IValidator::class, Validator::class); |
|
540 | - |
|
541 | - $this->registerService(AvatarManager::class, function(Server $c) { |
|
542 | - return new AvatarManager( |
|
543 | - $c->query(\OC\User\Manager::class), |
|
544 | - $c->getAppDataDir('avatar'), |
|
545 | - $c->getL10N('lib'), |
|
546 | - $c->getLogger(), |
|
547 | - $c->getConfig() |
|
548 | - ); |
|
549 | - }); |
|
550 | - $this->registerAlias(\OCP\IAvatarManager::class, AvatarManager::class); |
|
551 | - $this->registerAlias('AvatarManager', AvatarManager::class); |
|
552 | - |
|
553 | - $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); |
|
554 | - $this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class); |
|
555 | - |
|
556 | - $this->registerService(\OC\Log::class, function (Server $c) { |
|
557 | - $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
558 | - $factory = new LogFactory($c, $this->getSystemConfig()); |
|
559 | - $logger = $factory->get($logType); |
|
560 | - $registry = $c->query(\OCP\Support\CrashReport\IRegistry::class); |
|
561 | - |
|
562 | - return new Log($logger, $this->getSystemConfig(), null, $registry); |
|
563 | - }); |
|
564 | - $this->registerAlias(\OCP\ILogger::class, \OC\Log::class); |
|
565 | - $this->registerAlias('Logger', \OC\Log::class); |
|
566 | - |
|
567 | - $this->registerService(ILogFactory::class, function (Server $c) { |
|
568 | - return new LogFactory($c, $this->getSystemConfig()); |
|
569 | - }); |
|
570 | - |
|
571 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
572 | - $config = $c->getConfig(); |
|
573 | - return new \OC\BackgroundJob\JobList( |
|
574 | - $c->getDatabaseConnection(), |
|
575 | - $config, |
|
576 | - new TimeFactory() |
|
577 | - ); |
|
578 | - }); |
|
579 | - $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
580 | - |
|
581 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
582 | - $cacheFactory = $c->getMemCacheFactory(); |
|
583 | - $logger = $c->getLogger(); |
|
584 | - if ($cacheFactory->isLocalCacheAvailable()) { |
|
585 | - $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger); |
|
586 | - } else { |
|
587 | - $router = new \OC\Route\Router($logger); |
|
588 | - } |
|
589 | - return $router; |
|
590 | - }); |
|
591 | - $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
592 | - |
|
593 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
594 | - return new Search(); |
|
595 | - }); |
|
596 | - $this->registerAlias('Search', \OCP\ISearch::class); |
|
597 | - |
|
598 | - $this->registerService(\OC\Security\RateLimiting\Limiter::class, function (Server $c) { |
|
599 | - return new \OC\Security\RateLimiting\Limiter( |
|
600 | - $this->getUserSession(), |
|
601 | - $this->getRequest(), |
|
602 | - new \OC\AppFramework\Utility\TimeFactory(), |
|
603 | - $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
|
604 | - ); |
|
605 | - }); |
|
606 | - $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { |
|
607 | - return new \OC\Security\RateLimiting\Backend\MemoryCache( |
|
608 | - $this->getMemCacheFactory(), |
|
609 | - new \OC\AppFramework\Utility\TimeFactory() |
|
610 | - ); |
|
611 | - }); |
|
612 | - |
|
613 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
614 | - return new SecureRandom(); |
|
615 | - }); |
|
616 | - $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
617 | - |
|
618 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
619 | - return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
620 | - }); |
|
621 | - $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
622 | - |
|
623 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
624 | - return new Hasher($c->getConfig()); |
|
625 | - }); |
|
626 | - $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
627 | - |
|
628 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
629 | - return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
630 | - }); |
|
631 | - $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
632 | - |
|
633 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
634 | - $systemConfig = $c->getSystemConfig(); |
|
635 | - $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
636 | - $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
637 | - if (!$factory->isValidType($type)) { |
|
638 | - throw new \OC\DatabaseException('Invalid database type'); |
|
639 | - } |
|
640 | - $connectionParams = $factory->createConnectionParams(); |
|
641 | - $connection = $factory->getConnection($type, $connectionParams); |
|
642 | - $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
643 | - return $connection; |
|
644 | - }); |
|
645 | - $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
646 | - |
|
647 | - |
|
648 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
649 | - $user = \OC_User::getUser(); |
|
650 | - $uid = $user ? $user : null; |
|
651 | - return new ClientService( |
|
652 | - $c->getConfig(), |
|
653 | - new \OC\Security\CertificateManager( |
|
654 | - $uid, |
|
655 | - new View(), |
|
656 | - $c->getConfig(), |
|
657 | - $c->getLogger(), |
|
658 | - $c->getSecureRandom() |
|
659 | - ) |
|
660 | - ); |
|
661 | - }); |
|
662 | - $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
663 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
664 | - $eventLogger = new EventLogger(); |
|
665 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
666 | - // In debug mode, module is being activated by default |
|
667 | - $eventLogger->activate(); |
|
668 | - } |
|
669 | - return $eventLogger; |
|
670 | - }); |
|
671 | - $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
672 | - |
|
673 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
674 | - $queryLogger = new QueryLogger(); |
|
675 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
676 | - // In debug mode, module is being activated by default |
|
677 | - $queryLogger->activate(); |
|
678 | - } |
|
679 | - return $queryLogger; |
|
680 | - }); |
|
681 | - $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
682 | - |
|
683 | - $this->registerService(TempManager::class, function (Server $c) { |
|
684 | - return new TempManager( |
|
685 | - $c->getLogger(), |
|
686 | - $c->getConfig() |
|
687 | - ); |
|
688 | - }); |
|
689 | - $this->registerAlias('TempManager', TempManager::class); |
|
690 | - $this->registerAlias(ITempManager::class, TempManager::class); |
|
691 | - |
|
692 | - $this->registerService(AppManager::class, function (Server $c) { |
|
693 | - return new \OC\App\AppManager( |
|
694 | - $c->getUserSession(), |
|
695 | - $c->query(\OC\AppConfig::class), |
|
696 | - $c->getGroupManager(), |
|
697 | - $c->getMemCacheFactory(), |
|
698 | - $c->getEventDispatcher() |
|
699 | - ); |
|
700 | - }); |
|
701 | - $this->registerAlias('AppManager', AppManager::class); |
|
702 | - $this->registerAlias(IAppManager::class, AppManager::class); |
|
703 | - |
|
704 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
705 | - return new DateTimeZone( |
|
706 | - $c->getConfig(), |
|
707 | - $c->getSession() |
|
708 | - ); |
|
709 | - }); |
|
710 | - $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
711 | - |
|
712 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
713 | - $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
714 | - |
|
715 | - return new DateTimeFormatter( |
|
716 | - $c->getDateTimeZone()->getTimeZone(), |
|
717 | - $c->getL10N('lib', $language) |
|
718 | - ); |
|
719 | - }); |
|
720 | - $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
721 | - |
|
722 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
723 | - $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
724 | - $listener = new UserMountCacheListener($mountCache); |
|
725 | - $listener->listen($c->getUserManager()); |
|
726 | - return $mountCache; |
|
727 | - }); |
|
728 | - $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
729 | - |
|
730 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
731 | - $loader = \OC\Files\Filesystem::getLoader(); |
|
732 | - $mountCache = $c->query('UserMountCache'); |
|
733 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
734 | - |
|
735 | - // builtin providers |
|
736 | - |
|
737 | - $config = $c->getConfig(); |
|
738 | - $manager->registerProvider(new CacheMountProvider($config)); |
|
739 | - $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
740 | - $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
741 | - |
|
742 | - return $manager; |
|
743 | - }); |
|
744 | - $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
745 | - |
|
746 | - $this->registerService('IniWrapper', function ($c) { |
|
747 | - return new IniGetWrapper(); |
|
748 | - }); |
|
749 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
750 | - $busClass = $c->getConfig()->getSystemValue('commandbus'); |
|
751 | - if ($busClass) { |
|
752 | - list($app, $class) = explode('::', $busClass, 2); |
|
753 | - if ($c->getAppManager()->isInstalled($app)) { |
|
754 | - \OC_App::loadApp($app); |
|
755 | - return $c->query($class); |
|
756 | - } else { |
|
757 | - throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled"); |
|
758 | - } |
|
759 | - } else { |
|
760 | - $jobList = $c->getJobList(); |
|
761 | - return new CronBus($jobList); |
|
762 | - } |
|
763 | - }); |
|
764 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
765 | - return new TrustedDomainHelper($this->getConfig()); |
|
766 | - }); |
|
767 | - $this->registerService(Throttler::class, function (Server $c) { |
|
768 | - return new Throttler( |
|
769 | - $c->getDatabaseConnection(), |
|
770 | - new TimeFactory(), |
|
771 | - $c->getLogger(), |
|
772 | - $c->getConfig() |
|
773 | - ); |
|
774 | - }); |
|
775 | - $this->registerAlias('Throttler', Throttler::class); |
|
776 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
777 | - // IConfig and IAppManager requires a working database. This code |
|
778 | - // might however be called when ownCloud is not yet setup. |
|
779 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
780 | - $config = $c->getConfig(); |
|
781 | - $appManager = $c->getAppManager(); |
|
782 | - } else { |
|
783 | - $config = null; |
|
784 | - $appManager = null; |
|
785 | - } |
|
786 | - |
|
787 | - return new Checker( |
|
788 | - new EnvironmentHelper(), |
|
789 | - new FileAccessHelper(), |
|
790 | - new AppLocator(), |
|
791 | - $config, |
|
792 | - $c->getMemCacheFactory(), |
|
793 | - $appManager, |
|
794 | - $c->getTempManager() |
|
795 | - ); |
|
796 | - }); |
|
797 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
798 | - if (isset($this['urlParams'])) { |
|
799 | - $urlParams = $this['urlParams']; |
|
800 | - } else { |
|
801 | - $urlParams = []; |
|
802 | - } |
|
803 | - |
|
804 | - if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
805 | - && in_array('fakeinput', stream_get_wrappers()) |
|
806 | - ) { |
|
807 | - $stream = 'fakeinput://data'; |
|
808 | - } else { |
|
809 | - $stream = 'php://input'; |
|
810 | - } |
|
811 | - |
|
812 | - return new Request( |
|
813 | - [ |
|
814 | - 'get' => $_GET, |
|
815 | - 'post' => $_POST, |
|
816 | - 'files' => $_FILES, |
|
817 | - 'server' => $_SERVER, |
|
818 | - 'env' => $_ENV, |
|
819 | - 'cookies' => $_COOKIE, |
|
820 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
821 | - ? $_SERVER['REQUEST_METHOD'] |
|
822 | - : '', |
|
823 | - 'urlParams' => $urlParams, |
|
824 | - ], |
|
825 | - $this->getSecureRandom(), |
|
826 | - $this->getConfig(), |
|
827 | - $this->getCsrfTokenManager(), |
|
828 | - $stream |
|
829 | - ); |
|
830 | - }); |
|
831 | - $this->registerAlias('Request', \OCP\IRequest::class); |
|
832 | - |
|
833 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
834 | - return new Mailer( |
|
835 | - $c->getConfig(), |
|
836 | - $c->getLogger(), |
|
837 | - $c->query(Defaults::class), |
|
838 | - $c->getURLGenerator(), |
|
839 | - $c->getL10N('lib') |
|
840 | - ); |
|
841 | - }); |
|
842 | - $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
843 | - |
|
844 | - $this->registerService('LDAPProvider', function (Server $c) { |
|
845 | - $config = $c->getConfig(); |
|
846 | - $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
847 | - if (is_null($factoryClass)) { |
|
848 | - throw new \Exception('ldapProviderFactory not set'); |
|
849 | - } |
|
850 | - /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
851 | - $factory = new $factoryClass($this); |
|
852 | - return $factory->getLDAPProvider(); |
|
853 | - }); |
|
854 | - $this->registerService(ILockingProvider::class, function (Server $c) { |
|
855 | - $ini = $c->getIniWrapper(); |
|
856 | - $config = $c->getConfig(); |
|
857 | - $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
858 | - if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
859 | - /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
860 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
861 | - $memcache = $memcacheFactory->createLocking('lock'); |
|
862 | - if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
863 | - return new MemcacheLockingProvider($memcache, $ttl); |
|
864 | - } |
|
865 | - return new DBLockingProvider( |
|
866 | - $c->getDatabaseConnection(), |
|
867 | - $c->getLogger(), |
|
868 | - new TimeFactory(), |
|
869 | - $ttl, |
|
870 | - !\OC::$CLI |
|
871 | - ); |
|
872 | - } |
|
873 | - return new NoopLockingProvider(); |
|
874 | - }); |
|
875 | - $this->registerAlias('LockingProvider', ILockingProvider::class); |
|
876 | - |
|
877 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
878 | - return new \OC\Files\Mount\Manager(); |
|
879 | - }); |
|
880 | - $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
881 | - |
|
882 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
883 | - return new \OC\Files\Type\Detection( |
|
884 | - $c->getURLGenerator(), |
|
885 | - \OC::$configDir, |
|
886 | - \OC::$SERVERROOT . '/resources/config/' |
|
887 | - ); |
|
888 | - }); |
|
889 | - $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
890 | - |
|
891 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
892 | - return new \OC\Files\Type\Loader( |
|
893 | - $c->getDatabaseConnection() |
|
894 | - ); |
|
895 | - }); |
|
896 | - $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
897 | - $this->registerService(BundleFetcher::class, function () { |
|
898 | - return new BundleFetcher($this->getL10N('lib')); |
|
899 | - }); |
|
900 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
901 | - return new Manager( |
|
902 | - $c->query(IValidator::class) |
|
903 | - ); |
|
904 | - }); |
|
905 | - $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
906 | - |
|
907 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
908 | - $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
909 | - $manager->registerCapability(function () use ($c) { |
|
910 | - return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
911 | - }); |
|
912 | - $manager->registerCapability(function () use ($c) { |
|
913 | - return $c->query(\OC\Security\Bruteforce\Capabilities::class); |
|
914 | - }); |
|
915 | - return $manager; |
|
916 | - }); |
|
917 | - $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
918 | - |
|
919 | - $this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) { |
|
920 | - $config = $c->getConfig(); |
|
921 | - $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class); |
|
922 | - /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
923 | - $factory = new $factoryClass($this); |
|
924 | - $manager = $factory->getManager(); |
|
925 | - |
|
926 | - $manager->registerDisplayNameResolver('user', function($id) use ($c) { |
|
927 | - $manager = $c->getUserManager(); |
|
928 | - $user = $manager->get($id); |
|
929 | - if(is_null($user)) { |
|
930 | - $l = $c->getL10N('core'); |
|
931 | - $displayName = $l->t('Unknown user'); |
|
932 | - } else { |
|
933 | - $displayName = $user->getDisplayName(); |
|
934 | - } |
|
935 | - return $displayName; |
|
936 | - }); |
|
937 | - |
|
938 | - return $manager; |
|
939 | - }); |
|
940 | - $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
941 | - |
|
942 | - $this->registerService('ThemingDefaults', function (Server $c) { |
|
943 | - /* |
|
173 | + /** @var string */ |
|
174 | + private $webRoot; |
|
175 | + |
|
176 | + /** |
|
177 | + * @param string $webRoot |
|
178 | + * @param \OC\Config $config |
|
179 | + */ |
|
180 | + public function __construct($webRoot, \OC\Config $config) { |
|
181 | + parent::__construct(); |
|
182 | + $this->webRoot = $webRoot; |
|
183 | + |
|
184 | + // To find out if we are running from CLI or not |
|
185 | + $this->registerParameter('isCLI', \OC::$CLI); |
|
186 | + |
|
187 | + $this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) { |
|
188 | + return $c; |
|
189 | + }); |
|
190 | + |
|
191 | + $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class); |
|
192 | + $this->registerAlias('CalendarManager', \OC\Calendar\Manager::class); |
|
193 | + |
|
194 | + $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class); |
|
195 | + $this->registerAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class); |
|
196 | + |
|
197 | + $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class); |
|
198 | + $this->registerAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class); |
|
199 | + |
|
200 | + $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
201 | + $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
202 | + |
|
203 | + $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
204 | + |
|
205 | + |
|
206 | + $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
207 | + return new PreviewManager( |
|
208 | + $c->getConfig(), |
|
209 | + $c->getRootFolder(), |
|
210 | + $c->getAppDataDir('preview'), |
|
211 | + $c->getEventDispatcher(), |
|
212 | + $c->getSession()->get('user_id') |
|
213 | + ); |
|
214 | + }); |
|
215 | + $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
216 | + |
|
217 | + $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
218 | + return new \OC\Preview\Watcher( |
|
219 | + $c->getAppDataDir('preview') |
|
220 | + ); |
|
221 | + }); |
|
222 | + |
|
223 | + $this->registerService(\OCP\Encryption\IManager::class, function (Server $c) { |
|
224 | + $view = new View(); |
|
225 | + $util = new Encryption\Util( |
|
226 | + $view, |
|
227 | + $c->getUserManager(), |
|
228 | + $c->getGroupManager(), |
|
229 | + $c->getConfig() |
|
230 | + ); |
|
231 | + return new Encryption\Manager( |
|
232 | + $c->getConfig(), |
|
233 | + $c->getLogger(), |
|
234 | + $c->getL10N('core'), |
|
235 | + new View(), |
|
236 | + $util, |
|
237 | + new ArrayCache() |
|
238 | + ); |
|
239 | + }); |
|
240 | + $this->registerAlias('EncryptionManager', \OCP\Encryption\IManager::class); |
|
241 | + |
|
242 | + $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
243 | + $util = new Encryption\Util( |
|
244 | + new View(), |
|
245 | + $c->getUserManager(), |
|
246 | + $c->getGroupManager(), |
|
247 | + $c->getConfig() |
|
248 | + ); |
|
249 | + return new Encryption\File( |
|
250 | + $util, |
|
251 | + $c->getRootFolder(), |
|
252 | + $c->getShareManager() |
|
253 | + ); |
|
254 | + }); |
|
255 | + |
|
256 | + $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
257 | + $view = new View(); |
|
258 | + $util = new Encryption\Util( |
|
259 | + $view, |
|
260 | + $c->getUserManager(), |
|
261 | + $c->getGroupManager(), |
|
262 | + $c->getConfig() |
|
263 | + ); |
|
264 | + |
|
265 | + return new Encryption\Keys\Storage($view, $util); |
|
266 | + }); |
|
267 | + $this->registerService('TagMapper', function (Server $c) { |
|
268 | + return new TagMapper($c->getDatabaseConnection()); |
|
269 | + }); |
|
270 | + |
|
271 | + $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
272 | + $tagMapper = $c->query('TagMapper'); |
|
273 | + return new TagManager($tagMapper, $c->getUserSession()); |
|
274 | + }); |
|
275 | + $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
276 | + |
|
277 | + $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
278 | + $config = $c->getConfig(); |
|
279 | + $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class); |
|
280 | + return new $factoryClass($this); |
|
281 | + }); |
|
282 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
283 | + return $c->query('SystemTagManagerFactory')->getManager(); |
|
284 | + }); |
|
285 | + $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
286 | + |
|
287 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
288 | + return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
289 | + }); |
|
290 | + $this->registerService('RootFolder', function (Server $c) { |
|
291 | + $manager = \OC\Files\Filesystem::getMountManager(null); |
|
292 | + $view = new View(); |
|
293 | + $root = new Root( |
|
294 | + $manager, |
|
295 | + $view, |
|
296 | + null, |
|
297 | + $c->getUserMountCache(), |
|
298 | + $this->getLogger(), |
|
299 | + $this->getUserManager() |
|
300 | + ); |
|
301 | + $connector = new HookConnector($root, $view); |
|
302 | + $connector->viewToNode(); |
|
303 | + |
|
304 | + $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
305 | + $previewConnector->connectWatcher(); |
|
306 | + |
|
307 | + return $root; |
|
308 | + }); |
|
309 | + $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
310 | + |
|
311 | + $this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) { |
|
312 | + return new LazyRoot(function () use ($c) { |
|
313 | + return $c->query('RootFolder'); |
|
314 | + }); |
|
315 | + }); |
|
316 | + $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
317 | + |
|
318 | + $this->registerService(\OC\User\Manager::class, function (Server $c) { |
|
319 | + return new \OC\User\Manager($c->getConfig(), $c->getEventDispatcher()); |
|
320 | + }); |
|
321 | + $this->registerAlias('UserManager', \OC\User\Manager::class); |
|
322 | + $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); |
|
323 | + |
|
324 | + $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
325 | + $groupManager = new \OC\Group\Manager($this->getUserManager(), $c->getEventDispatcher(), $this->getLogger()); |
|
326 | + $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
327 | + \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
328 | + }); |
|
329 | + $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
330 | + \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
331 | + }); |
|
332 | + $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
333 | + \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
334 | + }); |
|
335 | + $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
336 | + \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
337 | + }); |
|
338 | + $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
339 | + \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
340 | + }); |
|
341 | + $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
342 | + \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
343 | + //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
344 | + \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
345 | + }); |
|
346 | + return $groupManager; |
|
347 | + }); |
|
348 | + $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
349 | + |
|
350 | + $this->registerService(Store::class, function (Server $c) { |
|
351 | + $session = $c->getSession(); |
|
352 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
353 | + $tokenProvider = $c->query(IProvider::class); |
|
354 | + } else { |
|
355 | + $tokenProvider = null; |
|
356 | + } |
|
357 | + $logger = $c->getLogger(); |
|
358 | + return new Store($session, $logger, $tokenProvider); |
|
359 | + }); |
|
360 | + $this->registerAlias(IStore::class, Store::class); |
|
361 | + $this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) { |
|
362 | + $dbConnection = $c->getDatabaseConnection(); |
|
363 | + return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
364 | + }); |
|
365 | + $this->registerAlias(IProvider::class, Authentication\Token\Manager::class); |
|
366 | + |
|
367 | + $this->registerService(\OC\User\Session::class, function (Server $c) { |
|
368 | + $manager = $c->getUserManager(); |
|
369 | + $session = new \OC\Session\Memory(''); |
|
370 | + $timeFactory = new TimeFactory(); |
|
371 | + // Token providers might require a working database. This code |
|
372 | + // might however be called when ownCloud is not yet setup. |
|
373 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
374 | + $defaultTokenProvider = $c->query(IProvider::class); |
|
375 | + } else { |
|
376 | + $defaultTokenProvider = null; |
|
377 | + } |
|
378 | + |
|
379 | + $dispatcher = $c->getEventDispatcher(); |
|
380 | + |
|
381 | + $userSession = new \OC\User\Session( |
|
382 | + $manager, |
|
383 | + $session, |
|
384 | + $timeFactory, |
|
385 | + $defaultTokenProvider, |
|
386 | + $c->getConfig(), |
|
387 | + $c->getSecureRandom(), |
|
388 | + $c->getLockdownManager(), |
|
389 | + $c->getLogger() |
|
390 | + ); |
|
391 | + $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
392 | + \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
393 | + }); |
|
394 | + $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
395 | + /** @var $user \OC\User\User */ |
|
396 | + \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
397 | + }); |
|
398 | + $userSession->listen('\OC\User', 'preDelete', function ($user) use ($dispatcher) { |
|
399 | + /** @var $user \OC\User\User */ |
|
400 | + \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
401 | + $dispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); |
|
402 | + }); |
|
403 | + $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
404 | + /** @var $user \OC\User\User */ |
|
405 | + \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
406 | + }); |
|
407 | + $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
408 | + /** @var $user \OC\User\User */ |
|
409 | + \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
410 | + }); |
|
411 | + $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
412 | + /** @var $user \OC\User\User */ |
|
413 | + \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
414 | + }); |
|
415 | + $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
416 | + \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
417 | + }); |
|
418 | + $userSession->listen('\OC\User', 'postLogin', function ($user, $password, $isTokenLogin) { |
|
419 | + /** @var $user \OC\User\User */ |
|
420 | + \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'isTokenLogin' => $isTokenLogin)); |
|
421 | + }); |
|
422 | + $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { |
|
423 | + /** @var $user \OC\User\User */ |
|
424 | + \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
425 | + }); |
|
426 | + $userSession->listen('\OC\User', 'logout', function () { |
|
427 | + \OC_Hook::emit('OC_User', 'logout', array()); |
|
428 | + }); |
|
429 | + $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) { |
|
430 | + /** @var $user \OC\User\User */ |
|
431 | + \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
|
432 | + }); |
|
433 | + return $userSession; |
|
434 | + }); |
|
435 | + $this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class); |
|
436 | + $this->registerAlias('UserSession', \OC\User\Session::class); |
|
437 | + |
|
438 | + $this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class); |
|
439 | + |
|
440 | + $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
|
441 | + $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
442 | + |
|
443 | + $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
444 | + return new \OC\AllConfig( |
|
445 | + $c->getSystemConfig() |
|
446 | + ); |
|
447 | + }); |
|
448 | + $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
449 | + $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
450 | + |
|
451 | + $this->registerService('SystemConfig', function ($c) use ($config) { |
|
452 | + return new \OC\SystemConfig($config); |
|
453 | + }); |
|
454 | + |
|
455 | + $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
456 | + return new \OC\AppConfig($c->getDatabaseConnection()); |
|
457 | + }); |
|
458 | + $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
459 | + $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
460 | + |
|
461 | + $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
462 | + return new \OC\L10N\Factory( |
|
463 | + $c->getConfig(), |
|
464 | + $c->getRequest(), |
|
465 | + $c->getUserSession(), |
|
466 | + \OC::$SERVERROOT |
|
467 | + ); |
|
468 | + }); |
|
469 | + $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
470 | + |
|
471 | + $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
472 | + $config = $c->getConfig(); |
|
473 | + $cacheFactory = $c->getMemCacheFactory(); |
|
474 | + $request = $c->getRequest(); |
|
475 | + return new \OC\URLGenerator( |
|
476 | + $config, |
|
477 | + $cacheFactory, |
|
478 | + $request |
|
479 | + ); |
|
480 | + }); |
|
481 | + $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
482 | + |
|
483 | + $this->registerAlias('AppFetcher', AppFetcher::class); |
|
484 | + $this->registerAlias('CategoryFetcher', CategoryFetcher::class); |
|
485 | + |
|
486 | + $this->registerService(\OCP\ICache::class, function ($c) { |
|
487 | + return new Cache\File(); |
|
488 | + }); |
|
489 | + $this->registerAlias('UserCache', \OCP\ICache::class); |
|
490 | + |
|
491 | + $this->registerService(Factory::class, function (Server $c) { |
|
492 | + |
|
493 | + $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), |
|
494 | + ArrayCache::class, |
|
495 | + ArrayCache::class, |
|
496 | + ArrayCache::class |
|
497 | + ); |
|
498 | + $config = $c->getConfig(); |
|
499 | + |
|
500 | + if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
501 | + $v = \OC_App::getAppVersions(); |
|
502 | + $v['core'] = implode(',', \OC_Util::getVersion()); |
|
503 | + $version = implode(',', $v); |
|
504 | + $instanceId = \OC_Util::getInstanceId(); |
|
505 | + $path = \OC::$SERVERROOT; |
|
506 | + $prefix = md5($instanceId . '-' . $version . '-' . $path); |
|
507 | + return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
508 | + $config->getSystemValue('memcache.local', null), |
|
509 | + $config->getSystemValue('memcache.distributed', null), |
|
510 | + $config->getSystemValue('memcache.locking', null) |
|
511 | + ); |
|
512 | + } |
|
513 | + return $arrayCacheFactory; |
|
514 | + |
|
515 | + }); |
|
516 | + $this->registerAlias('MemCacheFactory', Factory::class); |
|
517 | + $this->registerAlias(ICacheFactory::class, Factory::class); |
|
518 | + |
|
519 | + $this->registerService('RedisFactory', function (Server $c) { |
|
520 | + $systemConfig = $c->getSystemConfig(); |
|
521 | + return new RedisFactory($systemConfig); |
|
522 | + }); |
|
523 | + |
|
524 | + $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
525 | + return new \OC\Activity\Manager( |
|
526 | + $c->getRequest(), |
|
527 | + $c->getUserSession(), |
|
528 | + $c->getConfig(), |
|
529 | + $c->query(IValidator::class) |
|
530 | + ); |
|
531 | + }); |
|
532 | + $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
533 | + |
|
534 | + $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
535 | + return new \OC\Activity\EventMerger( |
|
536 | + $c->getL10N('lib') |
|
537 | + ); |
|
538 | + }); |
|
539 | + $this->registerAlias(IValidator::class, Validator::class); |
|
540 | + |
|
541 | + $this->registerService(AvatarManager::class, function(Server $c) { |
|
542 | + return new AvatarManager( |
|
543 | + $c->query(\OC\User\Manager::class), |
|
544 | + $c->getAppDataDir('avatar'), |
|
545 | + $c->getL10N('lib'), |
|
546 | + $c->getLogger(), |
|
547 | + $c->getConfig() |
|
548 | + ); |
|
549 | + }); |
|
550 | + $this->registerAlias(\OCP\IAvatarManager::class, AvatarManager::class); |
|
551 | + $this->registerAlias('AvatarManager', AvatarManager::class); |
|
552 | + |
|
553 | + $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); |
|
554 | + $this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class); |
|
555 | + |
|
556 | + $this->registerService(\OC\Log::class, function (Server $c) { |
|
557 | + $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
558 | + $factory = new LogFactory($c, $this->getSystemConfig()); |
|
559 | + $logger = $factory->get($logType); |
|
560 | + $registry = $c->query(\OCP\Support\CrashReport\IRegistry::class); |
|
561 | + |
|
562 | + return new Log($logger, $this->getSystemConfig(), null, $registry); |
|
563 | + }); |
|
564 | + $this->registerAlias(\OCP\ILogger::class, \OC\Log::class); |
|
565 | + $this->registerAlias('Logger', \OC\Log::class); |
|
566 | + |
|
567 | + $this->registerService(ILogFactory::class, function (Server $c) { |
|
568 | + return new LogFactory($c, $this->getSystemConfig()); |
|
569 | + }); |
|
570 | + |
|
571 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
572 | + $config = $c->getConfig(); |
|
573 | + return new \OC\BackgroundJob\JobList( |
|
574 | + $c->getDatabaseConnection(), |
|
575 | + $config, |
|
576 | + new TimeFactory() |
|
577 | + ); |
|
578 | + }); |
|
579 | + $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
580 | + |
|
581 | + $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
582 | + $cacheFactory = $c->getMemCacheFactory(); |
|
583 | + $logger = $c->getLogger(); |
|
584 | + if ($cacheFactory->isLocalCacheAvailable()) { |
|
585 | + $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger); |
|
586 | + } else { |
|
587 | + $router = new \OC\Route\Router($logger); |
|
588 | + } |
|
589 | + return $router; |
|
590 | + }); |
|
591 | + $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
592 | + |
|
593 | + $this->registerService(\OCP\ISearch::class, function ($c) { |
|
594 | + return new Search(); |
|
595 | + }); |
|
596 | + $this->registerAlias('Search', \OCP\ISearch::class); |
|
597 | + |
|
598 | + $this->registerService(\OC\Security\RateLimiting\Limiter::class, function (Server $c) { |
|
599 | + return new \OC\Security\RateLimiting\Limiter( |
|
600 | + $this->getUserSession(), |
|
601 | + $this->getRequest(), |
|
602 | + new \OC\AppFramework\Utility\TimeFactory(), |
|
603 | + $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
|
604 | + ); |
|
605 | + }); |
|
606 | + $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { |
|
607 | + return new \OC\Security\RateLimiting\Backend\MemoryCache( |
|
608 | + $this->getMemCacheFactory(), |
|
609 | + new \OC\AppFramework\Utility\TimeFactory() |
|
610 | + ); |
|
611 | + }); |
|
612 | + |
|
613 | + $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
614 | + return new SecureRandom(); |
|
615 | + }); |
|
616 | + $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
617 | + |
|
618 | + $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
619 | + return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
620 | + }); |
|
621 | + $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
622 | + |
|
623 | + $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
624 | + return new Hasher($c->getConfig()); |
|
625 | + }); |
|
626 | + $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
627 | + |
|
628 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
629 | + return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
630 | + }); |
|
631 | + $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
632 | + |
|
633 | + $this->registerService(IDBConnection::class, function (Server $c) { |
|
634 | + $systemConfig = $c->getSystemConfig(); |
|
635 | + $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
636 | + $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
637 | + if (!$factory->isValidType($type)) { |
|
638 | + throw new \OC\DatabaseException('Invalid database type'); |
|
639 | + } |
|
640 | + $connectionParams = $factory->createConnectionParams(); |
|
641 | + $connection = $factory->getConnection($type, $connectionParams); |
|
642 | + $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
643 | + return $connection; |
|
644 | + }); |
|
645 | + $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
646 | + |
|
647 | + |
|
648 | + $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
649 | + $user = \OC_User::getUser(); |
|
650 | + $uid = $user ? $user : null; |
|
651 | + return new ClientService( |
|
652 | + $c->getConfig(), |
|
653 | + new \OC\Security\CertificateManager( |
|
654 | + $uid, |
|
655 | + new View(), |
|
656 | + $c->getConfig(), |
|
657 | + $c->getLogger(), |
|
658 | + $c->getSecureRandom() |
|
659 | + ) |
|
660 | + ); |
|
661 | + }); |
|
662 | + $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
663 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
664 | + $eventLogger = new EventLogger(); |
|
665 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
666 | + // In debug mode, module is being activated by default |
|
667 | + $eventLogger->activate(); |
|
668 | + } |
|
669 | + return $eventLogger; |
|
670 | + }); |
|
671 | + $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
672 | + |
|
673 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
674 | + $queryLogger = new QueryLogger(); |
|
675 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
676 | + // In debug mode, module is being activated by default |
|
677 | + $queryLogger->activate(); |
|
678 | + } |
|
679 | + return $queryLogger; |
|
680 | + }); |
|
681 | + $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
682 | + |
|
683 | + $this->registerService(TempManager::class, function (Server $c) { |
|
684 | + return new TempManager( |
|
685 | + $c->getLogger(), |
|
686 | + $c->getConfig() |
|
687 | + ); |
|
688 | + }); |
|
689 | + $this->registerAlias('TempManager', TempManager::class); |
|
690 | + $this->registerAlias(ITempManager::class, TempManager::class); |
|
691 | + |
|
692 | + $this->registerService(AppManager::class, function (Server $c) { |
|
693 | + return new \OC\App\AppManager( |
|
694 | + $c->getUserSession(), |
|
695 | + $c->query(\OC\AppConfig::class), |
|
696 | + $c->getGroupManager(), |
|
697 | + $c->getMemCacheFactory(), |
|
698 | + $c->getEventDispatcher() |
|
699 | + ); |
|
700 | + }); |
|
701 | + $this->registerAlias('AppManager', AppManager::class); |
|
702 | + $this->registerAlias(IAppManager::class, AppManager::class); |
|
703 | + |
|
704 | + $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
705 | + return new DateTimeZone( |
|
706 | + $c->getConfig(), |
|
707 | + $c->getSession() |
|
708 | + ); |
|
709 | + }); |
|
710 | + $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
711 | + |
|
712 | + $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
713 | + $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
714 | + |
|
715 | + return new DateTimeFormatter( |
|
716 | + $c->getDateTimeZone()->getTimeZone(), |
|
717 | + $c->getL10N('lib', $language) |
|
718 | + ); |
|
719 | + }); |
|
720 | + $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
721 | + |
|
722 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
723 | + $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
724 | + $listener = new UserMountCacheListener($mountCache); |
|
725 | + $listener->listen($c->getUserManager()); |
|
726 | + return $mountCache; |
|
727 | + }); |
|
728 | + $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
729 | + |
|
730 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
731 | + $loader = \OC\Files\Filesystem::getLoader(); |
|
732 | + $mountCache = $c->query('UserMountCache'); |
|
733 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
734 | + |
|
735 | + // builtin providers |
|
736 | + |
|
737 | + $config = $c->getConfig(); |
|
738 | + $manager->registerProvider(new CacheMountProvider($config)); |
|
739 | + $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
740 | + $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
741 | + |
|
742 | + return $manager; |
|
743 | + }); |
|
744 | + $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
745 | + |
|
746 | + $this->registerService('IniWrapper', function ($c) { |
|
747 | + return new IniGetWrapper(); |
|
748 | + }); |
|
749 | + $this->registerService('AsyncCommandBus', function (Server $c) { |
|
750 | + $busClass = $c->getConfig()->getSystemValue('commandbus'); |
|
751 | + if ($busClass) { |
|
752 | + list($app, $class) = explode('::', $busClass, 2); |
|
753 | + if ($c->getAppManager()->isInstalled($app)) { |
|
754 | + \OC_App::loadApp($app); |
|
755 | + return $c->query($class); |
|
756 | + } else { |
|
757 | + throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled"); |
|
758 | + } |
|
759 | + } else { |
|
760 | + $jobList = $c->getJobList(); |
|
761 | + return new CronBus($jobList); |
|
762 | + } |
|
763 | + }); |
|
764 | + $this->registerService('TrustedDomainHelper', function ($c) { |
|
765 | + return new TrustedDomainHelper($this->getConfig()); |
|
766 | + }); |
|
767 | + $this->registerService(Throttler::class, function (Server $c) { |
|
768 | + return new Throttler( |
|
769 | + $c->getDatabaseConnection(), |
|
770 | + new TimeFactory(), |
|
771 | + $c->getLogger(), |
|
772 | + $c->getConfig() |
|
773 | + ); |
|
774 | + }); |
|
775 | + $this->registerAlias('Throttler', Throttler::class); |
|
776 | + $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
777 | + // IConfig and IAppManager requires a working database. This code |
|
778 | + // might however be called when ownCloud is not yet setup. |
|
779 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
780 | + $config = $c->getConfig(); |
|
781 | + $appManager = $c->getAppManager(); |
|
782 | + } else { |
|
783 | + $config = null; |
|
784 | + $appManager = null; |
|
785 | + } |
|
786 | + |
|
787 | + return new Checker( |
|
788 | + new EnvironmentHelper(), |
|
789 | + new FileAccessHelper(), |
|
790 | + new AppLocator(), |
|
791 | + $config, |
|
792 | + $c->getMemCacheFactory(), |
|
793 | + $appManager, |
|
794 | + $c->getTempManager() |
|
795 | + ); |
|
796 | + }); |
|
797 | + $this->registerService(\OCP\IRequest::class, function ($c) { |
|
798 | + if (isset($this['urlParams'])) { |
|
799 | + $urlParams = $this['urlParams']; |
|
800 | + } else { |
|
801 | + $urlParams = []; |
|
802 | + } |
|
803 | + |
|
804 | + if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
805 | + && in_array('fakeinput', stream_get_wrappers()) |
|
806 | + ) { |
|
807 | + $stream = 'fakeinput://data'; |
|
808 | + } else { |
|
809 | + $stream = 'php://input'; |
|
810 | + } |
|
811 | + |
|
812 | + return new Request( |
|
813 | + [ |
|
814 | + 'get' => $_GET, |
|
815 | + 'post' => $_POST, |
|
816 | + 'files' => $_FILES, |
|
817 | + 'server' => $_SERVER, |
|
818 | + 'env' => $_ENV, |
|
819 | + 'cookies' => $_COOKIE, |
|
820 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
821 | + ? $_SERVER['REQUEST_METHOD'] |
|
822 | + : '', |
|
823 | + 'urlParams' => $urlParams, |
|
824 | + ], |
|
825 | + $this->getSecureRandom(), |
|
826 | + $this->getConfig(), |
|
827 | + $this->getCsrfTokenManager(), |
|
828 | + $stream |
|
829 | + ); |
|
830 | + }); |
|
831 | + $this->registerAlias('Request', \OCP\IRequest::class); |
|
832 | + |
|
833 | + $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
834 | + return new Mailer( |
|
835 | + $c->getConfig(), |
|
836 | + $c->getLogger(), |
|
837 | + $c->query(Defaults::class), |
|
838 | + $c->getURLGenerator(), |
|
839 | + $c->getL10N('lib') |
|
840 | + ); |
|
841 | + }); |
|
842 | + $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
843 | + |
|
844 | + $this->registerService('LDAPProvider', function (Server $c) { |
|
845 | + $config = $c->getConfig(); |
|
846 | + $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
847 | + if (is_null($factoryClass)) { |
|
848 | + throw new \Exception('ldapProviderFactory not set'); |
|
849 | + } |
|
850 | + /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
851 | + $factory = new $factoryClass($this); |
|
852 | + return $factory->getLDAPProvider(); |
|
853 | + }); |
|
854 | + $this->registerService(ILockingProvider::class, function (Server $c) { |
|
855 | + $ini = $c->getIniWrapper(); |
|
856 | + $config = $c->getConfig(); |
|
857 | + $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
858 | + if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
859 | + /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
860 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
861 | + $memcache = $memcacheFactory->createLocking('lock'); |
|
862 | + if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
863 | + return new MemcacheLockingProvider($memcache, $ttl); |
|
864 | + } |
|
865 | + return new DBLockingProvider( |
|
866 | + $c->getDatabaseConnection(), |
|
867 | + $c->getLogger(), |
|
868 | + new TimeFactory(), |
|
869 | + $ttl, |
|
870 | + !\OC::$CLI |
|
871 | + ); |
|
872 | + } |
|
873 | + return new NoopLockingProvider(); |
|
874 | + }); |
|
875 | + $this->registerAlias('LockingProvider', ILockingProvider::class); |
|
876 | + |
|
877 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
878 | + return new \OC\Files\Mount\Manager(); |
|
879 | + }); |
|
880 | + $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
881 | + |
|
882 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
883 | + return new \OC\Files\Type\Detection( |
|
884 | + $c->getURLGenerator(), |
|
885 | + \OC::$configDir, |
|
886 | + \OC::$SERVERROOT . '/resources/config/' |
|
887 | + ); |
|
888 | + }); |
|
889 | + $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
890 | + |
|
891 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
892 | + return new \OC\Files\Type\Loader( |
|
893 | + $c->getDatabaseConnection() |
|
894 | + ); |
|
895 | + }); |
|
896 | + $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
897 | + $this->registerService(BundleFetcher::class, function () { |
|
898 | + return new BundleFetcher($this->getL10N('lib')); |
|
899 | + }); |
|
900 | + $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
901 | + return new Manager( |
|
902 | + $c->query(IValidator::class) |
|
903 | + ); |
|
904 | + }); |
|
905 | + $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
906 | + |
|
907 | + $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
908 | + $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
909 | + $manager->registerCapability(function () use ($c) { |
|
910 | + return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
911 | + }); |
|
912 | + $manager->registerCapability(function () use ($c) { |
|
913 | + return $c->query(\OC\Security\Bruteforce\Capabilities::class); |
|
914 | + }); |
|
915 | + return $manager; |
|
916 | + }); |
|
917 | + $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
918 | + |
|
919 | + $this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) { |
|
920 | + $config = $c->getConfig(); |
|
921 | + $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class); |
|
922 | + /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
923 | + $factory = new $factoryClass($this); |
|
924 | + $manager = $factory->getManager(); |
|
925 | + |
|
926 | + $manager->registerDisplayNameResolver('user', function($id) use ($c) { |
|
927 | + $manager = $c->getUserManager(); |
|
928 | + $user = $manager->get($id); |
|
929 | + if(is_null($user)) { |
|
930 | + $l = $c->getL10N('core'); |
|
931 | + $displayName = $l->t('Unknown user'); |
|
932 | + } else { |
|
933 | + $displayName = $user->getDisplayName(); |
|
934 | + } |
|
935 | + return $displayName; |
|
936 | + }); |
|
937 | + |
|
938 | + return $manager; |
|
939 | + }); |
|
940 | + $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
941 | + |
|
942 | + $this->registerService('ThemingDefaults', function (Server $c) { |
|
943 | + /* |
|
944 | 944 | * Dark magic for autoloader. |
945 | 945 | * If we do a class_exists it will try to load the class which will |
946 | 946 | * make composer cache the result. Resulting in errors when enabling |
947 | 947 | * the theming app. |
948 | 948 | */ |
949 | - $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
950 | - if (isset($prefixes['OCA\\Theming\\'])) { |
|
951 | - $classExists = true; |
|
952 | - } else { |
|
953 | - $classExists = false; |
|
954 | - } |
|
955 | - |
|
956 | - if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) { |
|
957 | - return new ThemingDefaults( |
|
958 | - $c->getConfig(), |
|
959 | - $c->getL10N('theming'), |
|
960 | - $c->getURLGenerator(), |
|
961 | - $c->getMemCacheFactory(), |
|
962 | - new Util($c->getConfig(), $this->getAppManager(), $c->getAppDataDir('theming')), |
|
963 | - new ImageManager($c->getConfig(), $c->getAppDataDir('theming'), $c->getURLGenerator(), $this->getMemCacheFactory(), $this->getLogger()), |
|
964 | - $c->getAppManager(), |
|
965 | - $c->getNavigationManager() |
|
966 | - ); |
|
967 | - } |
|
968 | - return new \OC_Defaults(); |
|
969 | - }); |
|
970 | - $this->registerService(SCSSCacher::class, function (Server $c) { |
|
971 | - return new SCSSCacher( |
|
972 | - $c->getLogger(), |
|
973 | - $c->query(\OC\Files\AppData\Factory::class), |
|
974 | - $c->getURLGenerator(), |
|
975 | - $c->getConfig(), |
|
976 | - $c->getThemingDefaults(), |
|
977 | - \OC::$SERVERROOT, |
|
978 | - $this->getMemCacheFactory(), |
|
979 | - $c->query(IconsCacher::class), |
|
980 | - new TimeFactory() |
|
981 | - ); |
|
982 | - }); |
|
983 | - $this->registerService(JSCombiner::class, function (Server $c) { |
|
984 | - return new JSCombiner( |
|
985 | - $c->getAppDataDir('js'), |
|
986 | - $c->getURLGenerator(), |
|
987 | - $this->getMemCacheFactory(), |
|
988 | - $c->getSystemConfig(), |
|
989 | - $c->getLogger() |
|
990 | - ); |
|
991 | - }); |
|
992 | - $this->registerService(EventDispatcher::class, function () { |
|
993 | - return new EventDispatcher(); |
|
994 | - }); |
|
995 | - $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
996 | - $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
997 | - |
|
998 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
999 | - // FIXME: Instantiiated here due to cyclic dependency |
|
1000 | - $request = new Request( |
|
1001 | - [ |
|
1002 | - 'get' => $_GET, |
|
1003 | - 'post' => $_POST, |
|
1004 | - 'files' => $_FILES, |
|
1005 | - 'server' => $_SERVER, |
|
1006 | - 'env' => $_ENV, |
|
1007 | - 'cookies' => $_COOKIE, |
|
1008 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
1009 | - ? $_SERVER['REQUEST_METHOD'] |
|
1010 | - : null, |
|
1011 | - ], |
|
1012 | - $c->getSecureRandom(), |
|
1013 | - $c->getConfig() |
|
1014 | - ); |
|
1015 | - |
|
1016 | - return new CryptoWrapper( |
|
1017 | - $c->getConfig(), |
|
1018 | - $c->getCrypto(), |
|
1019 | - $c->getSecureRandom(), |
|
1020 | - $request |
|
1021 | - ); |
|
1022 | - }); |
|
1023 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
1024 | - $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
1025 | - |
|
1026 | - return new CsrfTokenManager( |
|
1027 | - $tokenGenerator, |
|
1028 | - $c->query(SessionStorage::class) |
|
1029 | - ); |
|
1030 | - }); |
|
1031 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
1032 | - return new SessionStorage($c->getSession()); |
|
1033 | - }); |
|
1034 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
1035 | - return new ContentSecurityPolicyManager(); |
|
1036 | - }); |
|
1037 | - $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
1038 | - |
|
1039 | - $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) { |
|
1040 | - return new ContentSecurityPolicyNonceManager( |
|
1041 | - $c->getCsrfTokenManager(), |
|
1042 | - $c->getRequest() |
|
1043 | - ); |
|
1044 | - }); |
|
1045 | - |
|
1046 | - $this->registerService(\OCP\Share\IManager::class, function (Server $c) { |
|
1047 | - $config = $c->getConfig(); |
|
1048 | - $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class); |
|
1049 | - /** @var \OCP\Share\IProviderFactory $factory */ |
|
1050 | - $factory = new $factoryClass($this); |
|
1051 | - |
|
1052 | - $manager = new \OC\Share20\Manager( |
|
1053 | - $c->getLogger(), |
|
1054 | - $c->getConfig(), |
|
1055 | - $c->getSecureRandom(), |
|
1056 | - $c->getHasher(), |
|
1057 | - $c->getMountManager(), |
|
1058 | - $c->getGroupManager(), |
|
1059 | - $c->getL10N('lib'), |
|
1060 | - $c->getL10NFactory(), |
|
1061 | - $factory, |
|
1062 | - $c->getUserManager(), |
|
1063 | - $c->getLazyRootFolder(), |
|
1064 | - $c->getEventDispatcher(), |
|
1065 | - $c->getMailer(), |
|
1066 | - $c->getURLGenerator(), |
|
1067 | - $c->getThemingDefaults() |
|
1068 | - ); |
|
1069 | - |
|
1070 | - return $manager; |
|
1071 | - }); |
|
1072 | - $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
1073 | - |
|
1074 | - $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) { |
|
1075 | - $instance = new Collaboration\Collaborators\Search($c); |
|
1076 | - |
|
1077 | - // register default plugins |
|
1078 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]); |
|
1079 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]); |
|
1080 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]); |
|
1081 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]); |
|
1082 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]); |
|
1083 | - |
|
1084 | - return $instance; |
|
1085 | - }); |
|
1086 | - $this->registerAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class); |
|
1087 | - $this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class); |
|
1088 | - |
|
1089 | - $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); |
|
1090 | - |
|
1091 | - $this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class); |
|
1092 | - |
|
1093 | - $this->registerService('SettingsManager', function (Server $c) { |
|
1094 | - $manager = new \OC\Settings\Manager( |
|
1095 | - $c->getLogger(), |
|
1096 | - $c->getL10N('lib'), |
|
1097 | - $c->getURLGenerator(), |
|
1098 | - $c |
|
1099 | - ); |
|
1100 | - return $manager; |
|
1101 | - }); |
|
1102 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
1103 | - return new \OC\Files\AppData\Factory( |
|
1104 | - $c->getRootFolder(), |
|
1105 | - $c->getSystemConfig() |
|
1106 | - ); |
|
1107 | - }); |
|
1108 | - |
|
1109 | - $this->registerService('LockdownManager', function (Server $c) { |
|
1110 | - return new LockdownManager(function () use ($c) { |
|
1111 | - return $c->getSession(); |
|
1112 | - }); |
|
1113 | - }); |
|
1114 | - |
|
1115 | - $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
1116 | - return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
1117 | - }); |
|
1118 | - |
|
1119 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
1120 | - return new CloudIdManager(); |
|
1121 | - }); |
|
1122 | - |
|
1123 | - $this->registerService(IConfig::class, function (Server $c) { |
|
1124 | - return new GlobalScale\Config($c->getConfig()); |
|
1125 | - }); |
|
1126 | - |
|
1127 | - $this->registerService(ICloudFederationProviderManager::class, function (Server $c) { |
|
1128 | - return new CloudFederationProviderManager($c->getAppManager(), $c->getHTTPClientService(), $c->getCloudIdManager(), $c->getLogger()); |
|
1129 | - }); |
|
1130 | - |
|
1131 | - $this->registerService(ICloudFederationFactory::class, function (Server $c) { |
|
1132 | - return new CloudFederationFactory(); |
|
1133 | - }); |
|
1134 | - |
|
1135 | - $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
1136 | - $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
1137 | - |
|
1138 | - $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
1139 | - $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
1140 | - |
|
1141 | - $this->registerService(Defaults::class, function (Server $c) { |
|
1142 | - return new Defaults( |
|
1143 | - $c->getThemingDefaults() |
|
1144 | - ); |
|
1145 | - }); |
|
1146 | - $this->registerAlias('Defaults', \OCP\Defaults::class); |
|
1147 | - |
|
1148 | - $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { |
|
1149 | - return $c->query(\OCP\IUserSession::class)->getSession(); |
|
1150 | - }); |
|
1151 | - |
|
1152 | - $this->registerService(IShareHelper::class, function (Server $c) { |
|
1153 | - return new ShareHelper( |
|
1154 | - $c->query(\OCP\Share\IManager::class) |
|
1155 | - ); |
|
1156 | - }); |
|
1157 | - |
|
1158 | - $this->registerService(Installer::class, function(Server $c) { |
|
1159 | - return new Installer( |
|
1160 | - $c->getAppFetcher(), |
|
1161 | - $c->getHTTPClientService(), |
|
1162 | - $c->getTempManager(), |
|
1163 | - $c->getLogger(), |
|
1164 | - $c->getConfig() |
|
1165 | - ); |
|
1166 | - }); |
|
1167 | - |
|
1168 | - $this->registerService(IApiFactory::class, function(Server $c) { |
|
1169 | - return new ApiFactory($c->getHTTPClientService()); |
|
1170 | - }); |
|
1171 | - |
|
1172 | - $this->registerService(IInstanceFactory::class, function(Server $c) { |
|
1173 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
1174 | - return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService()); |
|
1175 | - }); |
|
1176 | - |
|
1177 | - $this->registerService(IContactsStore::class, function(Server $c) { |
|
1178 | - return new ContactsStore( |
|
1179 | - $c->getContactsManager(), |
|
1180 | - $c->getConfig(), |
|
1181 | - $c->getUserManager(), |
|
1182 | - $c->getGroupManager() |
|
1183 | - ); |
|
1184 | - }); |
|
1185 | - $this->registerAlias(IContactsStore::class, ContactsStore::class); |
|
1186 | - $this->registerAlias(IAccountManager::class, AccountManager::class); |
|
1187 | - |
|
1188 | - $this->registerService(IStorageFactory::class, function() { |
|
1189 | - return new StorageFactory(); |
|
1190 | - }); |
|
1191 | - |
|
1192 | - $this->registerAlias(IDashboardManager::class, DashboardManager::class); |
|
1193 | - $this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class); |
|
1194 | - |
|
1195 | - $this->registerService(\OC\Security\IdentityProof\Manager::class, function (Server $c) { |
|
1196 | - return new \OC\Security\IdentityProof\Manager( |
|
1197 | - $c->query(\OC\Files\AppData\Factory::class), |
|
1198 | - $c->getCrypto(), |
|
1199 | - $c->getConfig() |
|
1200 | - ); |
|
1201 | - }); |
|
1202 | - |
|
1203 | - $this->registerAlias(ISubAdmin::class, SubAdmin::class); |
|
1204 | - |
|
1205 | - $this->registerAlias(IInitialStateService::class, InitialStateService::class); |
|
1206 | - |
|
1207 | - $this->connectDispatcher(); |
|
1208 | - } |
|
1209 | - |
|
1210 | - /** |
|
1211 | - * @return \OCP\Calendar\IManager |
|
1212 | - */ |
|
1213 | - public function getCalendarManager() { |
|
1214 | - return $this->query('CalendarManager'); |
|
1215 | - } |
|
1216 | - |
|
1217 | - /** |
|
1218 | - * @return \OCP\Calendar\Resource\IManager |
|
1219 | - */ |
|
1220 | - public function getCalendarResourceBackendManager() { |
|
1221 | - return $this->query('CalendarResourceBackendManager'); |
|
1222 | - } |
|
1223 | - |
|
1224 | - /** |
|
1225 | - * @return \OCP\Calendar\Room\IManager |
|
1226 | - */ |
|
1227 | - public function getCalendarRoomBackendManager() { |
|
1228 | - return $this->query('CalendarRoomBackendManager'); |
|
1229 | - } |
|
1230 | - |
|
1231 | - private function connectDispatcher() { |
|
1232 | - $dispatcher = $this->getEventDispatcher(); |
|
1233 | - |
|
1234 | - // Delete avatar on user deletion |
|
1235 | - $dispatcher->addListener('OCP\IUser::preDelete', function(GenericEvent $e) { |
|
1236 | - $logger = $this->getLogger(); |
|
1237 | - $manager = $this->getAvatarManager(); |
|
1238 | - /** @var IUser $user */ |
|
1239 | - $user = $e->getSubject(); |
|
1240 | - |
|
1241 | - try { |
|
1242 | - $avatar = $manager->getAvatar($user->getUID()); |
|
1243 | - $avatar->remove(); |
|
1244 | - } catch (NotFoundException $e) { |
|
1245 | - // no avatar to remove |
|
1246 | - } catch (\Exception $e) { |
|
1247 | - // Ignore exceptions |
|
1248 | - $logger->info('Could not cleanup avatar of ' . $user->getUID()); |
|
1249 | - } |
|
1250 | - }); |
|
1251 | - |
|
1252 | - $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { |
|
1253 | - $manager = $this->getAvatarManager(); |
|
1254 | - /** @var IUser $user */ |
|
1255 | - $user = $e->getSubject(); |
|
1256 | - $feature = $e->getArgument('feature'); |
|
1257 | - $oldValue = $e->getArgument('oldValue'); |
|
1258 | - $value = $e->getArgument('value'); |
|
1259 | - |
|
1260 | - // We only change the avatar on display name changes |
|
1261 | - if ($feature !== 'displayName') { |
|
1262 | - return; |
|
1263 | - } |
|
1264 | - |
|
1265 | - try { |
|
1266 | - $avatar = $manager->getAvatar($user->getUID()); |
|
1267 | - $avatar->userChanged($feature, $oldValue, $value); |
|
1268 | - } catch (NotFoundException $e) { |
|
1269 | - // no avatar to remove |
|
1270 | - } |
|
1271 | - }); |
|
1272 | - } |
|
1273 | - |
|
1274 | - /** |
|
1275 | - * @return \OCP\Contacts\IManager |
|
1276 | - */ |
|
1277 | - public function getContactsManager() { |
|
1278 | - return $this->query('ContactsManager'); |
|
1279 | - } |
|
1280 | - |
|
1281 | - /** |
|
1282 | - * @return \OC\Encryption\Manager |
|
1283 | - */ |
|
1284 | - public function getEncryptionManager() { |
|
1285 | - return $this->query('EncryptionManager'); |
|
1286 | - } |
|
1287 | - |
|
1288 | - /** |
|
1289 | - * @return \OC\Encryption\File |
|
1290 | - */ |
|
1291 | - public function getEncryptionFilesHelper() { |
|
1292 | - return $this->query('EncryptionFileHelper'); |
|
1293 | - } |
|
1294 | - |
|
1295 | - /** |
|
1296 | - * @return \OCP\Encryption\Keys\IStorage |
|
1297 | - */ |
|
1298 | - public function getEncryptionKeyStorage() { |
|
1299 | - return $this->query('EncryptionKeyStorage'); |
|
1300 | - } |
|
1301 | - |
|
1302 | - /** |
|
1303 | - * The current request object holding all information about the request |
|
1304 | - * currently being processed is returned from this method. |
|
1305 | - * In case the current execution was not initiated by a web request null is returned |
|
1306 | - * |
|
1307 | - * @return \OCP\IRequest |
|
1308 | - */ |
|
1309 | - public function getRequest() { |
|
1310 | - return $this->query('Request'); |
|
1311 | - } |
|
1312 | - |
|
1313 | - /** |
|
1314 | - * Returns the preview manager which can create preview images for a given file |
|
1315 | - * |
|
1316 | - * @return \OCP\IPreview |
|
1317 | - */ |
|
1318 | - public function getPreviewManager() { |
|
1319 | - return $this->query('PreviewManager'); |
|
1320 | - } |
|
1321 | - |
|
1322 | - /** |
|
1323 | - * Returns the tag manager which can get and set tags for different object types |
|
1324 | - * |
|
1325 | - * @see \OCP\ITagManager::load() |
|
1326 | - * @return \OCP\ITagManager |
|
1327 | - */ |
|
1328 | - public function getTagManager() { |
|
1329 | - return $this->query('TagManager'); |
|
1330 | - } |
|
1331 | - |
|
1332 | - /** |
|
1333 | - * Returns the system-tag manager |
|
1334 | - * |
|
1335 | - * @return \OCP\SystemTag\ISystemTagManager |
|
1336 | - * |
|
1337 | - * @since 9.0.0 |
|
1338 | - */ |
|
1339 | - public function getSystemTagManager() { |
|
1340 | - return $this->query('SystemTagManager'); |
|
1341 | - } |
|
1342 | - |
|
1343 | - /** |
|
1344 | - * Returns the system-tag object mapper |
|
1345 | - * |
|
1346 | - * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
1347 | - * |
|
1348 | - * @since 9.0.0 |
|
1349 | - */ |
|
1350 | - public function getSystemTagObjectMapper() { |
|
1351 | - return $this->query('SystemTagObjectMapper'); |
|
1352 | - } |
|
1353 | - |
|
1354 | - /** |
|
1355 | - * Returns the avatar manager, used for avatar functionality |
|
1356 | - * |
|
1357 | - * @return \OCP\IAvatarManager |
|
1358 | - */ |
|
1359 | - public function getAvatarManager() { |
|
1360 | - return $this->query('AvatarManager'); |
|
1361 | - } |
|
1362 | - |
|
1363 | - /** |
|
1364 | - * Returns the root folder of ownCloud's data directory |
|
1365 | - * |
|
1366 | - * @return \OCP\Files\IRootFolder |
|
1367 | - */ |
|
1368 | - public function getRootFolder() { |
|
1369 | - return $this->query('LazyRootFolder'); |
|
1370 | - } |
|
1371 | - |
|
1372 | - /** |
|
1373 | - * Returns the root folder of ownCloud's data directory |
|
1374 | - * This is the lazy variant so this gets only initialized once it |
|
1375 | - * is actually used. |
|
1376 | - * |
|
1377 | - * @return \OCP\Files\IRootFolder |
|
1378 | - */ |
|
1379 | - public function getLazyRootFolder() { |
|
1380 | - return $this->query('LazyRootFolder'); |
|
1381 | - } |
|
1382 | - |
|
1383 | - /** |
|
1384 | - * Returns a view to ownCloud's files folder |
|
1385 | - * |
|
1386 | - * @param string $userId user ID |
|
1387 | - * @return \OCP\Files\Folder|null |
|
1388 | - */ |
|
1389 | - public function getUserFolder($userId = null) { |
|
1390 | - if ($userId === null) { |
|
1391 | - $user = $this->getUserSession()->getUser(); |
|
1392 | - if (!$user) { |
|
1393 | - return null; |
|
1394 | - } |
|
1395 | - $userId = $user->getUID(); |
|
1396 | - } |
|
1397 | - $root = $this->getRootFolder(); |
|
1398 | - return $root->getUserFolder($userId); |
|
1399 | - } |
|
1400 | - |
|
1401 | - /** |
|
1402 | - * Returns an app-specific view in ownClouds data directory |
|
1403 | - * |
|
1404 | - * @return \OCP\Files\Folder |
|
1405 | - * @deprecated since 9.2.0 use IAppData |
|
1406 | - */ |
|
1407 | - public function getAppFolder() { |
|
1408 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
1409 | - $root = $this->getRootFolder(); |
|
1410 | - if (!$root->nodeExists($dir)) { |
|
1411 | - $folder = $root->newFolder($dir); |
|
1412 | - } else { |
|
1413 | - $folder = $root->get($dir); |
|
1414 | - } |
|
1415 | - return $folder; |
|
1416 | - } |
|
1417 | - |
|
1418 | - /** |
|
1419 | - * @return \OC\User\Manager |
|
1420 | - */ |
|
1421 | - public function getUserManager() { |
|
1422 | - return $this->query('UserManager'); |
|
1423 | - } |
|
1424 | - |
|
1425 | - /** |
|
1426 | - * @return \OC\Group\Manager |
|
1427 | - */ |
|
1428 | - public function getGroupManager() { |
|
1429 | - return $this->query('GroupManager'); |
|
1430 | - } |
|
1431 | - |
|
1432 | - /** |
|
1433 | - * @return \OC\User\Session |
|
1434 | - */ |
|
1435 | - public function getUserSession() { |
|
1436 | - return $this->query('UserSession'); |
|
1437 | - } |
|
1438 | - |
|
1439 | - /** |
|
1440 | - * @return \OCP\ISession |
|
1441 | - */ |
|
1442 | - public function getSession() { |
|
1443 | - return $this->query('UserSession')->getSession(); |
|
1444 | - } |
|
1445 | - |
|
1446 | - /** |
|
1447 | - * @param \OCP\ISession $session |
|
1448 | - */ |
|
1449 | - public function setSession(\OCP\ISession $session) { |
|
1450 | - $this->query(SessionStorage::class)->setSession($session); |
|
1451 | - $this->query('UserSession')->setSession($session); |
|
1452 | - $this->query(Store::class)->setSession($session); |
|
1453 | - } |
|
1454 | - |
|
1455 | - /** |
|
1456 | - * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1457 | - */ |
|
1458 | - public function getTwoFactorAuthManager() { |
|
1459 | - return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1460 | - } |
|
1461 | - |
|
1462 | - /** |
|
1463 | - * @return \OC\NavigationManager |
|
1464 | - */ |
|
1465 | - public function getNavigationManager() { |
|
1466 | - return $this->query('NavigationManager'); |
|
1467 | - } |
|
1468 | - |
|
1469 | - /** |
|
1470 | - * @return \OCP\IConfig |
|
1471 | - */ |
|
1472 | - public function getConfig() { |
|
1473 | - return $this->query('AllConfig'); |
|
1474 | - } |
|
1475 | - |
|
1476 | - /** |
|
1477 | - * @return \OC\SystemConfig |
|
1478 | - */ |
|
1479 | - public function getSystemConfig() { |
|
1480 | - return $this->query('SystemConfig'); |
|
1481 | - } |
|
1482 | - |
|
1483 | - /** |
|
1484 | - * Returns the app config manager |
|
1485 | - * |
|
1486 | - * @return \OCP\IAppConfig |
|
1487 | - */ |
|
1488 | - public function getAppConfig() { |
|
1489 | - return $this->query('AppConfig'); |
|
1490 | - } |
|
1491 | - |
|
1492 | - /** |
|
1493 | - * @return \OCP\L10N\IFactory |
|
1494 | - */ |
|
1495 | - public function getL10NFactory() { |
|
1496 | - return $this->query('L10NFactory'); |
|
1497 | - } |
|
1498 | - |
|
1499 | - /** |
|
1500 | - * get an L10N instance |
|
1501 | - * |
|
1502 | - * @param string $app appid |
|
1503 | - * @param string $lang |
|
1504 | - * @return IL10N |
|
1505 | - */ |
|
1506 | - public function getL10N($app, $lang = null) { |
|
1507 | - return $this->getL10NFactory()->get($app, $lang); |
|
1508 | - } |
|
1509 | - |
|
1510 | - /** |
|
1511 | - * @return \OCP\IURLGenerator |
|
1512 | - */ |
|
1513 | - public function getURLGenerator() { |
|
1514 | - return $this->query('URLGenerator'); |
|
1515 | - } |
|
1516 | - |
|
1517 | - /** |
|
1518 | - * @return AppFetcher |
|
1519 | - */ |
|
1520 | - public function getAppFetcher() { |
|
1521 | - return $this->query(AppFetcher::class); |
|
1522 | - } |
|
1523 | - |
|
1524 | - /** |
|
1525 | - * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1526 | - * getMemCacheFactory() instead. |
|
1527 | - * |
|
1528 | - * @return \OCP\ICache |
|
1529 | - * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1530 | - */ |
|
1531 | - public function getCache() { |
|
1532 | - return $this->query('UserCache'); |
|
1533 | - } |
|
1534 | - |
|
1535 | - /** |
|
1536 | - * Returns an \OCP\CacheFactory instance |
|
1537 | - * |
|
1538 | - * @return \OCP\ICacheFactory |
|
1539 | - */ |
|
1540 | - public function getMemCacheFactory() { |
|
1541 | - return $this->query('MemCacheFactory'); |
|
1542 | - } |
|
1543 | - |
|
1544 | - /** |
|
1545 | - * Returns an \OC\RedisFactory instance |
|
1546 | - * |
|
1547 | - * @return \OC\RedisFactory |
|
1548 | - */ |
|
1549 | - public function getGetRedisFactory() { |
|
1550 | - return $this->query('RedisFactory'); |
|
1551 | - } |
|
1552 | - |
|
1553 | - |
|
1554 | - /** |
|
1555 | - * Returns the current session |
|
1556 | - * |
|
1557 | - * @return \OCP\IDBConnection |
|
1558 | - */ |
|
1559 | - public function getDatabaseConnection() { |
|
1560 | - return $this->query('DatabaseConnection'); |
|
1561 | - } |
|
1562 | - |
|
1563 | - /** |
|
1564 | - * Returns the activity manager |
|
1565 | - * |
|
1566 | - * @return \OCP\Activity\IManager |
|
1567 | - */ |
|
1568 | - public function getActivityManager() { |
|
1569 | - return $this->query('ActivityManager'); |
|
1570 | - } |
|
1571 | - |
|
1572 | - /** |
|
1573 | - * Returns an job list for controlling background jobs |
|
1574 | - * |
|
1575 | - * @return \OCP\BackgroundJob\IJobList |
|
1576 | - */ |
|
1577 | - public function getJobList() { |
|
1578 | - return $this->query('JobList'); |
|
1579 | - } |
|
1580 | - |
|
1581 | - /** |
|
1582 | - * Returns a logger instance |
|
1583 | - * |
|
1584 | - * @return \OCP\ILogger |
|
1585 | - */ |
|
1586 | - public function getLogger() { |
|
1587 | - return $this->query('Logger'); |
|
1588 | - } |
|
1589 | - |
|
1590 | - /** |
|
1591 | - * @return ILogFactory |
|
1592 | - * @throws \OCP\AppFramework\QueryException |
|
1593 | - */ |
|
1594 | - public function getLogFactory() { |
|
1595 | - return $this->query(ILogFactory::class); |
|
1596 | - } |
|
1597 | - |
|
1598 | - /** |
|
1599 | - * Returns a router for generating and matching urls |
|
1600 | - * |
|
1601 | - * @return \OCP\Route\IRouter |
|
1602 | - */ |
|
1603 | - public function getRouter() { |
|
1604 | - return $this->query('Router'); |
|
1605 | - } |
|
1606 | - |
|
1607 | - /** |
|
1608 | - * Returns a search instance |
|
1609 | - * |
|
1610 | - * @return \OCP\ISearch |
|
1611 | - */ |
|
1612 | - public function getSearch() { |
|
1613 | - return $this->query('Search'); |
|
1614 | - } |
|
1615 | - |
|
1616 | - /** |
|
1617 | - * Returns a SecureRandom instance |
|
1618 | - * |
|
1619 | - * @return \OCP\Security\ISecureRandom |
|
1620 | - */ |
|
1621 | - public function getSecureRandom() { |
|
1622 | - return $this->query('SecureRandom'); |
|
1623 | - } |
|
1624 | - |
|
1625 | - /** |
|
1626 | - * Returns a Crypto instance |
|
1627 | - * |
|
1628 | - * @return \OCP\Security\ICrypto |
|
1629 | - */ |
|
1630 | - public function getCrypto() { |
|
1631 | - return $this->query('Crypto'); |
|
1632 | - } |
|
1633 | - |
|
1634 | - /** |
|
1635 | - * Returns a Hasher instance |
|
1636 | - * |
|
1637 | - * @return \OCP\Security\IHasher |
|
1638 | - */ |
|
1639 | - public function getHasher() { |
|
1640 | - return $this->query('Hasher'); |
|
1641 | - } |
|
1642 | - |
|
1643 | - /** |
|
1644 | - * Returns a CredentialsManager instance |
|
1645 | - * |
|
1646 | - * @return \OCP\Security\ICredentialsManager |
|
1647 | - */ |
|
1648 | - public function getCredentialsManager() { |
|
1649 | - return $this->query('CredentialsManager'); |
|
1650 | - } |
|
1651 | - |
|
1652 | - /** |
|
1653 | - * Get the certificate manager for the user |
|
1654 | - * |
|
1655 | - * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1656 | - * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1657 | - */ |
|
1658 | - public function getCertificateManager($userId = '') { |
|
1659 | - if ($userId === '') { |
|
1660 | - $userSession = $this->getUserSession(); |
|
1661 | - $user = $userSession->getUser(); |
|
1662 | - if (is_null($user)) { |
|
1663 | - return null; |
|
1664 | - } |
|
1665 | - $userId = $user->getUID(); |
|
1666 | - } |
|
1667 | - return new CertificateManager( |
|
1668 | - $userId, |
|
1669 | - new View(), |
|
1670 | - $this->getConfig(), |
|
1671 | - $this->getLogger(), |
|
1672 | - $this->getSecureRandom() |
|
1673 | - ); |
|
1674 | - } |
|
1675 | - |
|
1676 | - /** |
|
1677 | - * Returns an instance of the HTTP client service |
|
1678 | - * |
|
1679 | - * @return \OCP\Http\Client\IClientService |
|
1680 | - */ |
|
1681 | - public function getHTTPClientService() { |
|
1682 | - return $this->query('HttpClientService'); |
|
1683 | - } |
|
1684 | - |
|
1685 | - /** |
|
1686 | - * Create a new event source |
|
1687 | - * |
|
1688 | - * @return \OCP\IEventSource |
|
1689 | - */ |
|
1690 | - public function createEventSource() { |
|
1691 | - return new \OC_EventSource(); |
|
1692 | - } |
|
1693 | - |
|
1694 | - /** |
|
1695 | - * Get the active event logger |
|
1696 | - * |
|
1697 | - * The returned logger only logs data when debug mode is enabled |
|
1698 | - * |
|
1699 | - * @return \OCP\Diagnostics\IEventLogger |
|
1700 | - */ |
|
1701 | - public function getEventLogger() { |
|
1702 | - return $this->query('EventLogger'); |
|
1703 | - } |
|
1704 | - |
|
1705 | - /** |
|
1706 | - * Get the active query logger |
|
1707 | - * |
|
1708 | - * The returned logger only logs data when debug mode is enabled |
|
1709 | - * |
|
1710 | - * @return \OCP\Diagnostics\IQueryLogger |
|
1711 | - */ |
|
1712 | - public function getQueryLogger() { |
|
1713 | - return $this->query('QueryLogger'); |
|
1714 | - } |
|
1715 | - |
|
1716 | - /** |
|
1717 | - * Get the manager for temporary files and folders |
|
1718 | - * |
|
1719 | - * @return \OCP\ITempManager |
|
1720 | - */ |
|
1721 | - public function getTempManager() { |
|
1722 | - return $this->query('TempManager'); |
|
1723 | - } |
|
1724 | - |
|
1725 | - /** |
|
1726 | - * Get the app manager |
|
1727 | - * |
|
1728 | - * @return \OCP\App\IAppManager |
|
1729 | - */ |
|
1730 | - public function getAppManager() { |
|
1731 | - return $this->query('AppManager'); |
|
1732 | - } |
|
1733 | - |
|
1734 | - /** |
|
1735 | - * Creates a new mailer |
|
1736 | - * |
|
1737 | - * @return \OCP\Mail\IMailer |
|
1738 | - */ |
|
1739 | - public function getMailer() { |
|
1740 | - return $this->query('Mailer'); |
|
1741 | - } |
|
1742 | - |
|
1743 | - /** |
|
1744 | - * Get the webroot |
|
1745 | - * |
|
1746 | - * @return string |
|
1747 | - */ |
|
1748 | - public function getWebRoot() { |
|
1749 | - return $this->webRoot; |
|
1750 | - } |
|
1751 | - |
|
1752 | - /** |
|
1753 | - * @return \OC\OCSClient |
|
1754 | - */ |
|
1755 | - public function getOcsClient() { |
|
1756 | - return $this->query('OcsClient'); |
|
1757 | - } |
|
1758 | - |
|
1759 | - /** |
|
1760 | - * @return \OCP\IDateTimeZone |
|
1761 | - */ |
|
1762 | - public function getDateTimeZone() { |
|
1763 | - return $this->query('DateTimeZone'); |
|
1764 | - } |
|
1765 | - |
|
1766 | - /** |
|
1767 | - * @return \OCP\IDateTimeFormatter |
|
1768 | - */ |
|
1769 | - public function getDateTimeFormatter() { |
|
1770 | - return $this->query('DateTimeFormatter'); |
|
1771 | - } |
|
1772 | - |
|
1773 | - /** |
|
1774 | - * @return \OCP\Files\Config\IMountProviderCollection |
|
1775 | - */ |
|
1776 | - public function getMountProviderCollection() { |
|
1777 | - return $this->query('MountConfigManager'); |
|
1778 | - } |
|
1779 | - |
|
1780 | - /** |
|
1781 | - * Get the IniWrapper |
|
1782 | - * |
|
1783 | - * @return IniGetWrapper |
|
1784 | - */ |
|
1785 | - public function getIniWrapper() { |
|
1786 | - return $this->query('IniWrapper'); |
|
1787 | - } |
|
1788 | - |
|
1789 | - /** |
|
1790 | - * @return \OCP\Command\IBus |
|
1791 | - */ |
|
1792 | - public function getCommandBus() { |
|
1793 | - return $this->query('AsyncCommandBus'); |
|
1794 | - } |
|
1795 | - |
|
1796 | - /** |
|
1797 | - * Get the trusted domain helper |
|
1798 | - * |
|
1799 | - * @return TrustedDomainHelper |
|
1800 | - */ |
|
1801 | - public function getTrustedDomainHelper() { |
|
1802 | - return $this->query('TrustedDomainHelper'); |
|
1803 | - } |
|
1804 | - |
|
1805 | - /** |
|
1806 | - * Get the locking provider |
|
1807 | - * |
|
1808 | - * @return \OCP\Lock\ILockingProvider |
|
1809 | - * @since 8.1.0 |
|
1810 | - */ |
|
1811 | - public function getLockingProvider() { |
|
1812 | - return $this->query('LockingProvider'); |
|
1813 | - } |
|
1814 | - |
|
1815 | - /** |
|
1816 | - * @return \OCP\Files\Mount\IMountManager |
|
1817 | - **/ |
|
1818 | - function getMountManager() { |
|
1819 | - return $this->query('MountManager'); |
|
1820 | - } |
|
1821 | - |
|
1822 | - /** @return \OCP\Files\Config\IUserMountCache */ |
|
1823 | - function getUserMountCache() { |
|
1824 | - return $this->query('UserMountCache'); |
|
1825 | - } |
|
1826 | - |
|
1827 | - /** |
|
1828 | - * Get the MimeTypeDetector |
|
1829 | - * |
|
1830 | - * @return \OCP\Files\IMimeTypeDetector |
|
1831 | - */ |
|
1832 | - public function getMimeTypeDetector() { |
|
1833 | - return $this->query('MimeTypeDetector'); |
|
1834 | - } |
|
1835 | - |
|
1836 | - /** |
|
1837 | - * Get the MimeTypeLoader |
|
1838 | - * |
|
1839 | - * @return \OCP\Files\IMimeTypeLoader |
|
1840 | - */ |
|
1841 | - public function getMimeTypeLoader() { |
|
1842 | - return $this->query('MimeTypeLoader'); |
|
1843 | - } |
|
1844 | - |
|
1845 | - /** |
|
1846 | - * Get the manager of all the capabilities |
|
1847 | - * |
|
1848 | - * @return \OC\CapabilitiesManager |
|
1849 | - */ |
|
1850 | - public function getCapabilitiesManager() { |
|
1851 | - return $this->query('CapabilitiesManager'); |
|
1852 | - } |
|
1853 | - |
|
1854 | - /** |
|
1855 | - * Get the EventDispatcher |
|
1856 | - * |
|
1857 | - * @return EventDispatcherInterface |
|
1858 | - * @since 8.2.0 |
|
1859 | - */ |
|
1860 | - public function getEventDispatcher() { |
|
1861 | - return $this->query('EventDispatcher'); |
|
1862 | - } |
|
1863 | - |
|
1864 | - /** |
|
1865 | - * Get the Notification Manager |
|
1866 | - * |
|
1867 | - * @return \OCP\Notification\IManager |
|
1868 | - * @since 8.2.0 |
|
1869 | - */ |
|
1870 | - public function getNotificationManager() { |
|
1871 | - return $this->query('NotificationManager'); |
|
1872 | - } |
|
1873 | - |
|
1874 | - /** |
|
1875 | - * @return \OCP\Comments\ICommentsManager |
|
1876 | - */ |
|
1877 | - public function getCommentsManager() { |
|
1878 | - return $this->query('CommentsManager'); |
|
1879 | - } |
|
1880 | - |
|
1881 | - /** |
|
1882 | - * @return \OCA\Theming\ThemingDefaults |
|
1883 | - */ |
|
1884 | - public function getThemingDefaults() { |
|
1885 | - return $this->query('ThemingDefaults'); |
|
1886 | - } |
|
1887 | - |
|
1888 | - /** |
|
1889 | - * @return \OC\IntegrityCheck\Checker |
|
1890 | - */ |
|
1891 | - public function getIntegrityCodeChecker() { |
|
1892 | - return $this->query('IntegrityCodeChecker'); |
|
1893 | - } |
|
1894 | - |
|
1895 | - /** |
|
1896 | - * @return \OC\Session\CryptoWrapper |
|
1897 | - */ |
|
1898 | - public function getSessionCryptoWrapper() { |
|
1899 | - return $this->query('CryptoWrapper'); |
|
1900 | - } |
|
1901 | - |
|
1902 | - /** |
|
1903 | - * @return CsrfTokenManager |
|
1904 | - */ |
|
1905 | - public function getCsrfTokenManager() { |
|
1906 | - return $this->query('CsrfTokenManager'); |
|
1907 | - } |
|
1908 | - |
|
1909 | - /** |
|
1910 | - * @return Throttler |
|
1911 | - */ |
|
1912 | - public function getBruteForceThrottler() { |
|
1913 | - return $this->query('Throttler'); |
|
1914 | - } |
|
1915 | - |
|
1916 | - /** |
|
1917 | - * @return IContentSecurityPolicyManager |
|
1918 | - */ |
|
1919 | - public function getContentSecurityPolicyManager() { |
|
1920 | - return $this->query('ContentSecurityPolicyManager'); |
|
1921 | - } |
|
1922 | - |
|
1923 | - /** |
|
1924 | - * @return ContentSecurityPolicyNonceManager |
|
1925 | - */ |
|
1926 | - public function getContentSecurityPolicyNonceManager() { |
|
1927 | - return $this->query('ContentSecurityPolicyNonceManager'); |
|
1928 | - } |
|
1929 | - |
|
1930 | - /** |
|
1931 | - * Not a public API as of 8.2, wait for 9.0 |
|
1932 | - * |
|
1933 | - * @return \OCA\Files_External\Service\BackendService |
|
1934 | - */ |
|
1935 | - public function getStoragesBackendService() { |
|
1936 | - return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1937 | - } |
|
1938 | - |
|
1939 | - /** |
|
1940 | - * Not a public API as of 8.2, wait for 9.0 |
|
1941 | - * |
|
1942 | - * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1943 | - */ |
|
1944 | - public function getGlobalStoragesService() { |
|
1945 | - return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1946 | - } |
|
1947 | - |
|
1948 | - /** |
|
1949 | - * Not a public API as of 8.2, wait for 9.0 |
|
1950 | - * |
|
1951 | - * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1952 | - */ |
|
1953 | - public function getUserGlobalStoragesService() { |
|
1954 | - return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1955 | - } |
|
1956 | - |
|
1957 | - /** |
|
1958 | - * Not a public API as of 8.2, wait for 9.0 |
|
1959 | - * |
|
1960 | - * @return \OCA\Files_External\Service\UserStoragesService |
|
1961 | - */ |
|
1962 | - public function getUserStoragesService() { |
|
1963 | - return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1964 | - } |
|
1965 | - |
|
1966 | - /** |
|
1967 | - * @return \OCP\Share\IManager |
|
1968 | - */ |
|
1969 | - public function getShareManager() { |
|
1970 | - return $this->query('ShareManager'); |
|
1971 | - } |
|
1972 | - |
|
1973 | - /** |
|
1974 | - * @return \OCP\Collaboration\Collaborators\ISearch |
|
1975 | - */ |
|
1976 | - public function getCollaboratorSearch() { |
|
1977 | - return $this->query('CollaboratorSearch'); |
|
1978 | - } |
|
1979 | - |
|
1980 | - /** |
|
1981 | - * @return \OCP\Collaboration\AutoComplete\IManager |
|
1982 | - */ |
|
1983 | - public function getAutoCompleteManager(){ |
|
1984 | - return $this->query(IManager::class); |
|
1985 | - } |
|
1986 | - |
|
1987 | - /** |
|
1988 | - * Returns the LDAP Provider |
|
1989 | - * |
|
1990 | - * @return \OCP\LDAP\ILDAPProvider |
|
1991 | - */ |
|
1992 | - public function getLDAPProvider() { |
|
1993 | - return $this->query('LDAPProvider'); |
|
1994 | - } |
|
1995 | - |
|
1996 | - /** |
|
1997 | - * @return \OCP\Settings\IManager |
|
1998 | - */ |
|
1999 | - public function getSettingsManager() { |
|
2000 | - return $this->query('SettingsManager'); |
|
2001 | - } |
|
2002 | - |
|
2003 | - /** |
|
2004 | - * @return \OCP\Files\IAppData |
|
2005 | - */ |
|
2006 | - public function getAppDataDir($app) { |
|
2007 | - /** @var \OC\Files\AppData\Factory $factory */ |
|
2008 | - $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
2009 | - return $factory->get($app); |
|
2010 | - } |
|
2011 | - |
|
2012 | - /** |
|
2013 | - * @return \OCP\Lockdown\ILockdownManager |
|
2014 | - */ |
|
2015 | - public function getLockdownManager() { |
|
2016 | - return $this->query('LockdownManager'); |
|
2017 | - } |
|
2018 | - |
|
2019 | - /** |
|
2020 | - * @return \OCP\Federation\ICloudIdManager |
|
2021 | - */ |
|
2022 | - public function getCloudIdManager() { |
|
2023 | - return $this->query(ICloudIdManager::class); |
|
2024 | - } |
|
2025 | - |
|
2026 | - /** |
|
2027 | - * @return \OCP\GlobalScale\IConfig |
|
2028 | - */ |
|
2029 | - public function getGlobalScaleConfig() { |
|
2030 | - return $this->query(IConfig::class); |
|
2031 | - } |
|
2032 | - |
|
2033 | - /** |
|
2034 | - * @return \OCP\Federation\ICloudFederationProviderManager |
|
2035 | - */ |
|
2036 | - public function getCloudFederationProviderManager() { |
|
2037 | - return $this->query(ICloudFederationProviderManager::class); |
|
2038 | - } |
|
2039 | - |
|
2040 | - /** |
|
2041 | - * @return \OCP\Remote\Api\IApiFactory |
|
2042 | - */ |
|
2043 | - public function getRemoteApiFactory() { |
|
2044 | - return $this->query(IApiFactory::class); |
|
2045 | - } |
|
2046 | - |
|
2047 | - /** |
|
2048 | - * @return \OCP\Federation\ICloudFederationFactory |
|
2049 | - */ |
|
2050 | - public function getCloudFederationFactory() { |
|
2051 | - return $this->query(ICloudFederationFactory::class); |
|
2052 | - } |
|
2053 | - |
|
2054 | - /** |
|
2055 | - * @return \OCP\Remote\IInstanceFactory |
|
2056 | - */ |
|
2057 | - public function getRemoteInstanceFactory() { |
|
2058 | - return $this->query(IInstanceFactory::class); |
|
2059 | - } |
|
2060 | - |
|
2061 | - /** |
|
2062 | - * @return IStorageFactory |
|
2063 | - */ |
|
2064 | - public function getStorageFactory() { |
|
2065 | - return $this->query(IStorageFactory::class); |
|
2066 | - } |
|
949 | + $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
950 | + if (isset($prefixes['OCA\\Theming\\'])) { |
|
951 | + $classExists = true; |
|
952 | + } else { |
|
953 | + $classExists = false; |
|
954 | + } |
|
955 | + |
|
956 | + if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) { |
|
957 | + return new ThemingDefaults( |
|
958 | + $c->getConfig(), |
|
959 | + $c->getL10N('theming'), |
|
960 | + $c->getURLGenerator(), |
|
961 | + $c->getMemCacheFactory(), |
|
962 | + new Util($c->getConfig(), $this->getAppManager(), $c->getAppDataDir('theming')), |
|
963 | + new ImageManager($c->getConfig(), $c->getAppDataDir('theming'), $c->getURLGenerator(), $this->getMemCacheFactory(), $this->getLogger()), |
|
964 | + $c->getAppManager(), |
|
965 | + $c->getNavigationManager() |
|
966 | + ); |
|
967 | + } |
|
968 | + return new \OC_Defaults(); |
|
969 | + }); |
|
970 | + $this->registerService(SCSSCacher::class, function (Server $c) { |
|
971 | + return new SCSSCacher( |
|
972 | + $c->getLogger(), |
|
973 | + $c->query(\OC\Files\AppData\Factory::class), |
|
974 | + $c->getURLGenerator(), |
|
975 | + $c->getConfig(), |
|
976 | + $c->getThemingDefaults(), |
|
977 | + \OC::$SERVERROOT, |
|
978 | + $this->getMemCacheFactory(), |
|
979 | + $c->query(IconsCacher::class), |
|
980 | + new TimeFactory() |
|
981 | + ); |
|
982 | + }); |
|
983 | + $this->registerService(JSCombiner::class, function (Server $c) { |
|
984 | + return new JSCombiner( |
|
985 | + $c->getAppDataDir('js'), |
|
986 | + $c->getURLGenerator(), |
|
987 | + $this->getMemCacheFactory(), |
|
988 | + $c->getSystemConfig(), |
|
989 | + $c->getLogger() |
|
990 | + ); |
|
991 | + }); |
|
992 | + $this->registerService(EventDispatcher::class, function () { |
|
993 | + return new EventDispatcher(); |
|
994 | + }); |
|
995 | + $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
996 | + $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
997 | + |
|
998 | + $this->registerService('CryptoWrapper', function (Server $c) { |
|
999 | + // FIXME: Instantiiated here due to cyclic dependency |
|
1000 | + $request = new Request( |
|
1001 | + [ |
|
1002 | + 'get' => $_GET, |
|
1003 | + 'post' => $_POST, |
|
1004 | + 'files' => $_FILES, |
|
1005 | + 'server' => $_SERVER, |
|
1006 | + 'env' => $_ENV, |
|
1007 | + 'cookies' => $_COOKIE, |
|
1008 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
1009 | + ? $_SERVER['REQUEST_METHOD'] |
|
1010 | + : null, |
|
1011 | + ], |
|
1012 | + $c->getSecureRandom(), |
|
1013 | + $c->getConfig() |
|
1014 | + ); |
|
1015 | + |
|
1016 | + return new CryptoWrapper( |
|
1017 | + $c->getConfig(), |
|
1018 | + $c->getCrypto(), |
|
1019 | + $c->getSecureRandom(), |
|
1020 | + $request |
|
1021 | + ); |
|
1022 | + }); |
|
1023 | + $this->registerService('CsrfTokenManager', function (Server $c) { |
|
1024 | + $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
1025 | + |
|
1026 | + return new CsrfTokenManager( |
|
1027 | + $tokenGenerator, |
|
1028 | + $c->query(SessionStorage::class) |
|
1029 | + ); |
|
1030 | + }); |
|
1031 | + $this->registerService(SessionStorage::class, function (Server $c) { |
|
1032 | + return new SessionStorage($c->getSession()); |
|
1033 | + }); |
|
1034 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
1035 | + return new ContentSecurityPolicyManager(); |
|
1036 | + }); |
|
1037 | + $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
1038 | + |
|
1039 | + $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) { |
|
1040 | + return new ContentSecurityPolicyNonceManager( |
|
1041 | + $c->getCsrfTokenManager(), |
|
1042 | + $c->getRequest() |
|
1043 | + ); |
|
1044 | + }); |
|
1045 | + |
|
1046 | + $this->registerService(\OCP\Share\IManager::class, function (Server $c) { |
|
1047 | + $config = $c->getConfig(); |
|
1048 | + $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class); |
|
1049 | + /** @var \OCP\Share\IProviderFactory $factory */ |
|
1050 | + $factory = new $factoryClass($this); |
|
1051 | + |
|
1052 | + $manager = new \OC\Share20\Manager( |
|
1053 | + $c->getLogger(), |
|
1054 | + $c->getConfig(), |
|
1055 | + $c->getSecureRandom(), |
|
1056 | + $c->getHasher(), |
|
1057 | + $c->getMountManager(), |
|
1058 | + $c->getGroupManager(), |
|
1059 | + $c->getL10N('lib'), |
|
1060 | + $c->getL10NFactory(), |
|
1061 | + $factory, |
|
1062 | + $c->getUserManager(), |
|
1063 | + $c->getLazyRootFolder(), |
|
1064 | + $c->getEventDispatcher(), |
|
1065 | + $c->getMailer(), |
|
1066 | + $c->getURLGenerator(), |
|
1067 | + $c->getThemingDefaults() |
|
1068 | + ); |
|
1069 | + |
|
1070 | + return $manager; |
|
1071 | + }); |
|
1072 | + $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
1073 | + |
|
1074 | + $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) { |
|
1075 | + $instance = new Collaboration\Collaborators\Search($c); |
|
1076 | + |
|
1077 | + // register default plugins |
|
1078 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]); |
|
1079 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]); |
|
1080 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]); |
|
1081 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]); |
|
1082 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]); |
|
1083 | + |
|
1084 | + return $instance; |
|
1085 | + }); |
|
1086 | + $this->registerAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class); |
|
1087 | + $this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class); |
|
1088 | + |
|
1089 | + $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); |
|
1090 | + |
|
1091 | + $this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class); |
|
1092 | + |
|
1093 | + $this->registerService('SettingsManager', function (Server $c) { |
|
1094 | + $manager = new \OC\Settings\Manager( |
|
1095 | + $c->getLogger(), |
|
1096 | + $c->getL10N('lib'), |
|
1097 | + $c->getURLGenerator(), |
|
1098 | + $c |
|
1099 | + ); |
|
1100 | + return $manager; |
|
1101 | + }); |
|
1102 | + $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
1103 | + return new \OC\Files\AppData\Factory( |
|
1104 | + $c->getRootFolder(), |
|
1105 | + $c->getSystemConfig() |
|
1106 | + ); |
|
1107 | + }); |
|
1108 | + |
|
1109 | + $this->registerService('LockdownManager', function (Server $c) { |
|
1110 | + return new LockdownManager(function () use ($c) { |
|
1111 | + return $c->getSession(); |
|
1112 | + }); |
|
1113 | + }); |
|
1114 | + |
|
1115 | + $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
1116 | + return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
1117 | + }); |
|
1118 | + |
|
1119 | + $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
1120 | + return new CloudIdManager(); |
|
1121 | + }); |
|
1122 | + |
|
1123 | + $this->registerService(IConfig::class, function (Server $c) { |
|
1124 | + return new GlobalScale\Config($c->getConfig()); |
|
1125 | + }); |
|
1126 | + |
|
1127 | + $this->registerService(ICloudFederationProviderManager::class, function (Server $c) { |
|
1128 | + return new CloudFederationProviderManager($c->getAppManager(), $c->getHTTPClientService(), $c->getCloudIdManager(), $c->getLogger()); |
|
1129 | + }); |
|
1130 | + |
|
1131 | + $this->registerService(ICloudFederationFactory::class, function (Server $c) { |
|
1132 | + return new CloudFederationFactory(); |
|
1133 | + }); |
|
1134 | + |
|
1135 | + $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
1136 | + $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
1137 | + |
|
1138 | + $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
1139 | + $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
1140 | + |
|
1141 | + $this->registerService(Defaults::class, function (Server $c) { |
|
1142 | + return new Defaults( |
|
1143 | + $c->getThemingDefaults() |
|
1144 | + ); |
|
1145 | + }); |
|
1146 | + $this->registerAlias('Defaults', \OCP\Defaults::class); |
|
1147 | + |
|
1148 | + $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { |
|
1149 | + return $c->query(\OCP\IUserSession::class)->getSession(); |
|
1150 | + }); |
|
1151 | + |
|
1152 | + $this->registerService(IShareHelper::class, function (Server $c) { |
|
1153 | + return new ShareHelper( |
|
1154 | + $c->query(\OCP\Share\IManager::class) |
|
1155 | + ); |
|
1156 | + }); |
|
1157 | + |
|
1158 | + $this->registerService(Installer::class, function(Server $c) { |
|
1159 | + return new Installer( |
|
1160 | + $c->getAppFetcher(), |
|
1161 | + $c->getHTTPClientService(), |
|
1162 | + $c->getTempManager(), |
|
1163 | + $c->getLogger(), |
|
1164 | + $c->getConfig() |
|
1165 | + ); |
|
1166 | + }); |
|
1167 | + |
|
1168 | + $this->registerService(IApiFactory::class, function(Server $c) { |
|
1169 | + return new ApiFactory($c->getHTTPClientService()); |
|
1170 | + }); |
|
1171 | + |
|
1172 | + $this->registerService(IInstanceFactory::class, function(Server $c) { |
|
1173 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
1174 | + return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService()); |
|
1175 | + }); |
|
1176 | + |
|
1177 | + $this->registerService(IContactsStore::class, function(Server $c) { |
|
1178 | + return new ContactsStore( |
|
1179 | + $c->getContactsManager(), |
|
1180 | + $c->getConfig(), |
|
1181 | + $c->getUserManager(), |
|
1182 | + $c->getGroupManager() |
|
1183 | + ); |
|
1184 | + }); |
|
1185 | + $this->registerAlias(IContactsStore::class, ContactsStore::class); |
|
1186 | + $this->registerAlias(IAccountManager::class, AccountManager::class); |
|
1187 | + |
|
1188 | + $this->registerService(IStorageFactory::class, function() { |
|
1189 | + return new StorageFactory(); |
|
1190 | + }); |
|
1191 | + |
|
1192 | + $this->registerAlias(IDashboardManager::class, DashboardManager::class); |
|
1193 | + $this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class); |
|
1194 | + |
|
1195 | + $this->registerService(\OC\Security\IdentityProof\Manager::class, function (Server $c) { |
|
1196 | + return new \OC\Security\IdentityProof\Manager( |
|
1197 | + $c->query(\OC\Files\AppData\Factory::class), |
|
1198 | + $c->getCrypto(), |
|
1199 | + $c->getConfig() |
|
1200 | + ); |
|
1201 | + }); |
|
1202 | + |
|
1203 | + $this->registerAlias(ISubAdmin::class, SubAdmin::class); |
|
1204 | + |
|
1205 | + $this->registerAlias(IInitialStateService::class, InitialStateService::class); |
|
1206 | + |
|
1207 | + $this->connectDispatcher(); |
|
1208 | + } |
|
1209 | + |
|
1210 | + /** |
|
1211 | + * @return \OCP\Calendar\IManager |
|
1212 | + */ |
|
1213 | + public function getCalendarManager() { |
|
1214 | + return $this->query('CalendarManager'); |
|
1215 | + } |
|
1216 | + |
|
1217 | + /** |
|
1218 | + * @return \OCP\Calendar\Resource\IManager |
|
1219 | + */ |
|
1220 | + public function getCalendarResourceBackendManager() { |
|
1221 | + return $this->query('CalendarResourceBackendManager'); |
|
1222 | + } |
|
1223 | + |
|
1224 | + /** |
|
1225 | + * @return \OCP\Calendar\Room\IManager |
|
1226 | + */ |
|
1227 | + public function getCalendarRoomBackendManager() { |
|
1228 | + return $this->query('CalendarRoomBackendManager'); |
|
1229 | + } |
|
1230 | + |
|
1231 | + private function connectDispatcher() { |
|
1232 | + $dispatcher = $this->getEventDispatcher(); |
|
1233 | + |
|
1234 | + // Delete avatar on user deletion |
|
1235 | + $dispatcher->addListener('OCP\IUser::preDelete', function(GenericEvent $e) { |
|
1236 | + $logger = $this->getLogger(); |
|
1237 | + $manager = $this->getAvatarManager(); |
|
1238 | + /** @var IUser $user */ |
|
1239 | + $user = $e->getSubject(); |
|
1240 | + |
|
1241 | + try { |
|
1242 | + $avatar = $manager->getAvatar($user->getUID()); |
|
1243 | + $avatar->remove(); |
|
1244 | + } catch (NotFoundException $e) { |
|
1245 | + // no avatar to remove |
|
1246 | + } catch (\Exception $e) { |
|
1247 | + // Ignore exceptions |
|
1248 | + $logger->info('Could not cleanup avatar of ' . $user->getUID()); |
|
1249 | + } |
|
1250 | + }); |
|
1251 | + |
|
1252 | + $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { |
|
1253 | + $manager = $this->getAvatarManager(); |
|
1254 | + /** @var IUser $user */ |
|
1255 | + $user = $e->getSubject(); |
|
1256 | + $feature = $e->getArgument('feature'); |
|
1257 | + $oldValue = $e->getArgument('oldValue'); |
|
1258 | + $value = $e->getArgument('value'); |
|
1259 | + |
|
1260 | + // We only change the avatar on display name changes |
|
1261 | + if ($feature !== 'displayName') { |
|
1262 | + return; |
|
1263 | + } |
|
1264 | + |
|
1265 | + try { |
|
1266 | + $avatar = $manager->getAvatar($user->getUID()); |
|
1267 | + $avatar->userChanged($feature, $oldValue, $value); |
|
1268 | + } catch (NotFoundException $e) { |
|
1269 | + // no avatar to remove |
|
1270 | + } |
|
1271 | + }); |
|
1272 | + } |
|
1273 | + |
|
1274 | + /** |
|
1275 | + * @return \OCP\Contacts\IManager |
|
1276 | + */ |
|
1277 | + public function getContactsManager() { |
|
1278 | + return $this->query('ContactsManager'); |
|
1279 | + } |
|
1280 | + |
|
1281 | + /** |
|
1282 | + * @return \OC\Encryption\Manager |
|
1283 | + */ |
|
1284 | + public function getEncryptionManager() { |
|
1285 | + return $this->query('EncryptionManager'); |
|
1286 | + } |
|
1287 | + |
|
1288 | + /** |
|
1289 | + * @return \OC\Encryption\File |
|
1290 | + */ |
|
1291 | + public function getEncryptionFilesHelper() { |
|
1292 | + return $this->query('EncryptionFileHelper'); |
|
1293 | + } |
|
1294 | + |
|
1295 | + /** |
|
1296 | + * @return \OCP\Encryption\Keys\IStorage |
|
1297 | + */ |
|
1298 | + public function getEncryptionKeyStorage() { |
|
1299 | + return $this->query('EncryptionKeyStorage'); |
|
1300 | + } |
|
1301 | + |
|
1302 | + /** |
|
1303 | + * The current request object holding all information about the request |
|
1304 | + * currently being processed is returned from this method. |
|
1305 | + * In case the current execution was not initiated by a web request null is returned |
|
1306 | + * |
|
1307 | + * @return \OCP\IRequest |
|
1308 | + */ |
|
1309 | + public function getRequest() { |
|
1310 | + return $this->query('Request'); |
|
1311 | + } |
|
1312 | + |
|
1313 | + /** |
|
1314 | + * Returns the preview manager which can create preview images for a given file |
|
1315 | + * |
|
1316 | + * @return \OCP\IPreview |
|
1317 | + */ |
|
1318 | + public function getPreviewManager() { |
|
1319 | + return $this->query('PreviewManager'); |
|
1320 | + } |
|
1321 | + |
|
1322 | + /** |
|
1323 | + * Returns the tag manager which can get and set tags for different object types |
|
1324 | + * |
|
1325 | + * @see \OCP\ITagManager::load() |
|
1326 | + * @return \OCP\ITagManager |
|
1327 | + */ |
|
1328 | + public function getTagManager() { |
|
1329 | + return $this->query('TagManager'); |
|
1330 | + } |
|
1331 | + |
|
1332 | + /** |
|
1333 | + * Returns the system-tag manager |
|
1334 | + * |
|
1335 | + * @return \OCP\SystemTag\ISystemTagManager |
|
1336 | + * |
|
1337 | + * @since 9.0.0 |
|
1338 | + */ |
|
1339 | + public function getSystemTagManager() { |
|
1340 | + return $this->query('SystemTagManager'); |
|
1341 | + } |
|
1342 | + |
|
1343 | + /** |
|
1344 | + * Returns the system-tag object mapper |
|
1345 | + * |
|
1346 | + * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
1347 | + * |
|
1348 | + * @since 9.0.0 |
|
1349 | + */ |
|
1350 | + public function getSystemTagObjectMapper() { |
|
1351 | + return $this->query('SystemTagObjectMapper'); |
|
1352 | + } |
|
1353 | + |
|
1354 | + /** |
|
1355 | + * Returns the avatar manager, used for avatar functionality |
|
1356 | + * |
|
1357 | + * @return \OCP\IAvatarManager |
|
1358 | + */ |
|
1359 | + public function getAvatarManager() { |
|
1360 | + return $this->query('AvatarManager'); |
|
1361 | + } |
|
1362 | + |
|
1363 | + /** |
|
1364 | + * Returns the root folder of ownCloud's data directory |
|
1365 | + * |
|
1366 | + * @return \OCP\Files\IRootFolder |
|
1367 | + */ |
|
1368 | + public function getRootFolder() { |
|
1369 | + return $this->query('LazyRootFolder'); |
|
1370 | + } |
|
1371 | + |
|
1372 | + /** |
|
1373 | + * Returns the root folder of ownCloud's data directory |
|
1374 | + * This is the lazy variant so this gets only initialized once it |
|
1375 | + * is actually used. |
|
1376 | + * |
|
1377 | + * @return \OCP\Files\IRootFolder |
|
1378 | + */ |
|
1379 | + public function getLazyRootFolder() { |
|
1380 | + return $this->query('LazyRootFolder'); |
|
1381 | + } |
|
1382 | + |
|
1383 | + /** |
|
1384 | + * Returns a view to ownCloud's files folder |
|
1385 | + * |
|
1386 | + * @param string $userId user ID |
|
1387 | + * @return \OCP\Files\Folder|null |
|
1388 | + */ |
|
1389 | + public function getUserFolder($userId = null) { |
|
1390 | + if ($userId === null) { |
|
1391 | + $user = $this->getUserSession()->getUser(); |
|
1392 | + if (!$user) { |
|
1393 | + return null; |
|
1394 | + } |
|
1395 | + $userId = $user->getUID(); |
|
1396 | + } |
|
1397 | + $root = $this->getRootFolder(); |
|
1398 | + return $root->getUserFolder($userId); |
|
1399 | + } |
|
1400 | + |
|
1401 | + /** |
|
1402 | + * Returns an app-specific view in ownClouds data directory |
|
1403 | + * |
|
1404 | + * @return \OCP\Files\Folder |
|
1405 | + * @deprecated since 9.2.0 use IAppData |
|
1406 | + */ |
|
1407 | + public function getAppFolder() { |
|
1408 | + $dir = '/' . \OC_App::getCurrentApp(); |
|
1409 | + $root = $this->getRootFolder(); |
|
1410 | + if (!$root->nodeExists($dir)) { |
|
1411 | + $folder = $root->newFolder($dir); |
|
1412 | + } else { |
|
1413 | + $folder = $root->get($dir); |
|
1414 | + } |
|
1415 | + return $folder; |
|
1416 | + } |
|
1417 | + |
|
1418 | + /** |
|
1419 | + * @return \OC\User\Manager |
|
1420 | + */ |
|
1421 | + public function getUserManager() { |
|
1422 | + return $this->query('UserManager'); |
|
1423 | + } |
|
1424 | + |
|
1425 | + /** |
|
1426 | + * @return \OC\Group\Manager |
|
1427 | + */ |
|
1428 | + public function getGroupManager() { |
|
1429 | + return $this->query('GroupManager'); |
|
1430 | + } |
|
1431 | + |
|
1432 | + /** |
|
1433 | + * @return \OC\User\Session |
|
1434 | + */ |
|
1435 | + public function getUserSession() { |
|
1436 | + return $this->query('UserSession'); |
|
1437 | + } |
|
1438 | + |
|
1439 | + /** |
|
1440 | + * @return \OCP\ISession |
|
1441 | + */ |
|
1442 | + public function getSession() { |
|
1443 | + return $this->query('UserSession')->getSession(); |
|
1444 | + } |
|
1445 | + |
|
1446 | + /** |
|
1447 | + * @param \OCP\ISession $session |
|
1448 | + */ |
|
1449 | + public function setSession(\OCP\ISession $session) { |
|
1450 | + $this->query(SessionStorage::class)->setSession($session); |
|
1451 | + $this->query('UserSession')->setSession($session); |
|
1452 | + $this->query(Store::class)->setSession($session); |
|
1453 | + } |
|
1454 | + |
|
1455 | + /** |
|
1456 | + * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1457 | + */ |
|
1458 | + public function getTwoFactorAuthManager() { |
|
1459 | + return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1460 | + } |
|
1461 | + |
|
1462 | + /** |
|
1463 | + * @return \OC\NavigationManager |
|
1464 | + */ |
|
1465 | + public function getNavigationManager() { |
|
1466 | + return $this->query('NavigationManager'); |
|
1467 | + } |
|
1468 | + |
|
1469 | + /** |
|
1470 | + * @return \OCP\IConfig |
|
1471 | + */ |
|
1472 | + public function getConfig() { |
|
1473 | + return $this->query('AllConfig'); |
|
1474 | + } |
|
1475 | + |
|
1476 | + /** |
|
1477 | + * @return \OC\SystemConfig |
|
1478 | + */ |
|
1479 | + public function getSystemConfig() { |
|
1480 | + return $this->query('SystemConfig'); |
|
1481 | + } |
|
1482 | + |
|
1483 | + /** |
|
1484 | + * Returns the app config manager |
|
1485 | + * |
|
1486 | + * @return \OCP\IAppConfig |
|
1487 | + */ |
|
1488 | + public function getAppConfig() { |
|
1489 | + return $this->query('AppConfig'); |
|
1490 | + } |
|
1491 | + |
|
1492 | + /** |
|
1493 | + * @return \OCP\L10N\IFactory |
|
1494 | + */ |
|
1495 | + public function getL10NFactory() { |
|
1496 | + return $this->query('L10NFactory'); |
|
1497 | + } |
|
1498 | + |
|
1499 | + /** |
|
1500 | + * get an L10N instance |
|
1501 | + * |
|
1502 | + * @param string $app appid |
|
1503 | + * @param string $lang |
|
1504 | + * @return IL10N |
|
1505 | + */ |
|
1506 | + public function getL10N($app, $lang = null) { |
|
1507 | + return $this->getL10NFactory()->get($app, $lang); |
|
1508 | + } |
|
1509 | + |
|
1510 | + /** |
|
1511 | + * @return \OCP\IURLGenerator |
|
1512 | + */ |
|
1513 | + public function getURLGenerator() { |
|
1514 | + return $this->query('URLGenerator'); |
|
1515 | + } |
|
1516 | + |
|
1517 | + /** |
|
1518 | + * @return AppFetcher |
|
1519 | + */ |
|
1520 | + public function getAppFetcher() { |
|
1521 | + return $this->query(AppFetcher::class); |
|
1522 | + } |
|
1523 | + |
|
1524 | + /** |
|
1525 | + * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1526 | + * getMemCacheFactory() instead. |
|
1527 | + * |
|
1528 | + * @return \OCP\ICache |
|
1529 | + * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1530 | + */ |
|
1531 | + public function getCache() { |
|
1532 | + return $this->query('UserCache'); |
|
1533 | + } |
|
1534 | + |
|
1535 | + /** |
|
1536 | + * Returns an \OCP\CacheFactory instance |
|
1537 | + * |
|
1538 | + * @return \OCP\ICacheFactory |
|
1539 | + */ |
|
1540 | + public function getMemCacheFactory() { |
|
1541 | + return $this->query('MemCacheFactory'); |
|
1542 | + } |
|
1543 | + |
|
1544 | + /** |
|
1545 | + * Returns an \OC\RedisFactory instance |
|
1546 | + * |
|
1547 | + * @return \OC\RedisFactory |
|
1548 | + */ |
|
1549 | + public function getGetRedisFactory() { |
|
1550 | + return $this->query('RedisFactory'); |
|
1551 | + } |
|
1552 | + |
|
1553 | + |
|
1554 | + /** |
|
1555 | + * Returns the current session |
|
1556 | + * |
|
1557 | + * @return \OCP\IDBConnection |
|
1558 | + */ |
|
1559 | + public function getDatabaseConnection() { |
|
1560 | + return $this->query('DatabaseConnection'); |
|
1561 | + } |
|
1562 | + |
|
1563 | + /** |
|
1564 | + * Returns the activity manager |
|
1565 | + * |
|
1566 | + * @return \OCP\Activity\IManager |
|
1567 | + */ |
|
1568 | + public function getActivityManager() { |
|
1569 | + return $this->query('ActivityManager'); |
|
1570 | + } |
|
1571 | + |
|
1572 | + /** |
|
1573 | + * Returns an job list for controlling background jobs |
|
1574 | + * |
|
1575 | + * @return \OCP\BackgroundJob\IJobList |
|
1576 | + */ |
|
1577 | + public function getJobList() { |
|
1578 | + return $this->query('JobList'); |
|
1579 | + } |
|
1580 | + |
|
1581 | + /** |
|
1582 | + * Returns a logger instance |
|
1583 | + * |
|
1584 | + * @return \OCP\ILogger |
|
1585 | + */ |
|
1586 | + public function getLogger() { |
|
1587 | + return $this->query('Logger'); |
|
1588 | + } |
|
1589 | + |
|
1590 | + /** |
|
1591 | + * @return ILogFactory |
|
1592 | + * @throws \OCP\AppFramework\QueryException |
|
1593 | + */ |
|
1594 | + public function getLogFactory() { |
|
1595 | + return $this->query(ILogFactory::class); |
|
1596 | + } |
|
1597 | + |
|
1598 | + /** |
|
1599 | + * Returns a router for generating and matching urls |
|
1600 | + * |
|
1601 | + * @return \OCP\Route\IRouter |
|
1602 | + */ |
|
1603 | + public function getRouter() { |
|
1604 | + return $this->query('Router'); |
|
1605 | + } |
|
1606 | + |
|
1607 | + /** |
|
1608 | + * Returns a search instance |
|
1609 | + * |
|
1610 | + * @return \OCP\ISearch |
|
1611 | + */ |
|
1612 | + public function getSearch() { |
|
1613 | + return $this->query('Search'); |
|
1614 | + } |
|
1615 | + |
|
1616 | + /** |
|
1617 | + * Returns a SecureRandom instance |
|
1618 | + * |
|
1619 | + * @return \OCP\Security\ISecureRandom |
|
1620 | + */ |
|
1621 | + public function getSecureRandom() { |
|
1622 | + return $this->query('SecureRandom'); |
|
1623 | + } |
|
1624 | + |
|
1625 | + /** |
|
1626 | + * Returns a Crypto instance |
|
1627 | + * |
|
1628 | + * @return \OCP\Security\ICrypto |
|
1629 | + */ |
|
1630 | + public function getCrypto() { |
|
1631 | + return $this->query('Crypto'); |
|
1632 | + } |
|
1633 | + |
|
1634 | + /** |
|
1635 | + * Returns a Hasher instance |
|
1636 | + * |
|
1637 | + * @return \OCP\Security\IHasher |
|
1638 | + */ |
|
1639 | + public function getHasher() { |
|
1640 | + return $this->query('Hasher'); |
|
1641 | + } |
|
1642 | + |
|
1643 | + /** |
|
1644 | + * Returns a CredentialsManager instance |
|
1645 | + * |
|
1646 | + * @return \OCP\Security\ICredentialsManager |
|
1647 | + */ |
|
1648 | + public function getCredentialsManager() { |
|
1649 | + return $this->query('CredentialsManager'); |
|
1650 | + } |
|
1651 | + |
|
1652 | + /** |
|
1653 | + * Get the certificate manager for the user |
|
1654 | + * |
|
1655 | + * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1656 | + * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1657 | + */ |
|
1658 | + public function getCertificateManager($userId = '') { |
|
1659 | + if ($userId === '') { |
|
1660 | + $userSession = $this->getUserSession(); |
|
1661 | + $user = $userSession->getUser(); |
|
1662 | + if (is_null($user)) { |
|
1663 | + return null; |
|
1664 | + } |
|
1665 | + $userId = $user->getUID(); |
|
1666 | + } |
|
1667 | + return new CertificateManager( |
|
1668 | + $userId, |
|
1669 | + new View(), |
|
1670 | + $this->getConfig(), |
|
1671 | + $this->getLogger(), |
|
1672 | + $this->getSecureRandom() |
|
1673 | + ); |
|
1674 | + } |
|
1675 | + |
|
1676 | + /** |
|
1677 | + * Returns an instance of the HTTP client service |
|
1678 | + * |
|
1679 | + * @return \OCP\Http\Client\IClientService |
|
1680 | + */ |
|
1681 | + public function getHTTPClientService() { |
|
1682 | + return $this->query('HttpClientService'); |
|
1683 | + } |
|
1684 | + |
|
1685 | + /** |
|
1686 | + * Create a new event source |
|
1687 | + * |
|
1688 | + * @return \OCP\IEventSource |
|
1689 | + */ |
|
1690 | + public function createEventSource() { |
|
1691 | + return new \OC_EventSource(); |
|
1692 | + } |
|
1693 | + |
|
1694 | + /** |
|
1695 | + * Get the active event logger |
|
1696 | + * |
|
1697 | + * The returned logger only logs data when debug mode is enabled |
|
1698 | + * |
|
1699 | + * @return \OCP\Diagnostics\IEventLogger |
|
1700 | + */ |
|
1701 | + public function getEventLogger() { |
|
1702 | + return $this->query('EventLogger'); |
|
1703 | + } |
|
1704 | + |
|
1705 | + /** |
|
1706 | + * Get the active query logger |
|
1707 | + * |
|
1708 | + * The returned logger only logs data when debug mode is enabled |
|
1709 | + * |
|
1710 | + * @return \OCP\Diagnostics\IQueryLogger |
|
1711 | + */ |
|
1712 | + public function getQueryLogger() { |
|
1713 | + return $this->query('QueryLogger'); |
|
1714 | + } |
|
1715 | + |
|
1716 | + /** |
|
1717 | + * Get the manager for temporary files and folders |
|
1718 | + * |
|
1719 | + * @return \OCP\ITempManager |
|
1720 | + */ |
|
1721 | + public function getTempManager() { |
|
1722 | + return $this->query('TempManager'); |
|
1723 | + } |
|
1724 | + |
|
1725 | + /** |
|
1726 | + * Get the app manager |
|
1727 | + * |
|
1728 | + * @return \OCP\App\IAppManager |
|
1729 | + */ |
|
1730 | + public function getAppManager() { |
|
1731 | + return $this->query('AppManager'); |
|
1732 | + } |
|
1733 | + |
|
1734 | + /** |
|
1735 | + * Creates a new mailer |
|
1736 | + * |
|
1737 | + * @return \OCP\Mail\IMailer |
|
1738 | + */ |
|
1739 | + public function getMailer() { |
|
1740 | + return $this->query('Mailer'); |
|
1741 | + } |
|
1742 | + |
|
1743 | + /** |
|
1744 | + * Get the webroot |
|
1745 | + * |
|
1746 | + * @return string |
|
1747 | + */ |
|
1748 | + public function getWebRoot() { |
|
1749 | + return $this->webRoot; |
|
1750 | + } |
|
1751 | + |
|
1752 | + /** |
|
1753 | + * @return \OC\OCSClient |
|
1754 | + */ |
|
1755 | + public function getOcsClient() { |
|
1756 | + return $this->query('OcsClient'); |
|
1757 | + } |
|
1758 | + |
|
1759 | + /** |
|
1760 | + * @return \OCP\IDateTimeZone |
|
1761 | + */ |
|
1762 | + public function getDateTimeZone() { |
|
1763 | + return $this->query('DateTimeZone'); |
|
1764 | + } |
|
1765 | + |
|
1766 | + /** |
|
1767 | + * @return \OCP\IDateTimeFormatter |
|
1768 | + */ |
|
1769 | + public function getDateTimeFormatter() { |
|
1770 | + return $this->query('DateTimeFormatter'); |
|
1771 | + } |
|
1772 | + |
|
1773 | + /** |
|
1774 | + * @return \OCP\Files\Config\IMountProviderCollection |
|
1775 | + */ |
|
1776 | + public function getMountProviderCollection() { |
|
1777 | + return $this->query('MountConfigManager'); |
|
1778 | + } |
|
1779 | + |
|
1780 | + /** |
|
1781 | + * Get the IniWrapper |
|
1782 | + * |
|
1783 | + * @return IniGetWrapper |
|
1784 | + */ |
|
1785 | + public function getIniWrapper() { |
|
1786 | + return $this->query('IniWrapper'); |
|
1787 | + } |
|
1788 | + |
|
1789 | + /** |
|
1790 | + * @return \OCP\Command\IBus |
|
1791 | + */ |
|
1792 | + public function getCommandBus() { |
|
1793 | + return $this->query('AsyncCommandBus'); |
|
1794 | + } |
|
1795 | + |
|
1796 | + /** |
|
1797 | + * Get the trusted domain helper |
|
1798 | + * |
|
1799 | + * @return TrustedDomainHelper |
|
1800 | + */ |
|
1801 | + public function getTrustedDomainHelper() { |
|
1802 | + return $this->query('TrustedDomainHelper'); |
|
1803 | + } |
|
1804 | + |
|
1805 | + /** |
|
1806 | + * Get the locking provider |
|
1807 | + * |
|
1808 | + * @return \OCP\Lock\ILockingProvider |
|
1809 | + * @since 8.1.0 |
|
1810 | + */ |
|
1811 | + public function getLockingProvider() { |
|
1812 | + return $this->query('LockingProvider'); |
|
1813 | + } |
|
1814 | + |
|
1815 | + /** |
|
1816 | + * @return \OCP\Files\Mount\IMountManager |
|
1817 | + **/ |
|
1818 | + function getMountManager() { |
|
1819 | + return $this->query('MountManager'); |
|
1820 | + } |
|
1821 | + |
|
1822 | + /** @return \OCP\Files\Config\IUserMountCache */ |
|
1823 | + function getUserMountCache() { |
|
1824 | + return $this->query('UserMountCache'); |
|
1825 | + } |
|
1826 | + |
|
1827 | + /** |
|
1828 | + * Get the MimeTypeDetector |
|
1829 | + * |
|
1830 | + * @return \OCP\Files\IMimeTypeDetector |
|
1831 | + */ |
|
1832 | + public function getMimeTypeDetector() { |
|
1833 | + return $this->query('MimeTypeDetector'); |
|
1834 | + } |
|
1835 | + |
|
1836 | + /** |
|
1837 | + * Get the MimeTypeLoader |
|
1838 | + * |
|
1839 | + * @return \OCP\Files\IMimeTypeLoader |
|
1840 | + */ |
|
1841 | + public function getMimeTypeLoader() { |
|
1842 | + return $this->query('MimeTypeLoader'); |
|
1843 | + } |
|
1844 | + |
|
1845 | + /** |
|
1846 | + * Get the manager of all the capabilities |
|
1847 | + * |
|
1848 | + * @return \OC\CapabilitiesManager |
|
1849 | + */ |
|
1850 | + public function getCapabilitiesManager() { |
|
1851 | + return $this->query('CapabilitiesManager'); |
|
1852 | + } |
|
1853 | + |
|
1854 | + /** |
|
1855 | + * Get the EventDispatcher |
|
1856 | + * |
|
1857 | + * @return EventDispatcherInterface |
|
1858 | + * @since 8.2.0 |
|
1859 | + */ |
|
1860 | + public function getEventDispatcher() { |
|
1861 | + return $this->query('EventDispatcher'); |
|
1862 | + } |
|
1863 | + |
|
1864 | + /** |
|
1865 | + * Get the Notification Manager |
|
1866 | + * |
|
1867 | + * @return \OCP\Notification\IManager |
|
1868 | + * @since 8.2.0 |
|
1869 | + */ |
|
1870 | + public function getNotificationManager() { |
|
1871 | + return $this->query('NotificationManager'); |
|
1872 | + } |
|
1873 | + |
|
1874 | + /** |
|
1875 | + * @return \OCP\Comments\ICommentsManager |
|
1876 | + */ |
|
1877 | + public function getCommentsManager() { |
|
1878 | + return $this->query('CommentsManager'); |
|
1879 | + } |
|
1880 | + |
|
1881 | + /** |
|
1882 | + * @return \OCA\Theming\ThemingDefaults |
|
1883 | + */ |
|
1884 | + public function getThemingDefaults() { |
|
1885 | + return $this->query('ThemingDefaults'); |
|
1886 | + } |
|
1887 | + |
|
1888 | + /** |
|
1889 | + * @return \OC\IntegrityCheck\Checker |
|
1890 | + */ |
|
1891 | + public function getIntegrityCodeChecker() { |
|
1892 | + return $this->query('IntegrityCodeChecker'); |
|
1893 | + } |
|
1894 | + |
|
1895 | + /** |
|
1896 | + * @return \OC\Session\CryptoWrapper |
|
1897 | + */ |
|
1898 | + public function getSessionCryptoWrapper() { |
|
1899 | + return $this->query('CryptoWrapper'); |
|
1900 | + } |
|
1901 | + |
|
1902 | + /** |
|
1903 | + * @return CsrfTokenManager |
|
1904 | + */ |
|
1905 | + public function getCsrfTokenManager() { |
|
1906 | + return $this->query('CsrfTokenManager'); |
|
1907 | + } |
|
1908 | + |
|
1909 | + /** |
|
1910 | + * @return Throttler |
|
1911 | + */ |
|
1912 | + public function getBruteForceThrottler() { |
|
1913 | + return $this->query('Throttler'); |
|
1914 | + } |
|
1915 | + |
|
1916 | + /** |
|
1917 | + * @return IContentSecurityPolicyManager |
|
1918 | + */ |
|
1919 | + public function getContentSecurityPolicyManager() { |
|
1920 | + return $this->query('ContentSecurityPolicyManager'); |
|
1921 | + } |
|
1922 | + |
|
1923 | + /** |
|
1924 | + * @return ContentSecurityPolicyNonceManager |
|
1925 | + */ |
|
1926 | + public function getContentSecurityPolicyNonceManager() { |
|
1927 | + return $this->query('ContentSecurityPolicyNonceManager'); |
|
1928 | + } |
|
1929 | + |
|
1930 | + /** |
|
1931 | + * Not a public API as of 8.2, wait for 9.0 |
|
1932 | + * |
|
1933 | + * @return \OCA\Files_External\Service\BackendService |
|
1934 | + */ |
|
1935 | + public function getStoragesBackendService() { |
|
1936 | + return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1937 | + } |
|
1938 | + |
|
1939 | + /** |
|
1940 | + * Not a public API as of 8.2, wait for 9.0 |
|
1941 | + * |
|
1942 | + * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1943 | + */ |
|
1944 | + public function getGlobalStoragesService() { |
|
1945 | + return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1946 | + } |
|
1947 | + |
|
1948 | + /** |
|
1949 | + * Not a public API as of 8.2, wait for 9.0 |
|
1950 | + * |
|
1951 | + * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1952 | + */ |
|
1953 | + public function getUserGlobalStoragesService() { |
|
1954 | + return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1955 | + } |
|
1956 | + |
|
1957 | + /** |
|
1958 | + * Not a public API as of 8.2, wait for 9.0 |
|
1959 | + * |
|
1960 | + * @return \OCA\Files_External\Service\UserStoragesService |
|
1961 | + */ |
|
1962 | + public function getUserStoragesService() { |
|
1963 | + return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1964 | + } |
|
1965 | + |
|
1966 | + /** |
|
1967 | + * @return \OCP\Share\IManager |
|
1968 | + */ |
|
1969 | + public function getShareManager() { |
|
1970 | + return $this->query('ShareManager'); |
|
1971 | + } |
|
1972 | + |
|
1973 | + /** |
|
1974 | + * @return \OCP\Collaboration\Collaborators\ISearch |
|
1975 | + */ |
|
1976 | + public function getCollaboratorSearch() { |
|
1977 | + return $this->query('CollaboratorSearch'); |
|
1978 | + } |
|
1979 | + |
|
1980 | + /** |
|
1981 | + * @return \OCP\Collaboration\AutoComplete\IManager |
|
1982 | + */ |
|
1983 | + public function getAutoCompleteManager(){ |
|
1984 | + return $this->query(IManager::class); |
|
1985 | + } |
|
1986 | + |
|
1987 | + /** |
|
1988 | + * Returns the LDAP Provider |
|
1989 | + * |
|
1990 | + * @return \OCP\LDAP\ILDAPProvider |
|
1991 | + */ |
|
1992 | + public function getLDAPProvider() { |
|
1993 | + return $this->query('LDAPProvider'); |
|
1994 | + } |
|
1995 | + |
|
1996 | + /** |
|
1997 | + * @return \OCP\Settings\IManager |
|
1998 | + */ |
|
1999 | + public function getSettingsManager() { |
|
2000 | + return $this->query('SettingsManager'); |
|
2001 | + } |
|
2002 | + |
|
2003 | + /** |
|
2004 | + * @return \OCP\Files\IAppData |
|
2005 | + */ |
|
2006 | + public function getAppDataDir($app) { |
|
2007 | + /** @var \OC\Files\AppData\Factory $factory */ |
|
2008 | + $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
2009 | + return $factory->get($app); |
|
2010 | + } |
|
2011 | + |
|
2012 | + /** |
|
2013 | + * @return \OCP\Lockdown\ILockdownManager |
|
2014 | + */ |
|
2015 | + public function getLockdownManager() { |
|
2016 | + return $this->query('LockdownManager'); |
|
2017 | + } |
|
2018 | + |
|
2019 | + /** |
|
2020 | + * @return \OCP\Federation\ICloudIdManager |
|
2021 | + */ |
|
2022 | + public function getCloudIdManager() { |
|
2023 | + return $this->query(ICloudIdManager::class); |
|
2024 | + } |
|
2025 | + |
|
2026 | + /** |
|
2027 | + * @return \OCP\GlobalScale\IConfig |
|
2028 | + */ |
|
2029 | + public function getGlobalScaleConfig() { |
|
2030 | + return $this->query(IConfig::class); |
|
2031 | + } |
|
2032 | + |
|
2033 | + /** |
|
2034 | + * @return \OCP\Federation\ICloudFederationProviderManager |
|
2035 | + */ |
|
2036 | + public function getCloudFederationProviderManager() { |
|
2037 | + return $this->query(ICloudFederationProviderManager::class); |
|
2038 | + } |
|
2039 | + |
|
2040 | + /** |
|
2041 | + * @return \OCP\Remote\Api\IApiFactory |
|
2042 | + */ |
|
2043 | + public function getRemoteApiFactory() { |
|
2044 | + return $this->query(IApiFactory::class); |
|
2045 | + } |
|
2046 | + |
|
2047 | + /** |
|
2048 | + * @return \OCP\Federation\ICloudFederationFactory |
|
2049 | + */ |
|
2050 | + public function getCloudFederationFactory() { |
|
2051 | + return $this->query(ICloudFederationFactory::class); |
|
2052 | + } |
|
2053 | + |
|
2054 | + /** |
|
2055 | + * @return \OCP\Remote\IInstanceFactory |
|
2056 | + */ |
|
2057 | + public function getRemoteInstanceFactory() { |
|
2058 | + return $this->query(IInstanceFactory::class); |
|
2059 | + } |
|
2060 | + |
|
2061 | + /** |
|
2062 | + * @return IStorageFactory |
|
2063 | + */ |
|
2064 | + public function getStorageFactory() { |
|
2065 | + return $this->query(IStorageFactory::class); |
|
2066 | + } |
|
2067 | 2067 | } |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | // To find out if we are running from CLI or not |
185 | 185 | $this->registerParameter('isCLI', \OC::$CLI); |
186 | 186 | |
187 | - $this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) { |
|
187 | + $this->registerService(\OCP\IServerContainer::class, function(IServerContainer $c) { |
|
188 | 188 | return $c; |
189 | 189 | }); |
190 | 190 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | $this->registerAlias(IActionFactory::class, ActionFactory::class); |
204 | 204 | |
205 | 205 | |
206 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
206 | + $this->registerService(\OCP\IPreview::class, function(Server $c) { |
|
207 | 207 | return new PreviewManager( |
208 | 208 | $c->getConfig(), |
209 | 209 | $c->getRootFolder(), |
@@ -214,13 +214,13 @@ discard block |
||
214 | 214 | }); |
215 | 215 | $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
216 | 216 | |
217 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
217 | + $this->registerService(\OC\Preview\Watcher::class, function(Server $c) { |
|
218 | 218 | return new \OC\Preview\Watcher( |
219 | 219 | $c->getAppDataDir('preview') |
220 | 220 | ); |
221 | 221 | }); |
222 | 222 | |
223 | - $this->registerService(\OCP\Encryption\IManager::class, function (Server $c) { |
|
223 | + $this->registerService(\OCP\Encryption\IManager::class, function(Server $c) { |
|
224 | 224 | $view = new View(); |
225 | 225 | $util = new Encryption\Util( |
226 | 226 | $view, |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | }); |
240 | 240 | $this->registerAlias('EncryptionManager', \OCP\Encryption\IManager::class); |
241 | 241 | |
242 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
242 | + $this->registerService('EncryptionFileHelper', function(Server $c) { |
|
243 | 243 | $util = new Encryption\Util( |
244 | 244 | new View(), |
245 | 245 | $c->getUserManager(), |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | ); |
254 | 254 | }); |
255 | 255 | |
256 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
256 | + $this->registerService('EncryptionKeyStorage', function(Server $c) { |
|
257 | 257 | $view = new View(); |
258 | 258 | $util = new Encryption\Util( |
259 | 259 | $view, |
@@ -264,30 +264,30 @@ discard block |
||
264 | 264 | |
265 | 265 | return new Encryption\Keys\Storage($view, $util); |
266 | 266 | }); |
267 | - $this->registerService('TagMapper', function (Server $c) { |
|
267 | + $this->registerService('TagMapper', function(Server $c) { |
|
268 | 268 | return new TagMapper($c->getDatabaseConnection()); |
269 | 269 | }); |
270 | 270 | |
271 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
271 | + $this->registerService(\OCP\ITagManager::class, function(Server $c) { |
|
272 | 272 | $tagMapper = $c->query('TagMapper'); |
273 | 273 | return new TagManager($tagMapper, $c->getUserSession()); |
274 | 274 | }); |
275 | 275 | $this->registerAlias('TagManager', \OCP\ITagManager::class); |
276 | 276 | |
277 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
277 | + $this->registerService('SystemTagManagerFactory', function(Server $c) { |
|
278 | 278 | $config = $c->getConfig(); |
279 | 279 | $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class); |
280 | 280 | return new $factoryClass($this); |
281 | 281 | }); |
282 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
282 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function(Server $c) { |
|
283 | 283 | return $c->query('SystemTagManagerFactory')->getManager(); |
284 | 284 | }); |
285 | 285 | $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
286 | 286 | |
287 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
287 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function(Server $c) { |
|
288 | 288 | return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
289 | 289 | }); |
290 | - $this->registerService('RootFolder', function (Server $c) { |
|
290 | + $this->registerService('RootFolder', function(Server $c) { |
|
291 | 291 | $manager = \OC\Files\Filesystem::getMountManager(null); |
292 | 292 | $view = new View(); |
293 | 293 | $root = new Root( |
@@ -308,37 +308,37 @@ discard block |
||
308 | 308 | }); |
309 | 309 | $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
310 | 310 | |
311 | - $this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) { |
|
312 | - return new LazyRoot(function () use ($c) { |
|
311 | + $this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) { |
|
312 | + return new LazyRoot(function() use ($c) { |
|
313 | 313 | return $c->query('RootFolder'); |
314 | 314 | }); |
315 | 315 | }); |
316 | 316 | $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
317 | 317 | |
318 | - $this->registerService(\OC\User\Manager::class, function (Server $c) { |
|
318 | + $this->registerService(\OC\User\Manager::class, function(Server $c) { |
|
319 | 319 | return new \OC\User\Manager($c->getConfig(), $c->getEventDispatcher()); |
320 | 320 | }); |
321 | 321 | $this->registerAlias('UserManager', \OC\User\Manager::class); |
322 | 322 | $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); |
323 | 323 | |
324 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
324 | + $this->registerService(\OCP\IGroupManager::class, function(Server $c) { |
|
325 | 325 | $groupManager = new \OC\Group\Manager($this->getUserManager(), $c->getEventDispatcher(), $this->getLogger()); |
326 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
326 | + $groupManager->listen('\OC\Group', 'preCreate', function($gid) { |
|
327 | 327 | \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
328 | 328 | }); |
329 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
329 | + $groupManager->listen('\OC\Group', 'postCreate', function(\OC\Group\Group $gid) { |
|
330 | 330 | \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
331 | 331 | }); |
332 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
332 | + $groupManager->listen('\OC\Group', 'preDelete', function(\OC\Group\Group $group) { |
|
333 | 333 | \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
334 | 334 | }); |
335 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
335 | + $groupManager->listen('\OC\Group', 'postDelete', function(\OC\Group\Group $group) { |
|
336 | 336 | \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
337 | 337 | }); |
338 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
338 | + $groupManager->listen('\OC\Group', 'preAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
339 | 339 | \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
340 | 340 | }); |
341 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
341 | + $groupManager->listen('\OC\Group', 'postAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
342 | 342 | \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
343 | 343 | //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
344 | 344 | \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | }); |
348 | 348 | $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
349 | 349 | |
350 | - $this->registerService(Store::class, function (Server $c) { |
|
350 | + $this->registerService(Store::class, function(Server $c) { |
|
351 | 351 | $session = $c->getSession(); |
352 | 352 | if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
353 | 353 | $tokenProvider = $c->query(IProvider::class); |
@@ -358,13 +358,13 @@ discard block |
||
358 | 358 | return new Store($session, $logger, $tokenProvider); |
359 | 359 | }); |
360 | 360 | $this->registerAlias(IStore::class, Store::class); |
361 | - $this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) { |
|
361 | + $this->registerService(Authentication\Token\DefaultTokenMapper::class, function(Server $c) { |
|
362 | 362 | $dbConnection = $c->getDatabaseConnection(); |
363 | 363 | return new Authentication\Token\DefaultTokenMapper($dbConnection); |
364 | 364 | }); |
365 | 365 | $this->registerAlias(IProvider::class, Authentication\Token\Manager::class); |
366 | 366 | |
367 | - $this->registerService(\OC\User\Session::class, function (Server $c) { |
|
367 | + $this->registerService(\OC\User\Session::class, function(Server $c) { |
|
368 | 368 | $manager = $c->getUserManager(); |
369 | 369 | $session = new \OC\Session\Memory(''); |
370 | 370 | $timeFactory = new TimeFactory(); |
@@ -388,45 +388,45 @@ discard block |
||
388 | 388 | $c->getLockdownManager(), |
389 | 389 | $c->getLogger() |
390 | 390 | ); |
391 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
391 | + $userSession->listen('\OC\User', 'preCreateUser', function($uid, $password) { |
|
392 | 392 | \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
393 | 393 | }); |
394 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
394 | + $userSession->listen('\OC\User', 'postCreateUser', function($user, $password) { |
|
395 | 395 | /** @var $user \OC\User\User */ |
396 | 396 | \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
397 | 397 | }); |
398 | - $userSession->listen('\OC\User', 'preDelete', function ($user) use ($dispatcher) { |
|
398 | + $userSession->listen('\OC\User', 'preDelete', function($user) use ($dispatcher) { |
|
399 | 399 | /** @var $user \OC\User\User */ |
400 | 400 | \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
401 | 401 | $dispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); |
402 | 402 | }); |
403 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
403 | + $userSession->listen('\OC\User', 'postDelete', function($user) { |
|
404 | 404 | /** @var $user \OC\User\User */ |
405 | 405 | \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
406 | 406 | }); |
407 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
407 | + $userSession->listen('\OC\User', 'preSetPassword', function($user, $password, $recoveryPassword) { |
|
408 | 408 | /** @var $user \OC\User\User */ |
409 | 409 | \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
410 | 410 | }); |
411 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
411 | + $userSession->listen('\OC\User', 'postSetPassword', function($user, $password, $recoveryPassword) { |
|
412 | 412 | /** @var $user \OC\User\User */ |
413 | 413 | \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
414 | 414 | }); |
415 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
415 | + $userSession->listen('\OC\User', 'preLogin', function($uid, $password) { |
|
416 | 416 | \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
417 | 417 | }); |
418 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password, $isTokenLogin) { |
|
418 | + $userSession->listen('\OC\User', 'postLogin', function($user, $password, $isTokenLogin) { |
|
419 | 419 | /** @var $user \OC\User\User */ |
420 | 420 | \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'isTokenLogin' => $isTokenLogin)); |
421 | 421 | }); |
422 | - $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { |
|
422 | + $userSession->listen('\OC\User', 'postRememberedLogin', function($user, $password) { |
|
423 | 423 | /** @var $user \OC\User\User */ |
424 | 424 | \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
425 | 425 | }); |
426 | - $userSession->listen('\OC\User', 'logout', function () { |
|
426 | + $userSession->listen('\OC\User', 'logout', function() { |
|
427 | 427 | \OC_Hook::emit('OC_User', 'logout', array()); |
428 | 428 | }); |
429 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) { |
|
429 | + $userSession->listen('\OC\User', 'changeUser', function($user, $feature, $value, $oldValue) { |
|
430 | 430 | /** @var $user \OC\User\User */ |
431 | 431 | \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
432 | 432 | }); |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
441 | 441 | $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
442 | 442 | |
443 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
443 | + $this->registerService(\OC\AllConfig::class, function(Server $c) { |
|
444 | 444 | return new \OC\AllConfig( |
445 | 445 | $c->getSystemConfig() |
446 | 446 | ); |
@@ -448,17 +448,17 @@ discard block |
||
448 | 448 | $this->registerAlias('AllConfig', \OC\AllConfig::class); |
449 | 449 | $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
450 | 450 | |
451 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
451 | + $this->registerService('SystemConfig', function($c) use ($config) { |
|
452 | 452 | return new \OC\SystemConfig($config); |
453 | 453 | }); |
454 | 454 | |
455 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
455 | + $this->registerService(\OC\AppConfig::class, function(Server $c) { |
|
456 | 456 | return new \OC\AppConfig($c->getDatabaseConnection()); |
457 | 457 | }); |
458 | 458 | $this->registerAlias('AppConfig', \OC\AppConfig::class); |
459 | 459 | $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
460 | 460 | |
461 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
461 | + $this->registerService(\OCP\L10N\IFactory::class, function(Server $c) { |
|
462 | 462 | return new \OC\L10N\Factory( |
463 | 463 | $c->getConfig(), |
464 | 464 | $c->getRequest(), |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | }); |
469 | 469 | $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
470 | 470 | |
471 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
471 | + $this->registerService(\OCP\IURLGenerator::class, function(Server $c) { |
|
472 | 472 | $config = $c->getConfig(); |
473 | 473 | $cacheFactory = $c->getMemCacheFactory(); |
474 | 474 | $request = $c->getRequest(); |
@@ -483,12 +483,12 @@ discard block |
||
483 | 483 | $this->registerAlias('AppFetcher', AppFetcher::class); |
484 | 484 | $this->registerAlias('CategoryFetcher', CategoryFetcher::class); |
485 | 485 | |
486 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
486 | + $this->registerService(\OCP\ICache::class, function($c) { |
|
487 | 487 | return new Cache\File(); |
488 | 488 | }); |
489 | 489 | $this->registerAlias('UserCache', \OCP\ICache::class); |
490 | 490 | |
491 | - $this->registerService(Factory::class, function (Server $c) { |
|
491 | + $this->registerService(Factory::class, function(Server $c) { |
|
492 | 492 | |
493 | 493 | $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), |
494 | 494 | ArrayCache::class, |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | $version = implode(',', $v); |
504 | 504 | $instanceId = \OC_Util::getInstanceId(); |
505 | 505 | $path = \OC::$SERVERROOT; |
506 | - $prefix = md5($instanceId . '-' . $version . '-' . $path); |
|
506 | + $prefix = md5($instanceId.'-'.$version.'-'.$path); |
|
507 | 507 | return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
508 | 508 | $config->getSystemValue('memcache.local', null), |
509 | 509 | $config->getSystemValue('memcache.distributed', null), |
@@ -516,12 +516,12 @@ discard block |
||
516 | 516 | $this->registerAlias('MemCacheFactory', Factory::class); |
517 | 517 | $this->registerAlias(ICacheFactory::class, Factory::class); |
518 | 518 | |
519 | - $this->registerService('RedisFactory', function (Server $c) { |
|
519 | + $this->registerService('RedisFactory', function(Server $c) { |
|
520 | 520 | $systemConfig = $c->getSystemConfig(); |
521 | 521 | return new RedisFactory($systemConfig); |
522 | 522 | }); |
523 | 523 | |
524 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
524 | + $this->registerService(\OCP\Activity\IManager::class, function(Server $c) { |
|
525 | 525 | return new \OC\Activity\Manager( |
526 | 526 | $c->getRequest(), |
527 | 527 | $c->getUserSession(), |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | }); |
532 | 532 | $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
533 | 533 | |
534 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
534 | + $this->registerService(\OCP\Activity\IEventMerger::class, function(Server $c) { |
|
535 | 535 | return new \OC\Activity\EventMerger( |
536 | 536 | $c->getL10N('lib') |
537 | 537 | ); |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); |
554 | 554 | $this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class); |
555 | 555 | |
556 | - $this->registerService(\OC\Log::class, function (Server $c) { |
|
556 | + $this->registerService(\OC\Log::class, function(Server $c) { |
|
557 | 557 | $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
558 | 558 | $factory = new LogFactory($c, $this->getSystemConfig()); |
559 | 559 | $logger = $factory->get($logType); |
@@ -564,11 +564,11 @@ discard block |
||
564 | 564 | $this->registerAlias(\OCP\ILogger::class, \OC\Log::class); |
565 | 565 | $this->registerAlias('Logger', \OC\Log::class); |
566 | 566 | |
567 | - $this->registerService(ILogFactory::class, function (Server $c) { |
|
567 | + $this->registerService(ILogFactory::class, function(Server $c) { |
|
568 | 568 | return new LogFactory($c, $this->getSystemConfig()); |
569 | 569 | }); |
570 | 570 | |
571 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
571 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function(Server $c) { |
|
572 | 572 | $config = $c->getConfig(); |
573 | 573 | return new \OC\BackgroundJob\JobList( |
574 | 574 | $c->getDatabaseConnection(), |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | }); |
579 | 579 | $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
580 | 580 | |
581 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
581 | + $this->registerService(\OCP\Route\IRouter::class, function(Server $c) { |
|
582 | 582 | $cacheFactory = $c->getMemCacheFactory(); |
583 | 583 | $logger = $c->getLogger(); |
584 | 584 | if ($cacheFactory->isLocalCacheAvailable()) { |
@@ -590,12 +590,12 @@ discard block |
||
590 | 590 | }); |
591 | 591 | $this->registerAlias('Router', \OCP\Route\IRouter::class); |
592 | 592 | |
593 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
593 | + $this->registerService(\OCP\ISearch::class, function($c) { |
|
594 | 594 | return new Search(); |
595 | 595 | }); |
596 | 596 | $this->registerAlias('Search', \OCP\ISearch::class); |
597 | 597 | |
598 | - $this->registerService(\OC\Security\RateLimiting\Limiter::class, function (Server $c) { |
|
598 | + $this->registerService(\OC\Security\RateLimiting\Limiter::class, function(Server $c) { |
|
599 | 599 | return new \OC\Security\RateLimiting\Limiter( |
600 | 600 | $this->getUserSession(), |
601 | 601 | $this->getRequest(), |
@@ -603,34 +603,34 @@ discard block |
||
603 | 603 | $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
604 | 604 | ); |
605 | 605 | }); |
606 | - $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { |
|
606 | + $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function($c) { |
|
607 | 607 | return new \OC\Security\RateLimiting\Backend\MemoryCache( |
608 | 608 | $this->getMemCacheFactory(), |
609 | 609 | new \OC\AppFramework\Utility\TimeFactory() |
610 | 610 | ); |
611 | 611 | }); |
612 | 612 | |
613 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
613 | + $this->registerService(\OCP\Security\ISecureRandom::class, function($c) { |
|
614 | 614 | return new SecureRandom(); |
615 | 615 | }); |
616 | 616 | $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
617 | 617 | |
618 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
618 | + $this->registerService(\OCP\Security\ICrypto::class, function(Server $c) { |
|
619 | 619 | return new Crypto($c->getConfig(), $c->getSecureRandom()); |
620 | 620 | }); |
621 | 621 | $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
622 | 622 | |
623 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
623 | + $this->registerService(\OCP\Security\IHasher::class, function(Server $c) { |
|
624 | 624 | return new Hasher($c->getConfig()); |
625 | 625 | }); |
626 | 626 | $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
627 | 627 | |
628 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
628 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function(Server $c) { |
|
629 | 629 | return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
630 | 630 | }); |
631 | 631 | $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
632 | 632 | |
633 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
633 | + $this->registerService(IDBConnection::class, function(Server $c) { |
|
634 | 634 | $systemConfig = $c->getSystemConfig(); |
635 | 635 | $factory = new \OC\DB\ConnectionFactory($systemConfig); |
636 | 636 | $type = $systemConfig->getValue('dbtype', 'sqlite'); |
@@ -645,7 +645,7 @@ discard block |
||
645 | 645 | $this->registerAlias('DatabaseConnection', IDBConnection::class); |
646 | 646 | |
647 | 647 | |
648 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
648 | + $this->registerService(\OCP\Http\Client\IClientService::class, function(Server $c) { |
|
649 | 649 | $user = \OC_User::getUser(); |
650 | 650 | $uid = $user ? $user : null; |
651 | 651 | return new ClientService( |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | ); |
661 | 661 | }); |
662 | 662 | $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
663 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
663 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function(Server $c) { |
|
664 | 664 | $eventLogger = new EventLogger(); |
665 | 665 | if ($c->getSystemConfig()->getValue('debug', false)) { |
666 | 666 | // In debug mode, module is being activated by default |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | }); |
671 | 671 | $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
672 | 672 | |
673 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
673 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function(Server $c) { |
|
674 | 674 | $queryLogger = new QueryLogger(); |
675 | 675 | if ($c->getSystemConfig()->getValue('debug', false)) { |
676 | 676 | // In debug mode, module is being activated by default |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | }); |
681 | 681 | $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
682 | 682 | |
683 | - $this->registerService(TempManager::class, function (Server $c) { |
|
683 | + $this->registerService(TempManager::class, function(Server $c) { |
|
684 | 684 | return new TempManager( |
685 | 685 | $c->getLogger(), |
686 | 686 | $c->getConfig() |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | $this->registerAlias('TempManager', TempManager::class); |
690 | 690 | $this->registerAlias(ITempManager::class, TempManager::class); |
691 | 691 | |
692 | - $this->registerService(AppManager::class, function (Server $c) { |
|
692 | + $this->registerService(AppManager::class, function(Server $c) { |
|
693 | 693 | return new \OC\App\AppManager( |
694 | 694 | $c->getUserSession(), |
695 | 695 | $c->query(\OC\AppConfig::class), |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | $this->registerAlias('AppManager', AppManager::class); |
702 | 702 | $this->registerAlias(IAppManager::class, AppManager::class); |
703 | 703 | |
704 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
704 | + $this->registerService(\OCP\IDateTimeZone::class, function(Server $c) { |
|
705 | 705 | return new DateTimeZone( |
706 | 706 | $c->getConfig(), |
707 | 707 | $c->getSession() |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | }); |
710 | 710 | $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
711 | 711 | |
712 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
712 | + $this->registerService(\OCP\IDateTimeFormatter::class, function(Server $c) { |
|
713 | 713 | $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
714 | 714 | |
715 | 715 | return new DateTimeFormatter( |
@@ -719,7 +719,7 @@ discard block |
||
719 | 719 | }); |
720 | 720 | $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
721 | 721 | |
722 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
722 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function(Server $c) { |
|
723 | 723 | $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
724 | 724 | $listener = new UserMountCacheListener($mountCache); |
725 | 725 | $listener->listen($c->getUserManager()); |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | }); |
728 | 728 | $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
729 | 729 | |
730 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
730 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function(Server $c) { |
|
731 | 731 | $loader = \OC\Files\Filesystem::getLoader(); |
732 | 732 | $mountCache = $c->query('UserMountCache'); |
733 | 733 | $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
@@ -743,10 +743,10 @@ discard block |
||
743 | 743 | }); |
744 | 744 | $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
745 | 745 | |
746 | - $this->registerService('IniWrapper', function ($c) { |
|
746 | + $this->registerService('IniWrapper', function($c) { |
|
747 | 747 | return new IniGetWrapper(); |
748 | 748 | }); |
749 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
749 | + $this->registerService('AsyncCommandBus', function(Server $c) { |
|
750 | 750 | $busClass = $c->getConfig()->getSystemValue('commandbus'); |
751 | 751 | if ($busClass) { |
752 | 752 | list($app, $class) = explode('::', $busClass, 2); |
@@ -761,10 +761,10 @@ discard block |
||
761 | 761 | return new CronBus($jobList); |
762 | 762 | } |
763 | 763 | }); |
764 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
764 | + $this->registerService('TrustedDomainHelper', function($c) { |
|
765 | 765 | return new TrustedDomainHelper($this->getConfig()); |
766 | 766 | }); |
767 | - $this->registerService(Throttler::class, function (Server $c) { |
|
767 | + $this->registerService(Throttler::class, function(Server $c) { |
|
768 | 768 | return new Throttler( |
769 | 769 | $c->getDatabaseConnection(), |
770 | 770 | new TimeFactory(), |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | ); |
774 | 774 | }); |
775 | 775 | $this->registerAlias('Throttler', Throttler::class); |
776 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
776 | + $this->registerService('IntegrityCodeChecker', function(Server $c) { |
|
777 | 777 | // IConfig and IAppManager requires a working database. This code |
778 | 778 | // might however be called when ownCloud is not yet setup. |
779 | 779 | if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | $c->getTempManager() |
795 | 795 | ); |
796 | 796 | }); |
797 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
797 | + $this->registerService(\OCP\IRequest::class, function($c) { |
|
798 | 798 | if (isset($this['urlParams'])) { |
799 | 799 | $urlParams = $this['urlParams']; |
800 | 800 | } else { |
@@ -830,7 +830,7 @@ discard block |
||
830 | 830 | }); |
831 | 831 | $this->registerAlias('Request', \OCP\IRequest::class); |
832 | 832 | |
833 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
833 | + $this->registerService(\OCP\Mail\IMailer::class, function(Server $c) { |
|
834 | 834 | return new Mailer( |
835 | 835 | $c->getConfig(), |
836 | 836 | $c->getLogger(), |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | }); |
842 | 842 | $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
843 | 843 | |
844 | - $this->registerService('LDAPProvider', function (Server $c) { |
|
844 | + $this->registerService('LDAPProvider', function(Server $c) { |
|
845 | 845 | $config = $c->getConfig(); |
846 | 846 | $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
847 | 847 | if (is_null($factoryClass)) { |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | $factory = new $factoryClass($this); |
852 | 852 | return $factory->getLDAPProvider(); |
853 | 853 | }); |
854 | - $this->registerService(ILockingProvider::class, function (Server $c) { |
|
854 | + $this->registerService(ILockingProvider::class, function(Server $c) { |
|
855 | 855 | $ini = $c->getIniWrapper(); |
856 | 856 | $config = $c->getConfig(); |
857 | 857 | $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
@@ -874,49 +874,49 @@ discard block |
||
874 | 874 | }); |
875 | 875 | $this->registerAlias('LockingProvider', ILockingProvider::class); |
876 | 876 | |
877 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
877 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function() { |
|
878 | 878 | return new \OC\Files\Mount\Manager(); |
879 | 879 | }); |
880 | 880 | $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
881 | 881 | |
882 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
882 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function(Server $c) { |
|
883 | 883 | return new \OC\Files\Type\Detection( |
884 | 884 | $c->getURLGenerator(), |
885 | 885 | \OC::$configDir, |
886 | - \OC::$SERVERROOT . '/resources/config/' |
|
886 | + \OC::$SERVERROOT.'/resources/config/' |
|
887 | 887 | ); |
888 | 888 | }); |
889 | 889 | $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
890 | 890 | |
891 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
891 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function(Server $c) { |
|
892 | 892 | return new \OC\Files\Type\Loader( |
893 | 893 | $c->getDatabaseConnection() |
894 | 894 | ); |
895 | 895 | }); |
896 | 896 | $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
897 | - $this->registerService(BundleFetcher::class, function () { |
|
897 | + $this->registerService(BundleFetcher::class, function() { |
|
898 | 898 | return new BundleFetcher($this->getL10N('lib')); |
899 | 899 | }); |
900 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
900 | + $this->registerService(\OCP\Notification\IManager::class, function(Server $c) { |
|
901 | 901 | return new Manager( |
902 | 902 | $c->query(IValidator::class) |
903 | 903 | ); |
904 | 904 | }); |
905 | 905 | $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
906 | 906 | |
907 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
907 | + $this->registerService(\OC\CapabilitiesManager::class, function(Server $c) { |
|
908 | 908 | $manager = new \OC\CapabilitiesManager($c->getLogger()); |
909 | - $manager->registerCapability(function () use ($c) { |
|
909 | + $manager->registerCapability(function() use ($c) { |
|
910 | 910 | return new \OC\OCS\CoreCapabilities($c->getConfig()); |
911 | 911 | }); |
912 | - $manager->registerCapability(function () use ($c) { |
|
912 | + $manager->registerCapability(function() use ($c) { |
|
913 | 913 | return $c->query(\OC\Security\Bruteforce\Capabilities::class); |
914 | 914 | }); |
915 | 915 | return $manager; |
916 | 916 | }); |
917 | 917 | $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
918 | 918 | |
919 | - $this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) { |
|
919 | + $this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) { |
|
920 | 920 | $config = $c->getConfig(); |
921 | 921 | $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class); |
922 | 922 | /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
@@ -926,7 +926,7 @@ discard block |
||
926 | 926 | $manager->registerDisplayNameResolver('user', function($id) use ($c) { |
927 | 927 | $manager = $c->getUserManager(); |
928 | 928 | $user = $manager->get($id); |
929 | - if(is_null($user)) { |
|
929 | + if (is_null($user)) { |
|
930 | 930 | $l = $c->getL10N('core'); |
931 | 931 | $displayName = $l->t('Unknown user'); |
932 | 932 | } else { |
@@ -939,7 +939,7 @@ discard block |
||
939 | 939 | }); |
940 | 940 | $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
941 | 941 | |
942 | - $this->registerService('ThemingDefaults', function (Server $c) { |
|
942 | + $this->registerService('ThemingDefaults', function(Server $c) { |
|
943 | 943 | /* |
944 | 944 | * Dark magic for autoloader. |
945 | 945 | * If we do a class_exists it will try to load the class which will |
@@ -967,7 +967,7 @@ discard block |
||
967 | 967 | } |
968 | 968 | return new \OC_Defaults(); |
969 | 969 | }); |
970 | - $this->registerService(SCSSCacher::class, function (Server $c) { |
|
970 | + $this->registerService(SCSSCacher::class, function(Server $c) { |
|
971 | 971 | return new SCSSCacher( |
972 | 972 | $c->getLogger(), |
973 | 973 | $c->query(\OC\Files\AppData\Factory::class), |
@@ -980,7 +980,7 @@ discard block |
||
980 | 980 | new TimeFactory() |
981 | 981 | ); |
982 | 982 | }); |
983 | - $this->registerService(JSCombiner::class, function (Server $c) { |
|
983 | + $this->registerService(JSCombiner::class, function(Server $c) { |
|
984 | 984 | return new JSCombiner( |
985 | 985 | $c->getAppDataDir('js'), |
986 | 986 | $c->getURLGenerator(), |
@@ -989,13 +989,13 @@ discard block |
||
989 | 989 | $c->getLogger() |
990 | 990 | ); |
991 | 991 | }); |
992 | - $this->registerService(EventDispatcher::class, function () { |
|
992 | + $this->registerService(EventDispatcher::class, function() { |
|
993 | 993 | return new EventDispatcher(); |
994 | 994 | }); |
995 | 995 | $this->registerAlias('EventDispatcher', EventDispatcher::class); |
996 | 996 | $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
997 | 997 | |
998 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
998 | + $this->registerService('CryptoWrapper', function(Server $c) { |
|
999 | 999 | // FIXME: Instantiiated here due to cyclic dependency |
1000 | 1000 | $request = new Request( |
1001 | 1001 | [ |
@@ -1020,7 +1020,7 @@ discard block |
||
1020 | 1020 | $request |
1021 | 1021 | ); |
1022 | 1022 | }); |
1023 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
1023 | + $this->registerService('CsrfTokenManager', function(Server $c) { |
|
1024 | 1024 | $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
1025 | 1025 | |
1026 | 1026 | return new CsrfTokenManager( |
@@ -1028,22 +1028,22 @@ discard block |
||
1028 | 1028 | $c->query(SessionStorage::class) |
1029 | 1029 | ); |
1030 | 1030 | }); |
1031 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
1031 | + $this->registerService(SessionStorage::class, function(Server $c) { |
|
1032 | 1032 | return new SessionStorage($c->getSession()); |
1033 | 1033 | }); |
1034 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
1034 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function(Server $c) { |
|
1035 | 1035 | return new ContentSecurityPolicyManager(); |
1036 | 1036 | }); |
1037 | 1037 | $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
1038 | 1038 | |
1039 | - $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) { |
|
1039 | + $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) { |
|
1040 | 1040 | return new ContentSecurityPolicyNonceManager( |
1041 | 1041 | $c->getCsrfTokenManager(), |
1042 | 1042 | $c->getRequest() |
1043 | 1043 | ); |
1044 | 1044 | }); |
1045 | 1045 | |
1046 | - $this->registerService(\OCP\Share\IManager::class, function (Server $c) { |
|
1046 | + $this->registerService(\OCP\Share\IManager::class, function(Server $c) { |
|
1047 | 1047 | $config = $c->getConfig(); |
1048 | 1048 | $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class); |
1049 | 1049 | /** @var \OCP\Share\IProviderFactory $factory */ |
@@ -1090,7 +1090,7 @@ discard block |
||
1090 | 1090 | |
1091 | 1091 | $this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class); |
1092 | 1092 | |
1093 | - $this->registerService('SettingsManager', function (Server $c) { |
|
1093 | + $this->registerService('SettingsManager', function(Server $c) { |
|
1094 | 1094 | $manager = new \OC\Settings\Manager( |
1095 | 1095 | $c->getLogger(), |
1096 | 1096 | $c->getL10N('lib'), |
@@ -1099,36 +1099,36 @@ discard block |
||
1099 | 1099 | ); |
1100 | 1100 | return $manager; |
1101 | 1101 | }); |
1102 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
1102 | + $this->registerService(\OC\Files\AppData\Factory::class, function(Server $c) { |
|
1103 | 1103 | return new \OC\Files\AppData\Factory( |
1104 | 1104 | $c->getRootFolder(), |
1105 | 1105 | $c->getSystemConfig() |
1106 | 1106 | ); |
1107 | 1107 | }); |
1108 | 1108 | |
1109 | - $this->registerService('LockdownManager', function (Server $c) { |
|
1110 | - return new LockdownManager(function () use ($c) { |
|
1109 | + $this->registerService('LockdownManager', function(Server $c) { |
|
1110 | + return new LockdownManager(function() use ($c) { |
|
1111 | 1111 | return $c->getSession(); |
1112 | 1112 | }); |
1113 | 1113 | }); |
1114 | 1114 | |
1115 | - $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
1115 | + $this->registerService(\OCP\OCS\IDiscoveryService::class, function(Server $c) { |
|
1116 | 1116 | return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
1117 | 1117 | }); |
1118 | 1118 | |
1119 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
1119 | + $this->registerService(ICloudIdManager::class, function(Server $c) { |
|
1120 | 1120 | return new CloudIdManager(); |
1121 | 1121 | }); |
1122 | 1122 | |
1123 | - $this->registerService(IConfig::class, function (Server $c) { |
|
1123 | + $this->registerService(IConfig::class, function(Server $c) { |
|
1124 | 1124 | return new GlobalScale\Config($c->getConfig()); |
1125 | 1125 | }); |
1126 | 1126 | |
1127 | - $this->registerService(ICloudFederationProviderManager::class, function (Server $c) { |
|
1127 | + $this->registerService(ICloudFederationProviderManager::class, function(Server $c) { |
|
1128 | 1128 | return new CloudFederationProviderManager($c->getAppManager(), $c->getHTTPClientService(), $c->getCloudIdManager(), $c->getLogger()); |
1129 | 1129 | }); |
1130 | 1130 | |
1131 | - $this->registerService(ICloudFederationFactory::class, function (Server $c) { |
|
1131 | + $this->registerService(ICloudFederationFactory::class, function(Server $c) { |
|
1132 | 1132 | return new CloudFederationFactory(); |
1133 | 1133 | }); |
1134 | 1134 | |
@@ -1138,18 +1138,18 @@ discard block |
||
1138 | 1138 | $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
1139 | 1139 | $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
1140 | 1140 | |
1141 | - $this->registerService(Defaults::class, function (Server $c) { |
|
1141 | + $this->registerService(Defaults::class, function(Server $c) { |
|
1142 | 1142 | return new Defaults( |
1143 | 1143 | $c->getThemingDefaults() |
1144 | 1144 | ); |
1145 | 1145 | }); |
1146 | 1146 | $this->registerAlias('Defaults', \OCP\Defaults::class); |
1147 | 1147 | |
1148 | - $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { |
|
1148 | + $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) { |
|
1149 | 1149 | return $c->query(\OCP\IUserSession::class)->getSession(); |
1150 | 1150 | }); |
1151 | 1151 | |
1152 | - $this->registerService(IShareHelper::class, function (Server $c) { |
|
1152 | + $this->registerService(IShareHelper::class, function(Server $c) { |
|
1153 | 1153 | return new ShareHelper( |
1154 | 1154 | $c->query(\OCP\Share\IManager::class) |
1155 | 1155 | ); |
@@ -1192,7 +1192,7 @@ discard block |
||
1192 | 1192 | $this->registerAlias(IDashboardManager::class, DashboardManager::class); |
1193 | 1193 | $this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class); |
1194 | 1194 | |
1195 | - $this->registerService(\OC\Security\IdentityProof\Manager::class, function (Server $c) { |
|
1195 | + $this->registerService(\OC\Security\IdentityProof\Manager::class, function(Server $c) { |
|
1196 | 1196 | return new \OC\Security\IdentityProof\Manager( |
1197 | 1197 | $c->query(\OC\Files\AppData\Factory::class), |
1198 | 1198 | $c->getCrypto(), |
@@ -1245,11 +1245,11 @@ discard block |
||
1245 | 1245 | // no avatar to remove |
1246 | 1246 | } catch (\Exception $e) { |
1247 | 1247 | // Ignore exceptions |
1248 | - $logger->info('Could not cleanup avatar of ' . $user->getUID()); |
|
1248 | + $logger->info('Could not cleanup avatar of '.$user->getUID()); |
|
1249 | 1249 | } |
1250 | 1250 | }); |
1251 | 1251 | |
1252 | - $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { |
|
1252 | + $dispatcher->addListener('OCP\IUser::changeUser', function(GenericEvent $e) { |
|
1253 | 1253 | $manager = $this->getAvatarManager(); |
1254 | 1254 | /** @var IUser $user */ |
1255 | 1255 | $user = $e->getSubject(); |
@@ -1405,7 +1405,7 @@ discard block |
||
1405 | 1405 | * @deprecated since 9.2.0 use IAppData |
1406 | 1406 | */ |
1407 | 1407 | public function getAppFolder() { |
1408 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
1408 | + $dir = '/'.\OC_App::getCurrentApp(); |
|
1409 | 1409 | $root = $this->getRootFolder(); |
1410 | 1410 | if (!$root->nodeExists($dir)) { |
1411 | 1411 | $folder = $root->newFolder($dir); |
@@ -1980,7 +1980,7 @@ discard block |
||
1980 | 1980 | /** |
1981 | 1981 | * @return \OCP\Collaboration\AutoComplete\IManager |
1982 | 1982 | */ |
1983 | - public function getAutoCompleteManager(){ |
|
1983 | + public function getAutoCompleteManager() { |
|
1984 | 1984 | return $this->query(IManager::class); |
1985 | 1985 | } |
1986 | 1986 |