Passed
Push — master ( 2d938a...0d8733 )
by Joas
14:58 queued 12s
created
apps/user_status/lib/Service/StatusService.php 1 patch
Indentation   +501 added lines, -501 removed lines patch added patch discarded remove patch
@@ -48,505 +48,505 @@
 block discarded – undo
48 48
  */
49 49
 class StatusService {
50 50
 
51
-	/** @var UserStatusMapper */
52
-	private $mapper;
53
-
54
-	/** @var ITimeFactory */
55
-	private $timeFactory;
56
-
57
-	/** @var PredefinedStatusService */
58
-	private $predefinedStatusService;
59
-
60
-	private IEmojiHelper $emojiHelper;
61
-
62
-	/** @var bool */
63
-	private $shareeEnumeration;
64
-
65
-	/** @var bool */
66
-	private $shareeEnumerationInGroupOnly;
67
-
68
-	/** @var bool */
69
-	private $shareeEnumerationPhone;
70
-
71
-	/**
72
-	 * List of priorities ordered by their priority
73
-	 */
74
-	public const PRIORITY_ORDERED_STATUSES = [
75
-		IUserStatus::ONLINE,
76
-		IUserStatus::AWAY,
77
-		IUserStatus::DND,
78
-		IUserStatus::INVISIBLE,
79
-		IUserStatus::OFFLINE,
80
-	];
81
-
82
-	/**
83
-	 * List of statuses that persist the clear-up
84
-	 * or UserLiveStatusEvents
85
-	 */
86
-	public const PERSISTENT_STATUSES = [
87
-		IUserStatus::AWAY,
88
-		IUserStatus::DND,
89
-		IUserStatus::INVISIBLE,
90
-	];
91
-
92
-	/** @var int */
93
-	public const INVALIDATE_STATUS_THRESHOLD = 15 /* minutes */ * 60 /* seconds */;
94
-
95
-	/** @var int */
96
-	public const MAXIMUM_MESSAGE_LENGTH = 80;
97
-
98
-	public function __construct(UserStatusMapper $mapper,
99
-								ITimeFactory $timeFactory,
100
-								PredefinedStatusService $defaultStatusService,
101
-								IEmojiHelper $emojiHelper,
102
-								IConfig $config) {
103
-		$this->mapper = $mapper;
104
-		$this->timeFactory = $timeFactory;
105
-		$this->predefinedStatusService = $defaultStatusService;
106
-		$this->emojiHelper = $emojiHelper;
107
-		$this->shareeEnumeration = $config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes';
108
-		$this->shareeEnumerationInGroupOnly = $this->shareeEnumeration && $config->getAppValue('core', 'shareapi_restrict_user_enumeration_to_group', 'no') === 'yes';
109
-		$this->shareeEnumerationPhone = $this->shareeEnumeration && $config->getAppValue('core', 'shareapi_restrict_user_enumeration_to_phone', 'no') === 'yes';
110
-	}
111
-
112
-	/**
113
-	 * @param int|null $limit
114
-	 * @param int|null $offset
115
-	 * @return UserStatus[]
116
-	 */
117
-	public function findAll(?int $limit = null, ?int $offset = null): array {
118
-		// Return empty array if user enumeration is disabled or limited to groups
119
-		// TODO: find a solution that scales to get only users from common groups if user enumeration is limited to
120
-		//       groups. See discussion at https://github.com/nextcloud/server/pull/27879#discussion_r729715936
121
-		if (!$this->shareeEnumeration || $this->shareeEnumerationInGroupOnly || $this->shareeEnumerationPhone) {
122
-			return [];
123
-		}
124
-
125
-		return array_map(function ($status) {
126
-			return $this->processStatus($status);
127
-		}, $this->mapper->findAll($limit, $offset));
128
-	}
129
-
130
-	/**
131
-	 * @param int|null $limit
132
-	 * @param int|null $offset
133
-	 * @return array
134
-	 */
135
-	public function findAllRecentStatusChanges(?int $limit = null, ?int $offset = null): array {
136
-		// Return empty array if user enumeration is disabled or limited to groups
137
-		// TODO: find a solution that scales to get only users from common groups if user enumeration is limited to
138
-		//       groups. See discussion at https://github.com/nextcloud/server/pull/27879#discussion_r729715936
139
-		if (!$this->shareeEnumeration || $this->shareeEnumerationInGroupOnly || $this->shareeEnumerationPhone) {
140
-			return [];
141
-		}
142
-
143
-		return array_map(function ($status) {
144
-			return $this->processStatus($status);
145
-		}, $this->mapper->findAllRecent($limit, $offset));
146
-	}
147
-
148
-	/**
149
-	 * @param string $userId
150
-	 * @return UserStatus
151
-	 * @throws DoesNotExistException
152
-	 */
153
-	public function findByUserId(string $userId):UserStatus {
154
-		return $this->processStatus($this->mapper->findByUserId($userId));
155
-	}
156
-
157
-	/**
158
-	 * @param array $userIds
159
-	 * @return UserStatus[]
160
-	 */
161
-	public function findByUserIds(array $userIds):array {
162
-		return array_map(function ($status) {
163
-			return $this->processStatus($status);
164
-		}, $this->mapper->findByUserIds($userIds));
165
-	}
166
-
167
-	/**
168
-	 * @param string $userId
169
-	 * @param string $status
170
-	 * @param int|null $statusTimestamp
171
-	 * @param bool $isUserDefined
172
-	 * @return UserStatus
173
-	 * @throws InvalidStatusTypeException
174
-	 */
175
-	public function setStatus(string $userId,
176
-							  string $status,
177
-							  ?int $statusTimestamp,
178
-							  bool $isUserDefined): UserStatus {
179
-		try {
180
-			$userStatus = $this->mapper->findByUserId($userId);
181
-		} catch (DoesNotExistException $ex) {
182
-			$userStatus = new UserStatus();
183
-			$userStatus->setUserId($userId);
184
-		}
185
-
186
-		// Check if status-type is valid
187
-		if (!\in_array($status, self::PRIORITY_ORDERED_STATUSES, true)) {
188
-			throw new InvalidStatusTypeException('Status-type "' . $status . '" is not supported');
189
-		}
190
-		if ($statusTimestamp === null) {
191
-			$statusTimestamp = $this->timeFactory->getTime();
192
-		}
193
-
194
-		$userStatus->setStatus($status);
195
-		$userStatus->setStatusTimestamp($statusTimestamp);
196
-		$userStatus->setIsUserDefined($isUserDefined);
197
-		$userStatus->setIsBackup(false);
198
-
199
-		if ($userStatus->getId() === null) {
200
-			return $this->mapper->insert($userStatus);
201
-		}
202
-
203
-		return $this->mapper->update($userStatus);
204
-	}
205
-
206
-	/**
207
-	 * @param string $userId
208
-	 * @param string $messageId
209
-	 * @param int|null $clearAt
210
-	 * @return UserStatus
211
-	 * @throws InvalidMessageIdException
212
-	 * @throws InvalidClearAtException
213
-	 */
214
-	public function setPredefinedMessage(string $userId,
215
-										 string $messageId,
216
-										 ?int $clearAt): UserStatus {
217
-		try {
218
-			$userStatus = $this->mapper->findByUserId($userId);
219
-		} catch (DoesNotExistException $ex) {
220
-			$userStatus = new UserStatus();
221
-			$userStatus->setUserId($userId);
222
-			$userStatus->setStatus(IUserStatus::OFFLINE);
223
-			$userStatus->setStatusTimestamp(0);
224
-			$userStatus->setIsUserDefined(false);
225
-			$userStatus->setIsBackup(false);
226
-		}
227
-
228
-		if (!$this->predefinedStatusService->isValidId($messageId)) {
229
-			throw new InvalidMessageIdException('Message-Id "' . $messageId . '" is not supported');
230
-		}
231
-
232
-		// Check that clearAt is in the future
233
-		if ($clearAt !== null && $clearAt < $this->timeFactory->getTime()) {
234
-			throw new InvalidClearAtException('ClearAt is in the past');
235
-		}
236
-
237
-		$userStatus->setMessageId($messageId);
238
-		$userStatus->setCustomIcon(null);
239
-		$userStatus->setCustomMessage(null);
240
-		$userStatus->setClearAt($clearAt);
241
-
242
-		if ($userStatus->getId() === null) {
243
-			return $this->mapper->insert($userStatus);
244
-		}
245
-
246
-		return $this->mapper->update($userStatus);
247
-	}
248
-
249
-	/**
250
-	 * @param string $userId
251
-	 * @param string $status
252
-	 * @param string $messageId
253
-	 * @param bool $createBackup
254
-	 * @throws InvalidStatusTypeException
255
-	 * @throws InvalidMessageIdException
256
-	 */
257
-	public function setUserStatus(string $userId,
258
-										 string $status,
259
-										 string $messageId,
260
-										 bool $createBackup): void {
261
-		// Check if status-type is valid
262
-		if (!\in_array($status, self::PRIORITY_ORDERED_STATUSES, true)) {
263
-			throw new InvalidStatusTypeException('Status-type "' . $status . '" is not supported');
264
-		}
265
-
266
-		if (!$this->predefinedStatusService->isValidId($messageId)) {
267
-			throw new InvalidMessageIdException('Message-Id "' . $messageId . '" is not supported');
268
-		}
269
-
270
-		if ($createBackup) {
271
-			if ($this->backupCurrentStatus($userId) === false) {
272
-				return; // Already a status set automatically => abort.
273
-			}
274
-
275
-			// If we just created the backup
276
-			$userStatus = new UserStatus();
277
-			$userStatus->setUserId($userId);
278
-		} else {
279
-			try {
280
-				$userStatus = $this->mapper->findByUserId($userId);
281
-			} catch (DoesNotExistException $ex) {
282
-				$userStatus = new UserStatus();
283
-				$userStatus->setUserId($userId);
284
-			}
285
-		}
286
-
287
-		$userStatus->setStatus($status);
288
-		$userStatus->setStatusTimestamp($this->timeFactory->getTime());
289
-		$userStatus->setIsUserDefined(true);
290
-		$userStatus->setIsBackup(false);
291
-		$userStatus->setMessageId($messageId);
292
-		$userStatus->setCustomIcon(null);
293
-		$userStatus->setCustomMessage(null);
294
-		$userStatus->setClearAt(null);
295
-
296
-		if ($userStatus->getId() !== null) {
297
-			$this->mapper->update($userStatus);
298
-			return;
299
-		}
300
-		$this->mapper->insert($userStatus);
301
-	}
302
-
303
-	/**
304
-	 * @param string $userId
305
-	 * @param string|null $statusIcon
306
-	 * @param string $message
307
-	 * @param int|null $clearAt
308
-	 * @return UserStatus
309
-	 * @throws InvalidClearAtException
310
-	 * @throws InvalidStatusIconException
311
-	 * @throws StatusMessageTooLongException
312
-	 */
313
-	public function setCustomMessage(string $userId,
314
-									 ?string $statusIcon,
315
-									 string $message,
316
-									 ?int $clearAt): UserStatus {
317
-		try {
318
-			$userStatus = $this->mapper->findByUserId($userId);
319
-		} catch (DoesNotExistException $ex) {
320
-			$userStatus = new UserStatus();
321
-			$userStatus->setUserId($userId);
322
-			$userStatus->setStatus(IUserStatus::OFFLINE);
323
-			$userStatus->setStatusTimestamp(0);
324
-			$userStatus->setIsUserDefined(false);
325
-		}
326
-
327
-		// Check if statusIcon contains only one character
328
-		if ($statusIcon !== null && !$this->emojiHelper->isValidSingleEmoji($statusIcon)) {
329
-			throw new InvalidStatusIconException('Status-Icon is longer than one character');
330
-		}
331
-		// Check for maximum length of custom message
332
-		if (\mb_strlen($message) > self::MAXIMUM_MESSAGE_LENGTH) {
333
-			throw new StatusMessageTooLongException('Message is longer than supported length of ' . self::MAXIMUM_MESSAGE_LENGTH . ' characters');
334
-		}
335
-		// Check that clearAt is in the future
336
-		if ($clearAt !== null && $clearAt < $this->timeFactory->getTime()) {
337
-			throw new InvalidClearAtException('ClearAt is in the past');
338
-		}
339
-
340
-		$userStatus->setMessageId(null);
341
-		$userStatus->setCustomIcon($statusIcon);
342
-		$userStatus->setCustomMessage($message);
343
-		$userStatus->setClearAt($clearAt);
344
-
345
-		if ($userStatus->getId() === null) {
346
-			return $this->mapper->insert($userStatus);
347
-		}
348
-
349
-		return $this->mapper->update($userStatus);
350
-	}
351
-
352
-	/**
353
-	 * @param string $userId
354
-	 * @return bool
355
-	 */
356
-	public function clearStatus(string $userId): bool {
357
-		try {
358
-			$userStatus = $this->mapper->findByUserId($userId);
359
-		} catch (DoesNotExistException $ex) {
360
-			// if there is no status to remove, just return
361
-			return false;
362
-		}
363
-
364
-		$userStatus->setStatus(IUserStatus::OFFLINE);
365
-		$userStatus->setStatusTimestamp(0);
366
-		$userStatus->setIsUserDefined(false);
367
-
368
-		$this->mapper->update($userStatus);
369
-		return true;
370
-	}
371
-
372
-	/**
373
-	 * @param string $userId
374
-	 * @return bool
375
-	 */
376
-	public function clearMessage(string $userId): bool {
377
-		try {
378
-			$userStatus = $this->mapper->findByUserId($userId);
379
-		} catch (DoesNotExistException $ex) {
380
-			// if there is no status to remove, just return
381
-			return false;
382
-		}
383
-
384
-		$userStatus->setMessageId(null);
385
-		$userStatus->setCustomMessage(null);
386
-		$userStatus->setCustomIcon(null);
387
-		$userStatus->setClearAt(null);
388
-
389
-		$this->mapper->update($userStatus);
390
-		return true;
391
-	}
392
-
393
-	/**
394
-	 * @param string $userId
395
-	 * @return bool
396
-	 */
397
-	public function removeUserStatus(string $userId): bool {
398
-		try {
399
-			$userStatus = $this->mapper->findByUserId($userId, false);
400
-		} catch (DoesNotExistException $ex) {
401
-			// if there is no status to remove, just return
402
-			return false;
403
-		}
404
-
405
-		$this->mapper->delete($userStatus);
406
-		return true;
407
-	}
408
-
409
-	public function removeBackupUserStatus(string $userId): bool {
410
-		try {
411
-			$userStatus = $this->mapper->findByUserId($userId, true);
412
-		} catch (DoesNotExistException $ex) {
413
-			// if there is no status to remove, just return
414
-			return false;
415
-		}
416
-
417
-		$this->mapper->delete($userStatus);
418
-		return true;
419
-	}
420
-
421
-	/**
422
-	 * Processes a status to check if custom message is still
423
-	 * up to date and provides translated default status if needed
424
-	 *
425
-	 * @param UserStatus $status
426
-	 * @return UserStatus
427
-	 */
428
-	private function processStatus(UserStatus $status): UserStatus {
429
-		$clearAt = $status->getClearAt();
430
-
431
-		if ($status->getStatusTimestamp() < $this->timeFactory->getTime() - self::INVALIDATE_STATUS_THRESHOLD
432
-			&& (!$status->getIsUserDefined() || $status->getStatus() === IUserStatus::ONLINE)) {
433
-			$this->cleanStatus($status);
434
-		}
435
-		if ($clearAt !== null && $clearAt < $this->timeFactory->getTime()) {
436
-			$this->cleanStatusMessage($status);
437
-		}
438
-		if ($status->getMessageId() !== null) {
439
-			$this->addDefaultMessage($status);
440
-		}
441
-
442
-		return $status;
443
-	}
444
-
445
-	/**
446
-	 * @param UserStatus $status
447
-	 */
448
-	private function cleanStatus(UserStatus $status): void {
449
-		if ($status->getStatus() === IUserStatus::OFFLINE && !$status->getIsUserDefined()) {
450
-			return;
451
-		}
452
-
453
-		$status->setStatus(IUserStatus::OFFLINE);
454
-		$status->setStatusTimestamp($this->timeFactory->getTime());
455
-		$status->setIsUserDefined(false);
456
-
457
-		$this->mapper->update($status);
458
-	}
459
-
460
-	/**
461
-	 * @param UserStatus $status
462
-	 */
463
-	private function cleanStatusMessage(UserStatus $status): void {
464
-		$status->setMessageId(null);
465
-		$status->setCustomIcon(null);
466
-		$status->setCustomMessage(null);
467
-		$status->setClearAt(null);
468
-
469
-		$this->mapper->update($status);
470
-	}
471
-
472
-	/**
473
-	 * @param UserStatus $status
474
-	 */
475
-	private function addDefaultMessage(UserStatus $status): void {
476
-		// If the message is predefined, insert the translated message and icon
477
-		$predefinedMessage = $this->predefinedStatusService->getDefaultStatusById($status->getMessageId());
478
-		if ($predefinedMessage !== null) {
479
-			$status->setCustomMessage($predefinedMessage['message']);
480
-			$status->setCustomIcon($predefinedMessage['icon']);
481
-		}
482
-	}
483
-
484
-	/**
485
-	 * @return bool false if there is already a backup. In this case abort the procedure.
486
-	 */
487
-	public function backupCurrentStatus(string $userId): bool {
488
-		try {
489
-			$this->mapper->createBackupStatus($userId);
490
-			return true;
491
-		} catch (Exception $ex) {
492
-			if ($ex->getReason() === Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
493
-				return false;
494
-			}
495
-			throw $ex;
496
-		}
497
-	}
498
-
499
-	public function revertUserStatus(string $userId, string $messageId, string $status): void {
500
-		try {
501
-			/** @var UserStatus $userStatus */
502
-			$backupUserStatus = $this->mapper->findByUserId($userId, true);
503
-		} catch (DoesNotExistException $ex) {
504
-			// No user status to revert, do nothing
505
-			return;
506
-		}
507
-
508
-		$deleted = $this->mapper->deleteCurrentStatusToRestoreBackup($userId, $messageId, $status);
509
-		if (!$deleted) {
510
-			// Another status is set automatically or no status, do nothing
511
-			return;
512
-		}
513
-
514
-		$backupUserStatus->setIsBackup(false);
515
-		// Remove the underscore prefix added when creating the backup
516
-		$backupUserStatus->setUserId(substr($backupUserStatus->getUserId(), 1));
517
-		$this->mapper->update($backupUserStatus);
518
-	}
519
-
520
-	public function revertMultipleUserStatus(array $userIds, string $messageId, string $status): void {
521
-		// Get all user statuses and the backups
522
-		$findById = $userIds;
523
-		foreach ($userIds as $userId) {
524
-			$findById[] = '_' . $userId;
525
-		}
526
-		$userStatuses = $this->mapper->findByUserIds($findById);
527
-
528
-		$backups = $restoreIds = $statuesToDelete = [];
529
-		foreach ($userStatuses as $userStatus) {
530
-			if (!$userStatus->getIsBackup()
531
-				&& $userStatus->getMessageId() === $messageId
532
-				&& $userStatus->getStatus() === $status) {
533
-				$statuesToDelete[$userStatus->getUserId()] = $userStatus->getId();
534
-			} else if ($userStatus->getIsBackup()) {
535
-				$backups[$userStatus->getUserId()] = $userStatus->getId();
536
-			}
537
-		}
538
-
539
-		// For users with both (normal and backup) delete the status when matching
540
-		foreach ($statuesToDelete as $userId => $statusId) {
541
-			$backupUserId = '_' . $userId;
542
-			if (isset($backups[$backupUserId])) {
543
-				$restoreIds[] = $backups[$backupUserId];
544
-			}
545
-		}
546
-
547
-		$this->mapper->deleteByIds(array_values($statuesToDelete));
548
-
549
-		// For users that matched restore the previous status
550
-		$this->mapper->restoreBackupStatuses($restoreIds);
551
-	}
51
+    /** @var UserStatusMapper */
52
+    private $mapper;
53
+
54
+    /** @var ITimeFactory */
55
+    private $timeFactory;
56
+
57
+    /** @var PredefinedStatusService */
58
+    private $predefinedStatusService;
59
+
60
+    private IEmojiHelper $emojiHelper;
61
+
62
+    /** @var bool */
63
+    private $shareeEnumeration;
64
+
65
+    /** @var bool */
66
+    private $shareeEnumerationInGroupOnly;
67
+
68
+    /** @var bool */
69
+    private $shareeEnumerationPhone;
70
+
71
+    /**
72
+     * List of priorities ordered by their priority
73
+     */
74
+    public const PRIORITY_ORDERED_STATUSES = [
75
+        IUserStatus::ONLINE,
76
+        IUserStatus::AWAY,
77
+        IUserStatus::DND,
78
+        IUserStatus::INVISIBLE,
79
+        IUserStatus::OFFLINE,
80
+    ];
81
+
82
+    /**
83
+     * List of statuses that persist the clear-up
84
+     * or UserLiveStatusEvents
85
+     */
86
+    public const PERSISTENT_STATUSES = [
87
+        IUserStatus::AWAY,
88
+        IUserStatus::DND,
89
+        IUserStatus::INVISIBLE,
90
+    ];
91
+
92
+    /** @var int */
93
+    public const INVALIDATE_STATUS_THRESHOLD = 15 /* minutes */ * 60 /* seconds */;
94
+
95
+    /** @var int */
96
+    public const MAXIMUM_MESSAGE_LENGTH = 80;
97
+
98
+    public function __construct(UserStatusMapper $mapper,
99
+                                ITimeFactory $timeFactory,
100
+                                PredefinedStatusService $defaultStatusService,
101
+                                IEmojiHelper $emojiHelper,
102
+                                IConfig $config) {
103
+        $this->mapper = $mapper;
104
+        $this->timeFactory = $timeFactory;
105
+        $this->predefinedStatusService = $defaultStatusService;
106
+        $this->emojiHelper = $emojiHelper;
107
+        $this->shareeEnumeration = $config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes';
108
+        $this->shareeEnumerationInGroupOnly = $this->shareeEnumeration && $config->getAppValue('core', 'shareapi_restrict_user_enumeration_to_group', 'no') === 'yes';
109
+        $this->shareeEnumerationPhone = $this->shareeEnumeration && $config->getAppValue('core', 'shareapi_restrict_user_enumeration_to_phone', 'no') === 'yes';
110
+    }
111
+
112
+    /**
113
+     * @param int|null $limit
114
+     * @param int|null $offset
115
+     * @return UserStatus[]
116
+     */
117
+    public function findAll(?int $limit = null, ?int $offset = null): array {
118
+        // Return empty array if user enumeration is disabled or limited to groups
119
+        // TODO: find a solution that scales to get only users from common groups if user enumeration is limited to
120
+        //       groups. See discussion at https://github.com/nextcloud/server/pull/27879#discussion_r729715936
121
+        if (!$this->shareeEnumeration || $this->shareeEnumerationInGroupOnly || $this->shareeEnumerationPhone) {
122
+            return [];
123
+        }
124
+
125
+        return array_map(function ($status) {
126
+            return $this->processStatus($status);
127
+        }, $this->mapper->findAll($limit, $offset));
128
+    }
129
+
130
+    /**
131
+     * @param int|null $limit
132
+     * @param int|null $offset
133
+     * @return array
134
+     */
135
+    public function findAllRecentStatusChanges(?int $limit = null, ?int $offset = null): array {
136
+        // Return empty array if user enumeration is disabled or limited to groups
137
+        // TODO: find a solution that scales to get only users from common groups if user enumeration is limited to
138
+        //       groups. See discussion at https://github.com/nextcloud/server/pull/27879#discussion_r729715936
139
+        if (!$this->shareeEnumeration || $this->shareeEnumerationInGroupOnly || $this->shareeEnumerationPhone) {
140
+            return [];
141
+        }
142
+
143
+        return array_map(function ($status) {
144
+            return $this->processStatus($status);
145
+        }, $this->mapper->findAllRecent($limit, $offset));
146
+    }
147
+
148
+    /**
149
+     * @param string $userId
150
+     * @return UserStatus
151
+     * @throws DoesNotExistException
152
+     */
153
+    public function findByUserId(string $userId):UserStatus {
154
+        return $this->processStatus($this->mapper->findByUserId($userId));
155
+    }
156
+
157
+    /**
158
+     * @param array $userIds
159
+     * @return UserStatus[]
160
+     */
161
+    public function findByUserIds(array $userIds):array {
162
+        return array_map(function ($status) {
163
+            return $this->processStatus($status);
164
+        }, $this->mapper->findByUserIds($userIds));
165
+    }
166
+
167
+    /**
168
+     * @param string $userId
169
+     * @param string $status
170
+     * @param int|null $statusTimestamp
171
+     * @param bool $isUserDefined
172
+     * @return UserStatus
173
+     * @throws InvalidStatusTypeException
174
+     */
175
+    public function setStatus(string $userId,
176
+                                string $status,
177
+                              ?int $statusTimestamp,
178
+                                bool $isUserDefined): UserStatus {
179
+        try {
180
+            $userStatus = $this->mapper->findByUserId($userId);
181
+        } catch (DoesNotExistException $ex) {
182
+            $userStatus = new UserStatus();
183
+            $userStatus->setUserId($userId);
184
+        }
185
+
186
+        // Check if status-type is valid
187
+        if (!\in_array($status, self::PRIORITY_ORDERED_STATUSES, true)) {
188
+            throw new InvalidStatusTypeException('Status-type "' . $status . '" is not supported');
189
+        }
190
+        if ($statusTimestamp === null) {
191
+            $statusTimestamp = $this->timeFactory->getTime();
192
+        }
193
+
194
+        $userStatus->setStatus($status);
195
+        $userStatus->setStatusTimestamp($statusTimestamp);
196
+        $userStatus->setIsUserDefined($isUserDefined);
197
+        $userStatus->setIsBackup(false);
198
+
199
+        if ($userStatus->getId() === null) {
200
+            return $this->mapper->insert($userStatus);
201
+        }
202
+
203
+        return $this->mapper->update($userStatus);
204
+    }
205
+
206
+    /**
207
+     * @param string $userId
208
+     * @param string $messageId
209
+     * @param int|null $clearAt
210
+     * @return UserStatus
211
+     * @throws InvalidMessageIdException
212
+     * @throws InvalidClearAtException
213
+     */
214
+    public function setPredefinedMessage(string $userId,
215
+                                            string $messageId,
216
+                                         ?int $clearAt): UserStatus {
217
+        try {
218
+            $userStatus = $this->mapper->findByUserId($userId);
219
+        } catch (DoesNotExistException $ex) {
220
+            $userStatus = new UserStatus();
221
+            $userStatus->setUserId($userId);
222
+            $userStatus->setStatus(IUserStatus::OFFLINE);
223
+            $userStatus->setStatusTimestamp(0);
224
+            $userStatus->setIsUserDefined(false);
225
+            $userStatus->setIsBackup(false);
226
+        }
227
+
228
+        if (!$this->predefinedStatusService->isValidId($messageId)) {
229
+            throw new InvalidMessageIdException('Message-Id "' . $messageId . '" is not supported');
230
+        }
231
+
232
+        // Check that clearAt is in the future
233
+        if ($clearAt !== null && $clearAt < $this->timeFactory->getTime()) {
234
+            throw new InvalidClearAtException('ClearAt is in the past');
235
+        }
236
+
237
+        $userStatus->setMessageId($messageId);
238
+        $userStatus->setCustomIcon(null);
239
+        $userStatus->setCustomMessage(null);
240
+        $userStatus->setClearAt($clearAt);
241
+
242
+        if ($userStatus->getId() === null) {
243
+            return $this->mapper->insert($userStatus);
244
+        }
245
+
246
+        return $this->mapper->update($userStatus);
247
+    }
248
+
249
+    /**
250
+     * @param string $userId
251
+     * @param string $status
252
+     * @param string $messageId
253
+     * @param bool $createBackup
254
+     * @throws InvalidStatusTypeException
255
+     * @throws InvalidMessageIdException
256
+     */
257
+    public function setUserStatus(string $userId,
258
+                                            string $status,
259
+                                            string $messageId,
260
+                                            bool $createBackup): void {
261
+        // Check if status-type is valid
262
+        if (!\in_array($status, self::PRIORITY_ORDERED_STATUSES, true)) {
263
+            throw new InvalidStatusTypeException('Status-type "' . $status . '" is not supported');
264
+        }
265
+
266
+        if (!$this->predefinedStatusService->isValidId($messageId)) {
267
+            throw new InvalidMessageIdException('Message-Id "' . $messageId . '" is not supported');
268
+        }
269
+
270
+        if ($createBackup) {
271
+            if ($this->backupCurrentStatus($userId) === false) {
272
+                return; // Already a status set automatically => abort.
273
+            }
274
+
275
+            // If we just created the backup
276
+            $userStatus = new UserStatus();
277
+            $userStatus->setUserId($userId);
278
+        } else {
279
+            try {
280
+                $userStatus = $this->mapper->findByUserId($userId);
281
+            } catch (DoesNotExistException $ex) {
282
+                $userStatus = new UserStatus();
283
+                $userStatus->setUserId($userId);
284
+            }
285
+        }
286
+
287
+        $userStatus->setStatus($status);
288
+        $userStatus->setStatusTimestamp($this->timeFactory->getTime());
289
+        $userStatus->setIsUserDefined(true);
290
+        $userStatus->setIsBackup(false);
291
+        $userStatus->setMessageId($messageId);
292
+        $userStatus->setCustomIcon(null);
293
+        $userStatus->setCustomMessage(null);
294
+        $userStatus->setClearAt(null);
295
+
296
+        if ($userStatus->getId() !== null) {
297
+            $this->mapper->update($userStatus);
298
+            return;
299
+        }
300
+        $this->mapper->insert($userStatus);
301
+    }
302
+
303
+    /**
304
+     * @param string $userId
305
+     * @param string|null $statusIcon
306
+     * @param string $message
307
+     * @param int|null $clearAt
308
+     * @return UserStatus
309
+     * @throws InvalidClearAtException
310
+     * @throws InvalidStatusIconException
311
+     * @throws StatusMessageTooLongException
312
+     */
313
+    public function setCustomMessage(string $userId,
314
+                                     ?string $statusIcon,
315
+                                        string $message,
316
+                                     ?int $clearAt): UserStatus {
317
+        try {
318
+            $userStatus = $this->mapper->findByUserId($userId);
319
+        } catch (DoesNotExistException $ex) {
320
+            $userStatus = new UserStatus();
321
+            $userStatus->setUserId($userId);
322
+            $userStatus->setStatus(IUserStatus::OFFLINE);
323
+            $userStatus->setStatusTimestamp(0);
324
+            $userStatus->setIsUserDefined(false);
325
+        }
326
+
327
+        // Check if statusIcon contains only one character
328
+        if ($statusIcon !== null && !$this->emojiHelper->isValidSingleEmoji($statusIcon)) {
329
+            throw new InvalidStatusIconException('Status-Icon is longer than one character');
330
+        }
331
+        // Check for maximum length of custom message
332
+        if (\mb_strlen($message) > self::MAXIMUM_MESSAGE_LENGTH) {
333
+            throw new StatusMessageTooLongException('Message is longer than supported length of ' . self::MAXIMUM_MESSAGE_LENGTH . ' characters');
334
+        }
335
+        // Check that clearAt is in the future
336
+        if ($clearAt !== null && $clearAt < $this->timeFactory->getTime()) {
337
+            throw new InvalidClearAtException('ClearAt is in the past');
338
+        }
339
+
340
+        $userStatus->setMessageId(null);
341
+        $userStatus->setCustomIcon($statusIcon);
342
+        $userStatus->setCustomMessage($message);
343
+        $userStatus->setClearAt($clearAt);
344
+
345
+        if ($userStatus->getId() === null) {
346
+            return $this->mapper->insert($userStatus);
347
+        }
348
+
349
+        return $this->mapper->update($userStatus);
350
+    }
351
+
352
+    /**
353
+     * @param string $userId
354
+     * @return bool
355
+     */
356
+    public function clearStatus(string $userId): bool {
357
+        try {
358
+            $userStatus = $this->mapper->findByUserId($userId);
359
+        } catch (DoesNotExistException $ex) {
360
+            // if there is no status to remove, just return
361
+            return false;
362
+        }
363
+
364
+        $userStatus->setStatus(IUserStatus::OFFLINE);
365
+        $userStatus->setStatusTimestamp(0);
366
+        $userStatus->setIsUserDefined(false);
367
+
368
+        $this->mapper->update($userStatus);
369
+        return true;
370
+    }
371
+
372
+    /**
373
+     * @param string $userId
374
+     * @return bool
375
+     */
376
+    public function clearMessage(string $userId): bool {
377
+        try {
378
+            $userStatus = $this->mapper->findByUserId($userId);
379
+        } catch (DoesNotExistException $ex) {
380
+            // if there is no status to remove, just return
381
+            return false;
382
+        }
383
+
384
+        $userStatus->setMessageId(null);
385
+        $userStatus->setCustomMessage(null);
386
+        $userStatus->setCustomIcon(null);
387
+        $userStatus->setClearAt(null);
388
+
389
+        $this->mapper->update($userStatus);
390
+        return true;
391
+    }
392
+
393
+    /**
394
+     * @param string $userId
395
+     * @return bool
396
+     */
397
+    public function removeUserStatus(string $userId): bool {
398
+        try {
399
+            $userStatus = $this->mapper->findByUserId($userId, false);
400
+        } catch (DoesNotExistException $ex) {
401
+            // if there is no status to remove, just return
402
+            return false;
403
+        }
404
+
405
+        $this->mapper->delete($userStatus);
406
+        return true;
407
+    }
408
+
409
+    public function removeBackupUserStatus(string $userId): bool {
410
+        try {
411
+            $userStatus = $this->mapper->findByUserId($userId, true);
412
+        } catch (DoesNotExistException $ex) {
413
+            // if there is no status to remove, just return
414
+            return false;
415
+        }
416
+
417
+        $this->mapper->delete($userStatus);
418
+        return true;
419
+    }
420
+
421
+    /**
422
+     * Processes a status to check if custom message is still
423
+     * up to date and provides translated default status if needed
424
+     *
425
+     * @param UserStatus $status
426
+     * @return UserStatus
427
+     */
428
+    private function processStatus(UserStatus $status): UserStatus {
429
+        $clearAt = $status->getClearAt();
430
+
431
+        if ($status->getStatusTimestamp() < $this->timeFactory->getTime() - self::INVALIDATE_STATUS_THRESHOLD
432
+            && (!$status->getIsUserDefined() || $status->getStatus() === IUserStatus::ONLINE)) {
433
+            $this->cleanStatus($status);
434
+        }
435
+        if ($clearAt !== null && $clearAt < $this->timeFactory->getTime()) {
436
+            $this->cleanStatusMessage($status);
437
+        }
438
+        if ($status->getMessageId() !== null) {
439
+            $this->addDefaultMessage($status);
440
+        }
441
+
442
+        return $status;
443
+    }
444
+
445
+    /**
446
+     * @param UserStatus $status
447
+     */
448
+    private function cleanStatus(UserStatus $status): void {
449
+        if ($status->getStatus() === IUserStatus::OFFLINE && !$status->getIsUserDefined()) {
450
+            return;
451
+        }
452
+
453
+        $status->setStatus(IUserStatus::OFFLINE);
454
+        $status->setStatusTimestamp($this->timeFactory->getTime());
455
+        $status->setIsUserDefined(false);
456
+
457
+        $this->mapper->update($status);
458
+    }
459
+
460
+    /**
461
+     * @param UserStatus $status
462
+     */
463
+    private function cleanStatusMessage(UserStatus $status): void {
464
+        $status->setMessageId(null);
465
+        $status->setCustomIcon(null);
466
+        $status->setCustomMessage(null);
467
+        $status->setClearAt(null);
468
+
469
+        $this->mapper->update($status);
470
+    }
471
+
472
+    /**
473
+     * @param UserStatus $status
474
+     */
475
+    private function addDefaultMessage(UserStatus $status): void {
476
+        // If the message is predefined, insert the translated message and icon
477
+        $predefinedMessage = $this->predefinedStatusService->getDefaultStatusById($status->getMessageId());
478
+        if ($predefinedMessage !== null) {
479
+            $status->setCustomMessage($predefinedMessage['message']);
480
+            $status->setCustomIcon($predefinedMessage['icon']);
481
+        }
482
+    }
483
+
484
+    /**
485
+     * @return bool false if there is already a backup. In this case abort the procedure.
486
+     */
487
+    public function backupCurrentStatus(string $userId): bool {
488
+        try {
489
+            $this->mapper->createBackupStatus($userId);
490
+            return true;
491
+        } catch (Exception $ex) {
492
+            if ($ex->getReason() === Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
493
+                return false;
494
+            }
495
+            throw $ex;
496
+        }
497
+    }
498
+
499
+    public function revertUserStatus(string $userId, string $messageId, string $status): void {
500
+        try {
501
+            /** @var UserStatus $userStatus */
502
+            $backupUserStatus = $this->mapper->findByUserId($userId, true);
503
+        } catch (DoesNotExistException $ex) {
504
+            // No user status to revert, do nothing
505
+            return;
506
+        }
507
+
508
+        $deleted = $this->mapper->deleteCurrentStatusToRestoreBackup($userId, $messageId, $status);
509
+        if (!$deleted) {
510
+            // Another status is set automatically or no status, do nothing
511
+            return;
512
+        }
513
+
514
+        $backupUserStatus->setIsBackup(false);
515
+        // Remove the underscore prefix added when creating the backup
516
+        $backupUserStatus->setUserId(substr($backupUserStatus->getUserId(), 1));
517
+        $this->mapper->update($backupUserStatus);
518
+    }
519
+
520
+    public function revertMultipleUserStatus(array $userIds, string $messageId, string $status): void {
521
+        // Get all user statuses and the backups
522
+        $findById = $userIds;
523
+        foreach ($userIds as $userId) {
524
+            $findById[] = '_' . $userId;
525
+        }
526
+        $userStatuses = $this->mapper->findByUserIds($findById);
527
+
528
+        $backups = $restoreIds = $statuesToDelete = [];
529
+        foreach ($userStatuses as $userStatus) {
530
+            if (!$userStatus->getIsBackup()
531
+                && $userStatus->getMessageId() === $messageId
532
+                && $userStatus->getStatus() === $status) {
533
+                $statuesToDelete[$userStatus->getUserId()] = $userStatus->getId();
534
+            } else if ($userStatus->getIsBackup()) {
535
+                $backups[$userStatus->getUserId()] = $userStatus->getId();
536
+            }
537
+        }
538
+
539
+        // For users with both (normal and backup) delete the status when matching
540
+        foreach ($statuesToDelete as $userId => $statusId) {
541
+            $backupUserId = '_' . $userId;
542
+            if (isset($backups[$backupUserId])) {
543
+                $restoreIds[] = $backups[$backupUserId];
544
+            }
545
+        }
546
+
547
+        $this->mapper->deleteByIds(array_values($statuesToDelete));
548
+
549
+        // For users that matched restore the previous status
550
+        $this->mapper->restoreBackupStatuses($restoreIds);
551
+    }
552 552
 }
Please login to merge, or discard this patch.
apps/user_status/lib/Capabilities.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -34,21 +34,21 @@
 block discarded – undo
34 34
  * @package OCA\UserStatus
35 35
  */
36 36
 class Capabilities implements ICapability {
37
-	private IEmojiHelper $emojiHelper;
37
+    private IEmojiHelper $emojiHelper;
38 38
 
39
-	public function __construct(IEmojiHelper $emojiHelper) {
40
-		$this->emojiHelper = $emojiHelper;
41
-	}
39
+    public function __construct(IEmojiHelper $emojiHelper) {
40
+        $this->emojiHelper = $emojiHelper;
41
+    }
42 42
 
43
-	/**
44
-	 * @inheritDoc
45
-	 */
46
-	public function getCapabilities() {
47
-		return [
48
-			'user_status' => [
49
-				'enabled' => true,
50
-				'supports_emoji' => $this->emojiHelper->doesPlatformSupportEmoji(),
51
-			],
52
-		];
53
-	}
43
+    /**
44
+     * @inheritDoc
45
+     */
46
+    public function getCapabilities() {
47
+        return [
48
+            'user_status' => [
49
+                'enabled' => true,
50
+                'supports_emoji' => $this->emojiHelper->doesPlatformSupportEmoji(),
51
+            ],
52
+        ];
53
+    }
54 54
 }
Please login to merge, or discard this patch.
apps/user_status/composer/composer/autoload_classmap.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -6,32 +6,32 @@
 block discarded – undo
6 6
 $baseDir = $vendorDir;
7 7
 
8 8
 return array(
9
-    'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
10
-    'OCA\\UserStatus\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php',
11
-    'OCA\\UserStatus\\BackgroundJob\\ClearOldStatusesBackgroundJob' => $baseDir . '/../lib/BackgroundJob/ClearOldStatusesBackgroundJob.php',
12
-    'OCA\\UserStatus\\Capabilities' => $baseDir . '/../lib/Capabilities.php',
13
-    'OCA\\UserStatus\\Connector\\UserStatus' => $baseDir . '/../lib/Connector/UserStatus.php',
14
-    'OCA\\UserStatus\\Connector\\UserStatusProvider' => $baseDir . '/../lib/Connector/UserStatusProvider.php',
15
-    'OCA\\UserStatus\\Controller\\HeartbeatController' => $baseDir . '/../lib/Controller/HeartbeatController.php',
16
-    'OCA\\UserStatus\\Controller\\PredefinedStatusController' => $baseDir . '/../lib/Controller/PredefinedStatusController.php',
17
-    'OCA\\UserStatus\\Controller\\StatusesController' => $baseDir . '/../lib/Controller/StatusesController.php',
18
-    'OCA\\UserStatus\\Controller\\UserStatusController' => $baseDir . '/../lib/Controller/UserStatusController.php',
19
-    'OCA\\UserStatus\\Dashboard\\UserStatusWidget' => $baseDir . '/../lib/Dashboard/UserStatusWidget.php',
20
-    'OCA\\UserStatus\\Db\\UserStatus' => $baseDir . '/../lib/Db/UserStatus.php',
21
-    'OCA\\UserStatus\\Db\\UserStatusMapper' => $baseDir . '/../lib/Db/UserStatusMapper.php',
22
-    'OCA\\UserStatus\\Exception\\InvalidClearAtException' => $baseDir . '/../lib/Exception/InvalidClearAtException.php',
23
-    'OCA\\UserStatus\\Exception\\InvalidMessageIdException' => $baseDir . '/../lib/Exception/InvalidMessageIdException.php',
24
-    'OCA\\UserStatus\\Exception\\InvalidStatusIconException' => $baseDir . '/../lib/Exception/InvalidStatusIconException.php',
25
-    'OCA\\UserStatus\\Exception\\InvalidStatusTypeException' => $baseDir . '/../lib/Exception/InvalidStatusTypeException.php',
26
-    'OCA\\UserStatus\\Exception\\StatusMessageTooLongException' => $baseDir . '/../lib/Exception/StatusMessageTooLongException.php',
27
-    'OCA\\UserStatus\\Listener\\BeforeTemplateRenderedListener' => $baseDir . '/../lib/Listener/BeforeTemplateRenderedListener.php',
28
-    'OCA\\UserStatus\\Listener\\UserDeletedListener' => $baseDir . '/../lib/Listener/UserDeletedListener.php',
29
-    'OCA\\UserStatus\\Listener\\UserLiveStatusListener' => $baseDir . '/../lib/Listener/UserLiveStatusListener.php',
30
-    'OCA\\UserStatus\\Migration\\Version0001Date20200602134824' => $baseDir . '/../lib/Migration/Version0001Date20200602134824.php',
31
-    'OCA\\UserStatus\\Migration\\Version0002Date20200902144824' => $baseDir . '/../lib/Migration/Version0002Date20200902144824.php',
32
-    'OCA\\UserStatus\\Migration\\Version1000Date20201111130204' => $baseDir . '/../lib/Migration/Version1000Date20201111130204.php',
33
-    'OCA\\UserStatus\\Migration\\Version2301Date20210809144824' => $baseDir . '/../lib/Migration/Version2301Date20210809144824.php',
34
-    'OCA\\UserStatus\\Service\\JSDataService' => $baseDir . '/../lib/Service/JSDataService.php',
35
-    'OCA\\UserStatus\\Service\\PredefinedStatusService' => $baseDir . '/../lib/Service/PredefinedStatusService.php',
36
-    'OCA\\UserStatus\\Service\\StatusService' => $baseDir . '/../lib/Service/StatusService.php',
9
+    'Composer\\InstalledVersions' => $vendorDir.'/composer/InstalledVersions.php',
10
+    'OCA\\UserStatus\\AppInfo\\Application' => $baseDir.'/../lib/AppInfo/Application.php',
11
+    'OCA\\UserStatus\\BackgroundJob\\ClearOldStatusesBackgroundJob' => $baseDir.'/../lib/BackgroundJob/ClearOldStatusesBackgroundJob.php',
12
+    'OCA\\UserStatus\\Capabilities' => $baseDir.'/../lib/Capabilities.php',
13
+    'OCA\\UserStatus\\Connector\\UserStatus' => $baseDir.'/../lib/Connector/UserStatus.php',
14
+    'OCA\\UserStatus\\Connector\\UserStatusProvider' => $baseDir.'/../lib/Connector/UserStatusProvider.php',
15
+    'OCA\\UserStatus\\Controller\\HeartbeatController' => $baseDir.'/../lib/Controller/HeartbeatController.php',
16
+    'OCA\\UserStatus\\Controller\\PredefinedStatusController' => $baseDir.'/../lib/Controller/PredefinedStatusController.php',
17
+    'OCA\\UserStatus\\Controller\\StatusesController' => $baseDir.'/../lib/Controller/StatusesController.php',
18
+    'OCA\\UserStatus\\Controller\\UserStatusController' => $baseDir.'/../lib/Controller/UserStatusController.php',
19
+    'OCA\\UserStatus\\Dashboard\\UserStatusWidget' => $baseDir.'/../lib/Dashboard/UserStatusWidget.php',
20
+    'OCA\\UserStatus\\Db\\UserStatus' => $baseDir.'/../lib/Db/UserStatus.php',
21
+    'OCA\\UserStatus\\Db\\UserStatusMapper' => $baseDir.'/../lib/Db/UserStatusMapper.php',
22
+    'OCA\\UserStatus\\Exception\\InvalidClearAtException' => $baseDir.'/../lib/Exception/InvalidClearAtException.php',
23
+    'OCA\\UserStatus\\Exception\\InvalidMessageIdException' => $baseDir.'/../lib/Exception/InvalidMessageIdException.php',
24
+    'OCA\\UserStatus\\Exception\\InvalidStatusIconException' => $baseDir.'/../lib/Exception/InvalidStatusIconException.php',
25
+    'OCA\\UserStatus\\Exception\\InvalidStatusTypeException' => $baseDir.'/../lib/Exception/InvalidStatusTypeException.php',
26
+    'OCA\\UserStatus\\Exception\\StatusMessageTooLongException' => $baseDir.'/../lib/Exception/StatusMessageTooLongException.php',
27
+    'OCA\\UserStatus\\Listener\\BeforeTemplateRenderedListener' => $baseDir.'/../lib/Listener/BeforeTemplateRenderedListener.php',
28
+    'OCA\\UserStatus\\Listener\\UserDeletedListener' => $baseDir.'/../lib/Listener/UserDeletedListener.php',
29
+    'OCA\\UserStatus\\Listener\\UserLiveStatusListener' => $baseDir.'/../lib/Listener/UserLiveStatusListener.php',
30
+    'OCA\\UserStatus\\Migration\\Version0001Date20200602134824' => $baseDir.'/../lib/Migration/Version0001Date20200602134824.php',
31
+    'OCA\\UserStatus\\Migration\\Version0002Date20200902144824' => $baseDir.'/../lib/Migration/Version0002Date20200902144824.php',
32
+    'OCA\\UserStatus\\Migration\\Version1000Date20201111130204' => $baseDir.'/../lib/Migration/Version1000Date20201111130204.php',
33
+    'OCA\\UserStatus\\Migration\\Version2301Date20210809144824' => $baseDir.'/../lib/Migration/Version2301Date20210809144824.php',
34
+    'OCA\\UserStatus\\Service\\JSDataService' => $baseDir.'/../lib/Service/JSDataService.php',
35
+    'OCA\\UserStatus\\Service\\PredefinedStatusService' => $baseDir.'/../lib/Service/PredefinedStatusService.php',
36
+    'OCA\\UserStatus\\Service\\StatusService' => $baseDir.'/../lib/Service/StatusService.php',
37 37
 );
Please login to merge, or discard this patch.
apps/user_status/composer/composer/autoload_static.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -6,54 +6,54 @@
 block discarded – undo
6 6
 
7 7
 class ComposerStaticInitUserStatus
8 8
 {
9
-    public static $prefixLengthsPsr4 = array (
9
+    public static $prefixLengthsPsr4 = array(
10 10
         'O' => 
11
-        array (
11
+        array(
12 12
             'OCA\\UserStatus\\' => 15,
13 13
         ),
14 14
     );
15 15
 
16
-    public static $prefixDirsPsr4 = array (
16
+    public static $prefixDirsPsr4 = array(
17 17
         'OCA\\UserStatus\\' => 
18
-        array (
19
-            0 => __DIR__ . '/..' . '/../lib',
18
+        array(
19
+            0 => __DIR__.'/..'.'/../lib',
20 20
         ),
21 21
     );
22 22
 
23
-    public static $classMap = array (
24
-        'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
25
-        'OCA\\UserStatus\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php',
26
-        'OCA\\UserStatus\\BackgroundJob\\ClearOldStatusesBackgroundJob' => __DIR__ . '/..' . '/../lib/BackgroundJob/ClearOldStatusesBackgroundJob.php',
27
-        'OCA\\UserStatus\\Capabilities' => __DIR__ . '/..' . '/../lib/Capabilities.php',
28
-        'OCA\\UserStatus\\Connector\\UserStatus' => __DIR__ . '/..' . '/../lib/Connector/UserStatus.php',
29
-        'OCA\\UserStatus\\Connector\\UserStatusProvider' => __DIR__ . '/..' . '/../lib/Connector/UserStatusProvider.php',
30
-        'OCA\\UserStatus\\Controller\\HeartbeatController' => __DIR__ . '/..' . '/../lib/Controller/HeartbeatController.php',
31
-        'OCA\\UserStatus\\Controller\\PredefinedStatusController' => __DIR__ . '/..' . '/../lib/Controller/PredefinedStatusController.php',
32
-        'OCA\\UserStatus\\Controller\\StatusesController' => __DIR__ . '/..' . '/../lib/Controller/StatusesController.php',
33
-        'OCA\\UserStatus\\Controller\\UserStatusController' => __DIR__ . '/..' . '/../lib/Controller/UserStatusController.php',
34
-        'OCA\\UserStatus\\Dashboard\\UserStatusWidget' => __DIR__ . '/..' . '/../lib/Dashboard/UserStatusWidget.php',
35
-        'OCA\\UserStatus\\Db\\UserStatus' => __DIR__ . '/..' . '/../lib/Db/UserStatus.php',
36
-        'OCA\\UserStatus\\Db\\UserStatusMapper' => __DIR__ . '/..' . '/../lib/Db/UserStatusMapper.php',
37
-        'OCA\\UserStatus\\Exception\\InvalidClearAtException' => __DIR__ . '/..' . '/../lib/Exception/InvalidClearAtException.php',
38
-        'OCA\\UserStatus\\Exception\\InvalidMessageIdException' => __DIR__ . '/..' . '/../lib/Exception/InvalidMessageIdException.php',
39
-        'OCA\\UserStatus\\Exception\\InvalidStatusIconException' => __DIR__ . '/..' . '/../lib/Exception/InvalidStatusIconException.php',
40
-        'OCA\\UserStatus\\Exception\\InvalidStatusTypeException' => __DIR__ . '/..' . '/../lib/Exception/InvalidStatusTypeException.php',
41
-        'OCA\\UserStatus\\Exception\\StatusMessageTooLongException' => __DIR__ . '/..' . '/../lib/Exception/StatusMessageTooLongException.php',
42
-        'OCA\\UserStatus\\Listener\\BeforeTemplateRenderedListener' => __DIR__ . '/..' . '/../lib/Listener/BeforeTemplateRenderedListener.php',
43
-        'OCA\\UserStatus\\Listener\\UserDeletedListener' => __DIR__ . '/..' . '/../lib/Listener/UserDeletedListener.php',
44
-        'OCA\\UserStatus\\Listener\\UserLiveStatusListener' => __DIR__ . '/..' . '/../lib/Listener/UserLiveStatusListener.php',
45
-        'OCA\\UserStatus\\Migration\\Version0001Date20200602134824' => __DIR__ . '/..' . '/../lib/Migration/Version0001Date20200602134824.php',
46
-        'OCA\\UserStatus\\Migration\\Version0002Date20200902144824' => __DIR__ . '/..' . '/../lib/Migration/Version0002Date20200902144824.php',
47
-        'OCA\\UserStatus\\Migration\\Version1000Date20201111130204' => __DIR__ . '/..' . '/../lib/Migration/Version1000Date20201111130204.php',
48
-        'OCA\\UserStatus\\Migration\\Version2301Date20210809144824' => __DIR__ . '/..' . '/../lib/Migration/Version2301Date20210809144824.php',
49
-        'OCA\\UserStatus\\Service\\JSDataService' => __DIR__ . '/..' . '/../lib/Service/JSDataService.php',
50
-        'OCA\\UserStatus\\Service\\PredefinedStatusService' => __DIR__ . '/..' . '/../lib/Service/PredefinedStatusService.php',
51
-        'OCA\\UserStatus\\Service\\StatusService' => __DIR__ . '/..' . '/../lib/Service/StatusService.php',
23
+    public static $classMap = array(
24
+        'Composer\\InstalledVersions' => __DIR__.'/..'.'/composer/InstalledVersions.php',
25
+        'OCA\\UserStatus\\AppInfo\\Application' => __DIR__.'/..'.'/../lib/AppInfo/Application.php',
26
+        'OCA\\UserStatus\\BackgroundJob\\ClearOldStatusesBackgroundJob' => __DIR__.'/..'.'/../lib/BackgroundJob/ClearOldStatusesBackgroundJob.php',
27
+        'OCA\\UserStatus\\Capabilities' => __DIR__.'/..'.'/../lib/Capabilities.php',
28
+        'OCA\\UserStatus\\Connector\\UserStatus' => __DIR__.'/..'.'/../lib/Connector/UserStatus.php',
29
+        'OCA\\UserStatus\\Connector\\UserStatusProvider' => __DIR__.'/..'.'/../lib/Connector/UserStatusProvider.php',
30
+        'OCA\\UserStatus\\Controller\\HeartbeatController' => __DIR__.'/..'.'/../lib/Controller/HeartbeatController.php',
31
+        'OCA\\UserStatus\\Controller\\PredefinedStatusController' => __DIR__.'/..'.'/../lib/Controller/PredefinedStatusController.php',
32
+        'OCA\\UserStatus\\Controller\\StatusesController' => __DIR__.'/..'.'/../lib/Controller/StatusesController.php',
33
+        'OCA\\UserStatus\\Controller\\UserStatusController' => __DIR__.'/..'.'/../lib/Controller/UserStatusController.php',
34
+        'OCA\\UserStatus\\Dashboard\\UserStatusWidget' => __DIR__.'/..'.'/../lib/Dashboard/UserStatusWidget.php',
35
+        'OCA\\UserStatus\\Db\\UserStatus' => __DIR__.'/..'.'/../lib/Db/UserStatus.php',
36
+        'OCA\\UserStatus\\Db\\UserStatusMapper' => __DIR__.'/..'.'/../lib/Db/UserStatusMapper.php',
37
+        'OCA\\UserStatus\\Exception\\InvalidClearAtException' => __DIR__.'/..'.'/../lib/Exception/InvalidClearAtException.php',
38
+        'OCA\\UserStatus\\Exception\\InvalidMessageIdException' => __DIR__.'/..'.'/../lib/Exception/InvalidMessageIdException.php',
39
+        'OCA\\UserStatus\\Exception\\InvalidStatusIconException' => __DIR__.'/..'.'/../lib/Exception/InvalidStatusIconException.php',
40
+        'OCA\\UserStatus\\Exception\\InvalidStatusTypeException' => __DIR__.'/..'.'/../lib/Exception/InvalidStatusTypeException.php',
41
+        'OCA\\UserStatus\\Exception\\StatusMessageTooLongException' => __DIR__.'/..'.'/../lib/Exception/StatusMessageTooLongException.php',
42
+        'OCA\\UserStatus\\Listener\\BeforeTemplateRenderedListener' => __DIR__.'/..'.'/../lib/Listener/BeforeTemplateRenderedListener.php',
43
+        'OCA\\UserStatus\\Listener\\UserDeletedListener' => __DIR__.'/..'.'/../lib/Listener/UserDeletedListener.php',
44
+        'OCA\\UserStatus\\Listener\\UserLiveStatusListener' => __DIR__.'/..'.'/../lib/Listener/UserLiveStatusListener.php',
45
+        'OCA\\UserStatus\\Migration\\Version0001Date20200602134824' => __DIR__.'/..'.'/../lib/Migration/Version0001Date20200602134824.php',
46
+        'OCA\\UserStatus\\Migration\\Version0002Date20200902144824' => __DIR__.'/..'.'/../lib/Migration/Version0002Date20200902144824.php',
47
+        'OCA\\UserStatus\\Migration\\Version1000Date20201111130204' => __DIR__.'/..'.'/../lib/Migration/Version1000Date20201111130204.php',
48
+        'OCA\\UserStatus\\Migration\\Version2301Date20210809144824' => __DIR__.'/..'.'/../lib/Migration/Version2301Date20210809144824.php',
49
+        'OCA\\UserStatus\\Service\\JSDataService' => __DIR__.'/..'.'/../lib/Service/JSDataService.php',
50
+        'OCA\\UserStatus\\Service\\PredefinedStatusService' => __DIR__.'/..'.'/../lib/Service/PredefinedStatusService.php',
51
+        'OCA\\UserStatus\\Service\\StatusService' => __DIR__.'/..'.'/../lib/Service/StatusService.php',
52 52
     );
53 53
 
54 54
     public static function getInitializer(ClassLoader $loader)
55 55
     {
56
-        return \Closure::bind(function () use ($loader) {
56
+        return \Closure::bind(function() use ($loader) {
57 57
             $loader->prefixLengthsPsr4 = ComposerStaticInitUserStatus::$prefixLengthsPsr4;
58 58
             $loader->prefixDirsPsr4 = ComposerStaticInitUserStatus::$prefixDirsPsr4;
59 59
             $loader->classMap = ComposerStaticInitUserStatus::$classMap;
Please login to merge, or discard this patch.
lib/public/IEmojiHelper.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,13 +27,13 @@
 block discarded – undo
27 27
  * @since 24.0.0
28 28
  */
29 29
 interface IEmojiHelper {
30
-	/**
31
-	 * @since 24.0.0
32
-	 */
33
-	public function doesPlatformSupportEmoji(): bool;
30
+    /**
31
+     * @since 24.0.0
32
+     */
33
+    public function doesPlatformSupportEmoji(): bool;
34 34
 
35
-	/**
36
-	 * @since 24.0.0
37
-	 */
38
-	public function isValidSingleEmoji(string $emoji): bool;
35
+    /**
36
+     * @since 24.0.0
37
+     */
38
+    public function isValidSingleEmoji(string $emoji): bool;
39 39
 }
Please login to merge, or discard this patch.
lib/private/Server.php 1 patch
Indentation   +2118 added lines, -2118 removed lines patch added patch discarded remove patch
@@ -273,2127 +273,2127 @@
 block discarded – undo
273 273
  */
274 274
 class Server extends ServerContainer implements IServerContainer {
275 275
 
276
-	/** @var string */
277
-	private $webRoot;
278
-
279
-	/**
280
-	 * @param string $webRoot
281
-	 * @param \OC\Config $config
282
-	 */
283
-	public function __construct($webRoot, \OC\Config $config) {
284
-		parent::__construct();
285
-		$this->webRoot = $webRoot;
286
-
287
-		// To find out if we are running from CLI or not
288
-		$this->registerParameter('isCLI', \OC::$CLI);
289
-		$this->registerParameter('serverRoot', \OC::$SERVERROOT);
290
-
291
-		$this->registerService(ContainerInterface::class, function (ContainerInterface $c) {
292
-			return $c;
293
-		});
294
-		$this->registerService(\OCP\IServerContainer::class, function (ContainerInterface $c) {
295
-			return $c;
296
-		});
297
-
298
-		$this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
299
-		/** @deprecated 19.0.0 */
300
-		$this->registerDeprecatedAlias('CalendarManager', \OC\Calendar\Manager::class);
301
-
302
-		$this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class);
303
-		/** @deprecated 19.0.0 */
304
-		$this->registerDeprecatedAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class);
305
-
306
-		$this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class);
307
-		/** @deprecated 19.0.0 */
308
-		$this->registerDeprecatedAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class);
309
-
310
-		$this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
311
-		/** @deprecated 19.0.0 */
312
-		$this->registerDeprecatedAlias('ContactsManager', \OCP\Contacts\IManager::class);
313
-
314
-		$this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class);
315
-		$this->registerAlias(ITemplateManager::class, TemplateManager::class);
316
-
317
-		$this->registerAlias(IActionFactory::class, ActionFactory::class);
318
-
319
-		$this->registerService(View::class, function (Server $c) {
320
-			return new View();
321
-		}, false);
322
-
323
-		$this->registerService(IPreview::class, function (ContainerInterface $c) {
324
-			return new PreviewManager(
325
-				$c->get(\OCP\IConfig::class),
326
-				$c->get(IRootFolder::class),
327
-				new \OC\Preview\Storage\Root(
328
-					$c->get(IRootFolder::class),
329
-					$c->get(SystemConfig::class)
330
-				),
331
-				$c->get(SymfonyAdapter::class),
332
-				$c->get(GeneratorHelper::class),
333
-				$c->get(ISession::class)->get('user_id'),
334
-				$c->get(Coordinator::class),
335
-				$c->get(IServerContainer::class)
336
-			);
337
-		});
338
-		/** @deprecated 19.0.0 */
339
-		$this->registerDeprecatedAlias('PreviewManager', IPreview::class);
340
-
341
-		$this->registerService(\OC\Preview\Watcher::class, function (ContainerInterface $c) {
342
-			return new \OC\Preview\Watcher(
343
-				new \OC\Preview\Storage\Root(
344
-					$c->get(IRootFolder::class),
345
-					$c->get(SystemConfig::class)
346
-				)
347
-			);
348
-		});
349
-
350
-		$this->registerService(IProfiler::class, function (Server $c) {
351
-			return new Profiler($c->get(SystemConfig::class));
352
-		});
353
-
354
-		$this->registerService(\OCP\Encryption\IManager::class, function (Server $c) {
355
-			$view = new View();
356
-			$util = new Encryption\Util(
357
-				$view,
358
-				$c->get(IUserManager::class),
359
-				$c->get(IGroupManager::class),
360
-				$c->get(\OCP\IConfig::class)
361
-			);
362
-			return new Encryption\Manager(
363
-				$c->get(\OCP\IConfig::class),
364
-				$c->get(LoggerInterface::class),
365
-				$c->getL10N('core'),
366
-				new View(),
367
-				$util,
368
-				new ArrayCache()
369
-			);
370
-		});
371
-		/** @deprecated 19.0.0 */
372
-		$this->registerDeprecatedAlias('EncryptionManager', \OCP\Encryption\IManager::class);
373
-
374
-		/** @deprecated 21.0.0 */
375
-		$this->registerDeprecatedAlias('EncryptionFileHelper', IFile::class);
376
-		$this->registerService(IFile::class, function (ContainerInterface $c) {
377
-			$util = new Encryption\Util(
378
-				new View(),
379
-				$c->get(IUserManager::class),
380
-				$c->get(IGroupManager::class),
381
-				$c->get(\OCP\IConfig::class)
382
-			);
383
-			return new Encryption\File(
384
-				$util,
385
-				$c->get(IRootFolder::class),
386
-				$c->get(\OCP\Share\IManager::class)
387
-			);
388
-		});
389
-
390
-		/** @deprecated 21.0.0 */
391
-		$this->registerDeprecatedAlias('EncryptionKeyStorage', IStorage::class);
392
-		$this->registerService(IStorage::class, function (ContainerInterface $c) {
393
-			$view = new View();
394
-			$util = new Encryption\Util(
395
-				$view,
396
-				$c->get(IUserManager::class),
397
-				$c->get(IGroupManager::class),
398
-				$c->get(\OCP\IConfig::class)
399
-			);
400
-
401
-			return new Encryption\Keys\Storage(
402
-				$view,
403
-				$util,
404
-				$c->get(ICrypto::class),
405
-				$c->get(\OCP\IConfig::class)
406
-			);
407
-		});
408
-		/** @deprecated 20.0.0 */
409
-		$this->registerDeprecatedAlias('TagMapper', TagMapper::class);
410
-
411
-		$this->registerAlias(\OCP\ITagManager::class, TagManager::class);
412
-		/** @deprecated 19.0.0 */
413
-		$this->registerDeprecatedAlias('TagManager', \OCP\ITagManager::class);
414
-
415
-		$this->registerService('SystemTagManagerFactory', function (ContainerInterface $c) {
416
-			/** @var \OCP\IConfig $config */
417
-			$config = $c->get(\OCP\IConfig::class);
418
-			$factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class);
419
-			return new $factoryClass($this);
420
-		});
421
-		$this->registerService(ISystemTagManager::class, function (ContainerInterface $c) {
422
-			return $c->get('SystemTagManagerFactory')->getManager();
423
-		});
424
-		/** @deprecated 19.0.0 */
425
-		$this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class);
426
-
427
-		$this->registerService(ISystemTagObjectMapper::class, function (ContainerInterface $c) {
428
-			return $c->get('SystemTagManagerFactory')->getObjectMapper();
429
-		});
430
-		$this->registerService('RootFolder', function (ContainerInterface $c) {
431
-			$manager = \OC\Files\Filesystem::getMountManager(null);
432
-			$view = new View();
433
-			$root = new Root(
434
-				$manager,
435
-				$view,
436
-				null,
437
-				$c->get(IUserMountCache::class),
438
-				$this->get(LoggerInterface::class),
439
-				$this->get(IUserManager::class),
440
-				$this->get(IEventDispatcher::class),
441
-			);
442
-
443
-			$previewConnector = new \OC\Preview\WatcherConnector(
444
-				$root,
445
-				$c->get(SystemConfig::class)
446
-			);
447
-			$previewConnector->connectWatcher();
448
-
449
-			return $root;
450
-		});
451
-		$this->registerService(HookConnector::class, function (ContainerInterface $c) {
452
-			return new HookConnector(
453
-				$c->get(IRootFolder::class),
454
-				new View(),
455
-				$c->get(\OC\EventDispatcher\SymfonyAdapter::class),
456
-				$c->get(IEventDispatcher::class)
457
-			);
458
-		});
459
-
460
-		/** @deprecated 19.0.0 */
461
-		$this->registerDeprecatedAlias('SystemTagObjectMapper', ISystemTagObjectMapper::class);
462
-
463
-		$this->registerService(IRootFolder::class, function (ContainerInterface $c) {
464
-			return new LazyRoot(function () use ($c) {
465
-				return $c->get('RootFolder');
466
-			});
467
-		});
468
-		/** @deprecated 19.0.0 */
469
-		$this->registerDeprecatedAlias('LazyRootFolder', IRootFolder::class);
470
-
471
-		/** @deprecated 19.0.0 */
472
-		$this->registerDeprecatedAlias('UserManager', \OC\User\Manager::class);
473
-		$this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
474
-
475
-		$this->registerService(\OCP\IGroupManager::class, function (ContainerInterface $c) {
476
-			$groupManager = new \OC\Group\Manager(
477
-				$this->get(IUserManager::class),
478
-				$c->get(SymfonyAdapter::class),
479
-				$this->get(LoggerInterface::class)
480
-			);
481
-			$groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
482
-				/** @var IEventDispatcher $dispatcher */
483
-				$dispatcher = $this->get(IEventDispatcher::class);
484
-				$dispatcher->dispatchTyped(new BeforeGroupCreatedEvent($gid));
485
-			});
486
-			$groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $group) {
487
-				/** @var IEventDispatcher $dispatcher */
488
-				$dispatcher = $this->get(IEventDispatcher::class);
489
-				$dispatcher->dispatchTyped(new GroupCreatedEvent($group));
490
-			});
491
-			$groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
492
-				/** @var IEventDispatcher $dispatcher */
493
-				$dispatcher = $this->get(IEventDispatcher::class);
494
-				$dispatcher->dispatchTyped(new BeforeGroupDeletedEvent($group));
495
-			});
496
-			$groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
497
-				/** @var IEventDispatcher $dispatcher */
498
-				$dispatcher = $this->get(IEventDispatcher::class);
499
-				$dispatcher->dispatchTyped(new GroupDeletedEvent($group));
500
-			});
501
-			$groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
502
-				/** @var IEventDispatcher $dispatcher */
503
-				$dispatcher = $this->get(IEventDispatcher::class);
504
-				$dispatcher->dispatchTyped(new BeforeUserAddedEvent($group, $user));
505
-			});
506
-			$groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
507
-				/** @var IEventDispatcher $dispatcher */
508
-				$dispatcher = $this->get(IEventDispatcher::class);
509
-				$dispatcher->dispatchTyped(new UserAddedEvent($group, $user));
510
-			});
511
-			$groupManager->listen('\OC\Group', 'preRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
512
-				/** @var IEventDispatcher $dispatcher */
513
-				$dispatcher = $this->get(IEventDispatcher::class);
514
-				$dispatcher->dispatchTyped(new BeforeUserRemovedEvent($group, $user));
515
-			});
516
-			$groupManager->listen('\OC\Group', 'postRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
517
-				/** @var IEventDispatcher $dispatcher */
518
-				$dispatcher = $this->get(IEventDispatcher::class);
519
-				$dispatcher->dispatchTyped(new UserRemovedEvent($group, $user));
520
-			});
521
-			return $groupManager;
522
-		});
523
-		/** @deprecated 19.0.0 */
524
-		$this->registerDeprecatedAlias('GroupManager', \OCP\IGroupManager::class);
525
-
526
-		$this->registerService(Store::class, function (ContainerInterface $c) {
527
-			$session = $c->get(ISession::class);
528
-			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
529
-				$tokenProvider = $c->get(IProvider::class);
530
-			} else {
531
-				$tokenProvider = null;
532
-			}
533
-			$logger = $c->get(LoggerInterface::class);
534
-			return new Store($session, $logger, $tokenProvider);
535
-		});
536
-		$this->registerAlias(IStore::class, Store::class);
537
-		$this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
538
-
539
-		$this->registerService(\OC\User\Session::class, function (Server $c) {
540
-			$manager = $c->get(IUserManager::class);
541
-			$session = new \OC\Session\Memory('');
542
-			$timeFactory = new TimeFactory();
543
-			// Token providers might require a working database. This code
544
-			// might however be called when Nextcloud is not yet setup.
545
-			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
546
-				$provider = $c->get(IProvider::class);
547
-			} else {
548
-				$provider = null;
549
-			}
550
-
551
-			$legacyDispatcher = $c->get(SymfonyAdapter::class);
552
-
553
-			$userSession = new \OC\User\Session(
554
-				$manager,
555
-				$session,
556
-				$timeFactory,
557
-				$provider,
558
-				$c->get(\OCP\IConfig::class),
559
-				$c->get(ISecureRandom::class),
560
-				$c->getLockdownManager(),
561
-				$c->get(LoggerInterface::class),
562
-				$c->get(IEventDispatcher::class)
563
-			);
564
-			/** @deprecated 21.0.0 use BeforeUserCreatedEvent event with the IEventDispatcher instead */
565
-			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
566
-				\OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]);
567
-			});
568
-			/** @deprecated 21.0.0 use UserCreatedEvent event with the IEventDispatcher instead */
569
-			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
570
-				/** @var \OC\User\User $user */
571
-				\OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]);
572
-			});
573
-			/** @deprecated 21.0.0 use BeforeUserDeletedEvent event with the IEventDispatcher instead */
574
-			$userSession->listen('\OC\User', 'preDelete', function ($user) use ($legacyDispatcher) {
575
-				/** @var \OC\User\User $user */
576
-				\OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]);
577
-				$legacyDispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user));
578
-			});
579
-			/** @deprecated 21.0.0 use UserDeletedEvent event with the IEventDispatcher instead */
580
-			$userSession->listen('\OC\User', 'postDelete', function ($user) {
581
-				/** @var \OC\User\User $user */
582
-				\OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]);
583
-			});
584
-			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
585
-				/** @var \OC\User\User $user */
586
-				\OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
587
-
588
-				/** @var IEventDispatcher $dispatcher */
589
-				$dispatcher = $this->get(IEventDispatcher::class);
590
-				$dispatcher->dispatchTyped(new BeforePasswordUpdatedEvent($user, $password, $recoveryPassword));
591
-			});
592
-			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
593
-				/** @var \OC\User\User $user */
594
-				\OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
595
-
596
-				/** @var IEventDispatcher $dispatcher */
597
-				$dispatcher = $this->get(IEventDispatcher::class);
598
-				$dispatcher->dispatchTyped(new PasswordUpdatedEvent($user, $password, $recoveryPassword));
599
-			});
600
-			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
601
-				\OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]);
602
-
603
-				/** @var IEventDispatcher $dispatcher */
604
-				$dispatcher = $this->get(IEventDispatcher::class);
605
-				$dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password));
606
-			});
607
-			$userSession->listen('\OC\User', 'postLogin', function ($user, $loginName, $password, $isTokenLogin) {
608
-				/** @var \OC\User\User $user */
609
-				\OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'loginName' => $loginName, 'password' => $password, 'isTokenLogin' => $isTokenLogin]);
610
-
611
-				/** @var IEventDispatcher $dispatcher */
612
-				$dispatcher = $this->get(IEventDispatcher::class);
613
-				$dispatcher->dispatchTyped(new UserLoggedInEvent($user, $loginName, $password, $isTokenLogin));
614
-			});
615
-			$userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) {
616
-				/** @var IEventDispatcher $dispatcher */
617
-				$dispatcher = $this->get(IEventDispatcher::class);
618
-				$dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid));
619
-			});
620
-			$userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
621
-				/** @var \OC\User\User $user */
622
-				\OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]);
623
-
624
-				/** @var IEventDispatcher $dispatcher */
625
-				$dispatcher = $this->get(IEventDispatcher::class);
626
-				$dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password));
627
-			});
628
-			$userSession->listen('\OC\User', 'logout', function ($user) {
629
-				\OC_Hook::emit('OC_User', 'logout', []);
630
-
631
-				/** @var IEventDispatcher $dispatcher */
632
-				$dispatcher = $this->get(IEventDispatcher::class);
633
-				$dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user));
634
-			});
635
-			$userSession->listen('\OC\User', 'postLogout', function ($user) {
636
-				/** @var IEventDispatcher $dispatcher */
637
-				$dispatcher = $this->get(IEventDispatcher::class);
638
-				$dispatcher->dispatchTyped(new UserLoggedOutEvent($user));
639
-			});
640
-			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
641
-				/** @var \OC\User\User $user */
642
-				\OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]);
643
-
644
-				/** @var IEventDispatcher $dispatcher */
645
-				$dispatcher = $this->get(IEventDispatcher::class);
646
-				$dispatcher->dispatchTyped(new UserChangedEvent($user, $feature, $value, $oldValue));
647
-			});
648
-			return $userSession;
649
-		});
650
-		$this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class);
651
-		/** @deprecated 19.0.0 */
652
-		$this->registerDeprecatedAlias('UserSession', \OC\User\Session::class);
653
-
654
-		$this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class);
655
-
656
-		$this->registerAlias(INavigationManager::class, \OC\NavigationManager::class);
657
-		/** @deprecated 19.0.0 */
658
-		$this->registerDeprecatedAlias('NavigationManager', INavigationManager::class);
659
-
660
-		/** @deprecated 19.0.0 */
661
-		$this->registerDeprecatedAlias('AllConfig', \OC\AllConfig::class);
662
-		$this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
663
-
664
-		$this->registerService(\OC\SystemConfig::class, function ($c) use ($config) {
665
-			return new \OC\SystemConfig($config);
666
-		});
667
-		/** @deprecated 19.0.0 */
668
-		$this->registerDeprecatedAlias('SystemConfig', \OC\SystemConfig::class);
669
-
670
-		/** @deprecated 19.0.0 */
671
-		$this->registerDeprecatedAlias('AppConfig', \OC\AppConfig::class);
672
-		$this->registerAlias(IAppConfig::class, \OC\AppConfig::class);
673
-
674
-		$this->registerService(IFactory::class, function (Server $c) {
675
-			return new \OC\L10N\Factory(
676
-				$c->get(\OCP\IConfig::class),
677
-				$c->getRequest(),
678
-				$c->get(IUserSession::class),
679
-				\OC::$SERVERROOT
680
-			);
681
-		});
682
-		/** @deprecated 19.0.0 */
683
-		$this->registerDeprecatedAlias('L10NFactory', IFactory::class);
684
-
685
-		$this->registerAlias(IURLGenerator::class, URLGenerator::class);
686
-		/** @deprecated 19.0.0 */
687
-		$this->registerDeprecatedAlias('URLGenerator', IURLGenerator::class);
688
-
689
-		/** @deprecated 19.0.0 */
690
-		$this->registerDeprecatedAlias('AppFetcher', AppFetcher::class);
691
-		/** @deprecated 19.0.0 */
692
-		$this->registerDeprecatedAlias('CategoryFetcher', CategoryFetcher::class);
693
-
694
-		$this->registerService(ICache::class, function ($c) {
695
-			return new Cache\File();
696
-		});
697
-		/** @deprecated 19.0.0 */
698
-		$this->registerDeprecatedAlias('UserCache', ICache::class);
699
-
700
-		$this->registerService(Factory::class, function (Server $c) {
701
-			$profiler = $c->get(IProfiler::class);
702
-			$arrayCacheFactory = new \OC\Memcache\Factory('', $c->get(LoggerInterface::class),
703
-				$profiler,
704
-				ArrayCache::class,
705
-				ArrayCache::class,
706
-				ArrayCache::class
707
-			);
708
-			/** @var \OCP\IConfig $config */
709
-			$config = $c->get(\OCP\IConfig::class);
710
-
711
-			if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
712
-				if (!$config->getSystemValueBool('log_query')) {
713
-					$v = \OC_App::getAppVersions();
714
-				} else {
715
-					// If the log_query is enabled, we can not get the app versions
716
-					// as that does a query, which will be logged and the logging
717
-					// depends on redis and here we are back again in the same function.
718
-					$v = [
719
-						'log_query' => 'enabled',
720
-					];
721
-				}
722
-				$v['core'] = implode(',', \OC_Util::getVersion());
723
-				$version = implode(',', $v);
724
-				$instanceId = \OC_Util::getInstanceId();
725
-				$path = \OC::$SERVERROOT;
726
-				$prefix = md5($instanceId . '-' . $version . '-' . $path);
727
-				return new \OC\Memcache\Factory($prefix,
728
-					$c->get(LoggerInterface::class),
729
-					$profiler,
730
-					$config->getSystemValue('memcache.local', null),
731
-					$config->getSystemValue('memcache.distributed', null),
732
-					$config->getSystemValue('memcache.locking', null),
733
-					$config->getSystemValueString('redis_log_file')
734
-				);
735
-			}
736
-			return $arrayCacheFactory;
737
-		});
738
-		/** @deprecated 19.0.0 */
739
-		$this->registerDeprecatedAlias('MemCacheFactory', Factory::class);
740
-		$this->registerAlias(ICacheFactory::class, Factory::class);
741
-
742
-		$this->registerService('RedisFactory', function (Server $c) {
743
-			$systemConfig = $c->get(SystemConfig::class);
744
-			return new RedisFactory($systemConfig, $c->getEventLogger());
745
-		});
746
-
747
-		$this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
748
-			$l10n = $this->get(IFactory::class)->get('lib');
749
-			return new \OC\Activity\Manager(
750
-				$c->getRequest(),
751
-				$c->get(IUserSession::class),
752
-				$c->get(\OCP\IConfig::class),
753
-				$c->get(IValidator::class),
754
-				$l10n
755
-			);
756
-		});
757
-		/** @deprecated 19.0.0 */
758
-		$this->registerDeprecatedAlias('ActivityManager', \OCP\Activity\IManager::class);
759
-
760
-		$this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
761
-			return new \OC\Activity\EventMerger(
762
-				$c->getL10N('lib')
763
-			);
764
-		});
765
-		$this->registerAlias(IValidator::class, Validator::class);
766
-
767
-		$this->registerService(AvatarManager::class, function (Server $c) {
768
-			return new AvatarManager(
769
-				$c->get(IUserSession::class),
770
-				$c->get(\OC\User\Manager::class),
771
-				$c->getAppDataDir('avatar'),
772
-				$c->getL10N('lib'),
773
-				$c->get(LoggerInterface::class),
774
-				$c->get(\OCP\IConfig::class),
775
-				$c->get(IAccountManager::class),
776
-				$c->get(KnownUserService::class)
777
-			);
778
-		});
779
-
780
-		$this->registerAlias(IAvatarManager::class, AvatarManager::class);
781
-		/** @deprecated 19.0.0 */
782
-		$this->registerDeprecatedAlias('AvatarManager', AvatarManager::class);
783
-
784
-		$this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
785
-		$this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class);
786
-
787
-		$this->registerService(\OC\Log::class, function (Server $c) {
788
-			$logType = $c->get(AllConfig::class)->getSystemValue('log_type', 'file');
789
-			$factory = new LogFactory($c, $this->get(SystemConfig::class));
790
-			$logger = $factory->get($logType);
791
-			$registry = $c->get(\OCP\Support\CrashReport\IRegistry::class);
792
-
793
-			return new Log($logger, $this->get(SystemConfig::class), null, $registry);
794
-		});
795
-		$this->registerAlias(ILogger::class, \OC\Log::class);
796
-		/** @deprecated 19.0.0 */
797
-		$this->registerDeprecatedAlias('Logger', \OC\Log::class);
798
-		// PSR-3 logger
799
-		$this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class);
800
-
801
-		$this->registerService(ILogFactory::class, function (Server $c) {
802
-			return new LogFactory($c, $this->get(SystemConfig::class));
803
-		});
804
-
805
-		$this->registerAlias(IJobList::class, \OC\BackgroundJob\JobList::class);
806
-		/** @deprecated 19.0.0 */
807
-		$this->registerDeprecatedAlias('JobList', IJobList::class);
808
-
809
-		$this->registerService(Router::class, function (Server $c) {
810
-			$cacheFactory = $c->get(ICacheFactory::class);
811
-			$logger = $c->get(LoggerInterface::class);
812
-			if ($cacheFactory->isLocalCacheAvailable()) {
813
-				$router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger);
814
-			} else {
815
-				$router = new \OC\Route\Router($logger);
816
-			}
817
-			return $router;
818
-		});
819
-		$this->registerAlias(IRouter::class, Router::class);
820
-		/** @deprecated 19.0.0 */
821
-		$this->registerDeprecatedAlias('Router', IRouter::class);
822
-
823
-		$this->registerAlias(ISearch::class, Search::class);
824
-		/** @deprecated 19.0.0 */
825
-		$this->registerDeprecatedAlias('Search', ISearch::class);
826
-
827
-		$this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
828
-			$cacheFactory = $c->get(ICacheFactory::class);
829
-			if ($cacheFactory->isAvailable()) {
830
-				$backend = new \OC\Security\RateLimiting\Backend\MemoryCacheBackend(
831
-					$this->get(ICacheFactory::class),
832
-					new \OC\AppFramework\Utility\TimeFactory()
833
-				);
834
-			} else {
835
-				$backend = new \OC\Security\RateLimiting\Backend\DatabaseBackend(
836
-					$c->get(IDBConnection::class),
837
-					new \OC\AppFramework\Utility\TimeFactory()
838
-				);
839
-			}
840
-
841
-			return $backend;
842
-		});
843
-
844
-		$this->registerAlias(\OCP\Security\ISecureRandom::class, SecureRandom::class);
845
-		/** @deprecated 19.0.0 */
846
-		$this->registerDeprecatedAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
847
-
848
-		$this->registerAlias(IVerificationToken::class, VerificationToken::class);
849
-
850
-		$this->registerAlias(ICrypto::class, Crypto::class);
851
-		/** @deprecated 19.0.0 */
852
-		$this->registerDeprecatedAlias('Crypto', ICrypto::class);
853
-
854
-		$this->registerAlias(IHasher::class, Hasher::class);
855
-		/** @deprecated 19.0.0 */
856
-		$this->registerDeprecatedAlias('Hasher', IHasher::class);
857
-
858
-		$this->registerAlias(ICredentialsManager::class, CredentialsManager::class);
859
-		/** @deprecated 19.0.0 */
860
-		$this->registerDeprecatedAlias('CredentialsManager', ICredentialsManager::class);
861
-
862
-		$this->registerAlias(IDBConnection::class, ConnectionAdapter::class);
863
-		$this->registerService(Connection::class, function (Server $c) {
864
-			$systemConfig = $c->get(SystemConfig::class);
865
-			$factory = new \OC\DB\ConnectionFactory($systemConfig);
866
-			$type = $systemConfig->getValue('dbtype', 'sqlite');
867
-			if (!$factory->isValidType($type)) {
868
-				throw new \OC\DatabaseException('Invalid database type');
869
-			}
870
-			$connectionParams = $factory->createConnectionParams();
871
-			$connection = $factory->getConnection($type, $connectionParams);
872
-			return $connection;
873
-		});
874
-		/** @deprecated 19.0.0 */
875
-		$this->registerDeprecatedAlias('DatabaseConnection', IDBConnection::class);
876
-
877
-		$this->registerAlias(ICertificateManager::class, CertificateManager::class);
878
-		$this->registerAlias(IClientService::class, ClientService::class);
879
-		$this->registerService(LocalAddressChecker::class, function (ContainerInterface $c) {
880
-			return new LocalAddressChecker(
881
-				$c->get(LoggerInterface::class),
882
-			);
883
-		});
884
-		$this->registerService(NegativeDnsCache::class, function (ContainerInterface $c) {
885
-			return new NegativeDnsCache(
886
-				$c->get(ICacheFactory::class),
887
-			);
888
-		});
889
-		$this->registerService(DnsPinMiddleware::class, function (ContainerInterface $c) {
890
-			return new DnsPinMiddleware(
891
-				$c->get(NegativeDnsCache::class),
892
-				$c->get(LocalAddressChecker::class)
893
-			);
894
-		});
895
-		$this->registerDeprecatedAlias('HttpClientService', IClientService::class);
896
-		$this->registerService(IEventLogger::class, function (ContainerInterface $c) {
897
-			return new EventLogger($c->get(SystemConfig::class), $c->get(LoggerInterface::class), $c->get(Log::class));
898
-		});
899
-		/** @deprecated 19.0.0 */
900
-		$this->registerDeprecatedAlias('EventLogger', IEventLogger::class);
901
-
902
-		$this->registerService(IQueryLogger::class, function (ContainerInterface $c) {
903
-			$queryLogger = new QueryLogger();
904
-			if ($c->get(SystemConfig::class)->getValue('debug', false)) {
905
-				// In debug mode, module is being activated by default
906
-				$queryLogger->activate();
907
-			}
908
-			return $queryLogger;
909
-		});
910
-		/** @deprecated 19.0.0 */
911
-		$this->registerDeprecatedAlias('QueryLogger', IQueryLogger::class);
912
-
913
-		/** @deprecated 19.0.0 */
914
-		$this->registerDeprecatedAlias('TempManager', TempManager::class);
915
-		$this->registerAlias(ITempManager::class, TempManager::class);
916
-
917
-		$this->registerService(AppManager::class, function (ContainerInterface $c) {
918
-			// TODO: use auto-wiring
919
-			return new \OC\App\AppManager(
920
-				$c->get(IUserSession::class),
921
-				$c->get(\OCP\IConfig::class),
922
-				$c->get(\OC\AppConfig::class),
923
-				$c->get(IGroupManager::class),
924
-				$c->get(ICacheFactory::class),
925
-				$c->get(SymfonyAdapter::class),
926
-				$c->get(LoggerInterface::class)
927
-			);
928
-		});
929
-		/** @deprecated 19.0.0 */
930
-		$this->registerDeprecatedAlias('AppManager', AppManager::class);
931
-		$this->registerAlias(IAppManager::class, AppManager::class);
932
-
933
-		$this->registerAlias(IDateTimeZone::class, DateTimeZone::class);
934
-		/** @deprecated 19.0.0 */
935
-		$this->registerDeprecatedAlias('DateTimeZone', IDateTimeZone::class);
936
-
937
-		$this->registerService(IDateTimeFormatter::class, function (Server $c) {
938
-			$language = $c->get(\OCP\IConfig::class)->getUserValue($c->get(ISession::class)->get('user_id'), 'core', 'lang', null);
939
-
940
-			return new DateTimeFormatter(
941
-				$c->get(IDateTimeZone::class)->getTimeZone(),
942
-				$c->getL10N('lib', $language)
943
-			);
944
-		});
945
-		/** @deprecated 19.0.0 */
946
-		$this->registerDeprecatedAlias('DateTimeFormatter', IDateTimeFormatter::class);
947
-
948
-		$this->registerService(IUserMountCache::class, function (ContainerInterface $c) {
949
-			$mountCache = new UserMountCache(
950
-				$c->get(IDBConnection::class),
951
-				$c->get(IUserManager::class),
952
-				$c->get(LoggerInterface::class)
953
-			);
954
-			$listener = new UserMountCacheListener($mountCache);
955
-			$listener->listen($c->get(IUserManager::class));
956
-			return $mountCache;
957
-		});
958
-		/** @deprecated 19.0.0 */
959
-		$this->registerDeprecatedAlias('UserMountCache', IUserMountCache::class);
960
-
961
-		$this->registerService(IMountProviderCollection::class, function (ContainerInterface $c) {
962
-			$loader = \OC\Files\Filesystem::getLoader();
963
-			$mountCache = $c->get(IUserMountCache::class);
964
-			$manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
965
-
966
-			// builtin providers
967
-
968
-			$config = $c->get(\OCP\IConfig::class);
969
-			$logger = $c->get(LoggerInterface::class);
970
-			$manager->registerProvider(new CacheMountProvider($config));
971
-			$manager->registerHomeProvider(new LocalHomeMountProvider());
972
-			$manager->registerHomeProvider(new ObjectHomeMountProvider($config));
973
-			$manager->registerRootProvider(new RootMountProvider($config, $c->get(LoggerInterface::class)));
974
-			$manager->registerRootProvider(new ObjectStorePreviewCacheMountProvider($logger, $config));
975
-
976
-			return $manager;
977
-		});
978
-		/** @deprecated 19.0.0 */
979
-		$this->registerDeprecatedAlias('MountConfigManager', IMountProviderCollection::class);
980
-
981
-		/** @deprecated 20.0.0 */
982
-		$this->registerDeprecatedAlias('IniWrapper', IniGetWrapper::class);
983
-		$this->registerService(IBus::class, function (ContainerInterface $c) {
984
-			$busClass = $c->get(\OCP\IConfig::class)->getSystemValue('commandbus');
985
-			if ($busClass) {
986
-				[$app, $class] = explode('::', $busClass, 2);
987
-				if ($c->get(IAppManager::class)->isInstalled($app)) {
988
-					\OC_App::loadApp($app);
989
-					return $c->get($class);
990
-				} else {
991
-					throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
992
-				}
993
-			} else {
994
-				$jobList = $c->get(IJobList::class);
995
-				return new CronBus($jobList);
996
-			}
997
-		});
998
-		$this->registerDeprecatedAlias('AsyncCommandBus', IBus::class);
999
-		/** @deprecated 20.0.0 */
1000
-		$this->registerDeprecatedAlias('TrustedDomainHelper', TrustedDomainHelper::class);
1001
-		$this->registerAlias(ITrustedDomainHelper::class, TrustedDomainHelper::class);
1002
-		/** @deprecated 19.0.0 */
1003
-		$this->registerDeprecatedAlias('Throttler', Throttler::class);
1004
-		$this->registerService('IntegrityCodeChecker', function (ContainerInterface $c) {
1005
-			// IConfig and IAppManager requires a working database. This code
1006
-			// might however be called when ownCloud is not yet setup.
1007
-			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
1008
-				$config = $c->get(\OCP\IConfig::class);
1009
-				$appManager = $c->get(IAppManager::class);
1010
-			} else {
1011
-				$config = null;
1012
-				$appManager = null;
1013
-			}
1014
-
1015
-			return new Checker(
1016
-				new EnvironmentHelper(),
1017
-				new FileAccessHelper(),
1018
-				new AppLocator(),
1019
-				$config,
1020
-				$c->get(ICacheFactory::class),
1021
-				$appManager,
1022
-				$c->get(IMimeTypeDetector::class)
1023
-			);
1024
-		});
1025
-		$this->registerService(\OCP\IRequest::class, function (ContainerInterface $c) {
1026
-			if (isset($this['urlParams'])) {
1027
-				$urlParams = $this['urlParams'];
1028
-			} else {
1029
-				$urlParams = [];
1030
-			}
1031
-
1032
-			if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
1033
-				&& in_array('fakeinput', stream_get_wrappers())
1034
-			) {
1035
-				$stream = 'fakeinput://data';
1036
-			} else {
1037
-				$stream = 'php://input';
1038
-			}
1039
-
1040
-			return new Request(
1041
-				[
1042
-					'get' => $_GET,
1043
-					'post' => $_POST,
1044
-					'files' => $_FILES,
1045
-					'server' => $_SERVER,
1046
-					'env' => $_ENV,
1047
-					'cookies' => $_COOKIE,
1048
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1049
-						? $_SERVER['REQUEST_METHOD']
1050
-						: '',
1051
-					'urlParams' => $urlParams,
1052
-				],
1053
-				$this->get(IRequestId::class),
1054
-				$this->get(\OCP\IConfig::class),
1055
-				$this->get(CsrfTokenManager::class),
1056
-				$stream
1057
-			);
1058
-		});
1059
-		/** @deprecated 19.0.0 */
1060
-		$this->registerDeprecatedAlias('Request', \OCP\IRequest::class);
1061
-
1062
-		$this->registerService(IRequestId::class, function (ContainerInterface $c): IRequestId {
1063
-			return new RequestId(
1064
-				$_SERVER['UNIQUE_ID'] ?? '',
1065
-				$this->get(ISecureRandom::class)
1066
-			);
1067
-		});
1068
-
1069
-		$this->registerService(IMailer::class, function (Server $c) {
1070
-			return new Mailer(
1071
-				$c->get(\OCP\IConfig::class),
1072
-				$c->get(LoggerInterface::class),
1073
-				$c->get(Defaults::class),
1074
-				$c->get(IURLGenerator::class),
1075
-				$c->getL10N('lib'),
1076
-				$c->get(IEventDispatcher::class),
1077
-				$c->get(IFactory::class)
1078
-			);
1079
-		});
1080
-		/** @deprecated 19.0.0 */
1081
-		$this->registerDeprecatedAlias('Mailer', IMailer::class);
1082
-
1083
-		/** @deprecated 21.0.0 */
1084
-		$this->registerDeprecatedAlias('LDAPProvider', ILDAPProvider::class);
1085
-
1086
-		$this->registerService(ILDAPProviderFactory::class, function (ContainerInterface $c) {
1087
-			$config = $c->get(\OCP\IConfig::class);
1088
-			$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
1089
-			if (is_null($factoryClass) || !class_exists($factoryClass)) {
1090
-				return new NullLDAPProviderFactory($this);
1091
-			}
1092
-			/** @var \OCP\LDAP\ILDAPProviderFactory $factory */
1093
-			return new $factoryClass($this);
1094
-		});
1095
-		$this->registerService(ILDAPProvider::class, function (ContainerInterface $c) {
1096
-			$factory = $c->get(ILDAPProviderFactory::class);
1097
-			return $factory->getLDAPProvider();
1098
-		});
1099
-		$this->registerService(ILockingProvider::class, function (ContainerInterface $c) {
1100
-			$ini = $c->get(IniGetWrapper::class);
1101
-			$config = $c->get(\OCP\IConfig::class);
1102
-			$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
1103
-			if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
1104
-				/** @var \OC\Memcache\Factory $memcacheFactory */
1105
-				$memcacheFactory = $c->get(ICacheFactory::class);
1106
-				$memcache = $memcacheFactory->createLocking('lock');
1107
-				if (!($memcache instanceof \OC\Memcache\NullCache)) {
1108
-					return new MemcacheLockingProvider($memcache, $ttl);
1109
-				}
1110
-				return new DBLockingProvider(
1111
-					$c->get(IDBConnection::class),
1112
-					$c->get(LoggerInterface::class),
1113
-					new TimeFactory(),
1114
-					$ttl,
1115
-					!\OC::$CLI
1116
-				);
1117
-			}
1118
-			return new NoopLockingProvider();
1119
-		});
1120
-		/** @deprecated 19.0.0 */
1121
-		$this->registerDeprecatedAlias('LockingProvider', ILockingProvider::class);
1122
-
1123
-		$this->registerService(ILockManager::class, function (Server $c): LockManager {
1124
-			return new LockManager();
1125
-		});
1126
-
1127
-		$this->registerAlias(ILockdownManager::class, 'LockdownManager');
1128
-		$this->registerService(SetupManager::class, function ($c) {
1129
-			// create the setupmanager through the mount manager to resolve the cyclic dependency
1130
-			return $c->get(\OC\Files\Mount\Manager::class)->getSetupManager();
1131
-		});
1132
-		$this->registerAlias(IMountManager::class, \OC\Files\Mount\Manager::class);
1133
-		/** @deprecated 19.0.0 */
1134
-		$this->registerDeprecatedAlias('MountManager', IMountManager::class);
1135
-
1136
-		$this->registerService(IMimeTypeDetector::class, function (ContainerInterface $c) {
1137
-			return new \OC\Files\Type\Detection(
1138
-				$c->get(IURLGenerator::class),
1139
-				$c->get(LoggerInterface::class),
1140
-				\OC::$configDir,
1141
-				\OC::$SERVERROOT . '/resources/config/'
1142
-			);
1143
-		});
1144
-		/** @deprecated 19.0.0 */
1145
-		$this->registerDeprecatedAlias('MimeTypeDetector', IMimeTypeDetector::class);
1146
-
1147
-		$this->registerAlias(IMimeTypeLoader::class, Loader::class);
1148
-		/** @deprecated 19.0.0 */
1149
-		$this->registerDeprecatedAlias('MimeTypeLoader', IMimeTypeLoader::class);
1150
-		$this->registerService(BundleFetcher::class, function () {
1151
-			return new BundleFetcher($this->getL10N('lib'));
1152
-		});
1153
-		$this->registerAlias(\OCP\Notification\IManager::class, Manager::class);
1154
-		/** @deprecated 19.0.0 */
1155
-		$this->registerDeprecatedAlias('NotificationManager', \OCP\Notification\IManager::class);
1156
-
1157
-		$this->registerService(CapabilitiesManager::class, function (ContainerInterface $c) {
1158
-			$manager = new CapabilitiesManager($c->get(LoggerInterface::class));
1159
-			$manager->registerCapability(function () use ($c) {
1160
-				return new \OC\OCS\CoreCapabilities($c->get(\OCP\IConfig::class));
1161
-			});
1162
-			$manager->registerCapability(function () use ($c) {
1163
-				return $c->get(\OC\Security\Bruteforce\Capabilities::class);
1164
-			});
1165
-			$manager->registerCapability(function () use ($c) {
1166
-				return $c->get(MetadataCapabilities::class);
1167
-			});
1168
-			return $manager;
1169
-		});
1170
-		/** @deprecated 19.0.0 */
1171
-		$this->registerDeprecatedAlias('CapabilitiesManager', CapabilitiesManager::class);
1172
-
1173
-		$this->registerService(ICommentsManager::class, function (Server $c) {
1174
-			$config = $c->get(\OCP\IConfig::class);
1175
-			$factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class);
1176
-			/** @var \OCP\Comments\ICommentsManagerFactory $factory */
1177
-			$factory = new $factoryClass($this);
1178
-			$manager = $factory->getManager();
1179
-
1180
-			$manager->registerDisplayNameResolver('user', function ($id) use ($c) {
1181
-				$manager = $c->get(IUserManager::class);
1182
-				$user = $manager->get($id);
1183
-				if (is_null($user)) {
1184
-					$l = $c->getL10N('core');
1185
-					$displayName = $l->t('Unknown user');
1186
-				} else {
1187
-					$displayName = $user->getDisplayName();
1188
-				}
1189
-				return $displayName;
1190
-			});
1191
-
1192
-			return $manager;
1193
-		});
1194
-		/** @deprecated 19.0.0 */
1195
-		$this->registerDeprecatedAlias('CommentsManager', ICommentsManager::class);
1196
-
1197
-		$this->registerAlias(\OC_Defaults::class, 'ThemingDefaults');
1198
-		$this->registerService('ThemingDefaults', function (Server $c) {
1199
-			/*
276
+    /** @var string */
277
+    private $webRoot;
278
+
279
+    /**
280
+     * @param string $webRoot
281
+     * @param \OC\Config $config
282
+     */
283
+    public function __construct($webRoot, \OC\Config $config) {
284
+        parent::__construct();
285
+        $this->webRoot = $webRoot;
286
+
287
+        // To find out if we are running from CLI or not
288
+        $this->registerParameter('isCLI', \OC::$CLI);
289
+        $this->registerParameter('serverRoot', \OC::$SERVERROOT);
290
+
291
+        $this->registerService(ContainerInterface::class, function (ContainerInterface $c) {
292
+            return $c;
293
+        });
294
+        $this->registerService(\OCP\IServerContainer::class, function (ContainerInterface $c) {
295
+            return $c;
296
+        });
297
+
298
+        $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
299
+        /** @deprecated 19.0.0 */
300
+        $this->registerDeprecatedAlias('CalendarManager', \OC\Calendar\Manager::class);
301
+
302
+        $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class);
303
+        /** @deprecated 19.0.0 */
304
+        $this->registerDeprecatedAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class);
305
+
306
+        $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class);
307
+        /** @deprecated 19.0.0 */
308
+        $this->registerDeprecatedAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class);
309
+
310
+        $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
311
+        /** @deprecated 19.0.0 */
312
+        $this->registerDeprecatedAlias('ContactsManager', \OCP\Contacts\IManager::class);
313
+
314
+        $this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class);
315
+        $this->registerAlias(ITemplateManager::class, TemplateManager::class);
316
+
317
+        $this->registerAlias(IActionFactory::class, ActionFactory::class);
318
+
319
+        $this->registerService(View::class, function (Server $c) {
320
+            return new View();
321
+        }, false);
322
+
323
+        $this->registerService(IPreview::class, function (ContainerInterface $c) {
324
+            return new PreviewManager(
325
+                $c->get(\OCP\IConfig::class),
326
+                $c->get(IRootFolder::class),
327
+                new \OC\Preview\Storage\Root(
328
+                    $c->get(IRootFolder::class),
329
+                    $c->get(SystemConfig::class)
330
+                ),
331
+                $c->get(SymfonyAdapter::class),
332
+                $c->get(GeneratorHelper::class),
333
+                $c->get(ISession::class)->get('user_id'),
334
+                $c->get(Coordinator::class),
335
+                $c->get(IServerContainer::class)
336
+            );
337
+        });
338
+        /** @deprecated 19.0.0 */
339
+        $this->registerDeprecatedAlias('PreviewManager', IPreview::class);
340
+
341
+        $this->registerService(\OC\Preview\Watcher::class, function (ContainerInterface $c) {
342
+            return new \OC\Preview\Watcher(
343
+                new \OC\Preview\Storage\Root(
344
+                    $c->get(IRootFolder::class),
345
+                    $c->get(SystemConfig::class)
346
+                )
347
+            );
348
+        });
349
+
350
+        $this->registerService(IProfiler::class, function (Server $c) {
351
+            return new Profiler($c->get(SystemConfig::class));
352
+        });
353
+
354
+        $this->registerService(\OCP\Encryption\IManager::class, function (Server $c) {
355
+            $view = new View();
356
+            $util = new Encryption\Util(
357
+                $view,
358
+                $c->get(IUserManager::class),
359
+                $c->get(IGroupManager::class),
360
+                $c->get(\OCP\IConfig::class)
361
+            );
362
+            return new Encryption\Manager(
363
+                $c->get(\OCP\IConfig::class),
364
+                $c->get(LoggerInterface::class),
365
+                $c->getL10N('core'),
366
+                new View(),
367
+                $util,
368
+                new ArrayCache()
369
+            );
370
+        });
371
+        /** @deprecated 19.0.0 */
372
+        $this->registerDeprecatedAlias('EncryptionManager', \OCP\Encryption\IManager::class);
373
+
374
+        /** @deprecated 21.0.0 */
375
+        $this->registerDeprecatedAlias('EncryptionFileHelper', IFile::class);
376
+        $this->registerService(IFile::class, function (ContainerInterface $c) {
377
+            $util = new Encryption\Util(
378
+                new View(),
379
+                $c->get(IUserManager::class),
380
+                $c->get(IGroupManager::class),
381
+                $c->get(\OCP\IConfig::class)
382
+            );
383
+            return new Encryption\File(
384
+                $util,
385
+                $c->get(IRootFolder::class),
386
+                $c->get(\OCP\Share\IManager::class)
387
+            );
388
+        });
389
+
390
+        /** @deprecated 21.0.0 */
391
+        $this->registerDeprecatedAlias('EncryptionKeyStorage', IStorage::class);
392
+        $this->registerService(IStorage::class, function (ContainerInterface $c) {
393
+            $view = new View();
394
+            $util = new Encryption\Util(
395
+                $view,
396
+                $c->get(IUserManager::class),
397
+                $c->get(IGroupManager::class),
398
+                $c->get(\OCP\IConfig::class)
399
+            );
400
+
401
+            return new Encryption\Keys\Storage(
402
+                $view,
403
+                $util,
404
+                $c->get(ICrypto::class),
405
+                $c->get(\OCP\IConfig::class)
406
+            );
407
+        });
408
+        /** @deprecated 20.0.0 */
409
+        $this->registerDeprecatedAlias('TagMapper', TagMapper::class);
410
+
411
+        $this->registerAlias(\OCP\ITagManager::class, TagManager::class);
412
+        /** @deprecated 19.0.0 */
413
+        $this->registerDeprecatedAlias('TagManager', \OCP\ITagManager::class);
414
+
415
+        $this->registerService('SystemTagManagerFactory', function (ContainerInterface $c) {
416
+            /** @var \OCP\IConfig $config */
417
+            $config = $c->get(\OCP\IConfig::class);
418
+            $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class);
419
+            return new $factoryClass($this);
420
+        });
421
+        $this->registerService(ISystemTagManager::class, function (ContainerInterface $c) {
422
+            return $c->get('SystemTagManagerFactory')->getManager();
423
+        });
424
+        /** @deprecated 19.0.0 */
425
+        $this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class);
426
+
427
+        $this->registerService(ISystemTagObjectMapper::class, function (ContainerInterface $c) {
428
+            return $c->get('SystemTagManagerFactory')->getObjectMapper();
429
+        });
430
+        $this->registerService('RootFolder', function (ContainerInterface $c) {
431
+            $manager = \OC\Files\Filesystem::getMountManager(null);
432
+            $view = new View();
433
+            $root = new Root(
434
+                $manager,
435
+                $view,
436
+                null,
437
+                $c->get(IUserMountCache::class),
438
+                $this->get(LoggerInterface::class),
439
+                $this->get(IUserManager::class),
440
+                $this->get(IEventDispatcher::class),
441
+            );
442
+
443
+            $previewConnector = new \OC\Preview\WatcherConnector(
444
+                $root,
445
+                $c->get(SystemConfig::class)
446
+            );
447
+            $previewConnector->connectWatcher();
448
+
449
+            return $root;
450
+        });
451
+        $this->registerService(HookConnector::class, function (ContainerInterface $c) {
452
+            return new HookConnector(
453
+                $c->get(IRootFolder::class),
454
+                new View(),
455
+                $c->get(\OC\EventDispatcher\SymfonyAdapter::class),
456
+                $c->get(IEventDispatcher::class)
457
+            );
458
+        });
459
+
460
+        /** @deprecated 19.0.0 */
461
+        $this->registerDeprecatedAlias('SystemTagObjectMapper', ISystemTagObjectMapper::class);
462
+
463
+        $this->registerService(IRootFolder::class, function (ContainerInterface $c) {
464
+            return new LazyRoot(function () use ($c) {
465
+                return $c->get('RootFolder');
466
+            });
467
+        });
468
+        /** @deprecated 19.0.0 */
469
+        $this->registerDeprecatedAlias('LazyRootFolder', IRootFolder::class);
470
+
471
+        /** @deprecated 19.0.0 */
472
+        $this->registerDeprecatedAlias('UserManager', \OC\User\Manager::class);
473
+        $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
474
+
475
+        $this->registerService(\OCP\IGroupManager::class, function (ContainerInterface $c) {
476
+            $groupManager = new \OC\Group\Manager(
477
+                $this->get(IUserManager::class),
478
+                $c->get(SymfonyAdapter::class),
479
+                $this->get(LoggerInterface::class)
480
+            );
481
+            $groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
482
+                /** @var IEventDispatcher $dispatcher */
483
+                $dispatcher = $this->get(IEventDispatcher::class);
484
+                $dispatcher->dispatchTyped(new BeforeGroupCreatedEvent($gid));
485
+            });
486
+            $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $group) {
487
+                /** @var IEventDispatcher $dispatcher */
488
+                $dispatcher = $this->get(IEventDispatcher::class);
489
+                $dispatcher->dispatchTyped(new GroupCreatedEvent($group));
490
+            });
491
+            $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
492
+                /** @var IEventDispatcher $dispatcher */
493
+                $dispatcher = $this->get(IEventDispatcher::class);
494
+                $dispatcher->dispatchTyped(new BeforeGroupDeletedEvent($group));
495
+            });
496
+            $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
497
+                /** @var IEventDispatcher $dispatcher */
498
+                $dispatcher = $this->get(IEventDispatcher::class);
499
+                $dispatcher->dispatchTyped(new GroupDeletedEvent($group));
500
+            });
501
+            $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
502
+                /** @var IEventDispatcher $dispatcher */
503
+                $dispatcher = $this->get(IEventDispatcher::class);
504
+                $dispatcher->dispatchTyped(new BeforeUserAddedEvent($group, $user));
505
+            });
506
+            $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
507
+                /** @var IEventDispatcher $dispatcher */
508
+                $dispatcher = $this->get(IEventDispatcher::class);
509
+                $dispatcher->dispatchTyped(new UserAddedEvent($group, $user));
510
+            });
511
+            $groupManager->listen('\OC\Group', 'preRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
512
+                /** @var IEventDispatcher $dispatcher */
513
+                $dispatcher = $this->get(IEventDispatcher::class);
514
+                $dispatcher->dispatchTyped(new BeforeUserRemovedEvent($group, $user));
515
+            });
516
+            $groupManager->listen('\OC\Group', 'postRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
517
+                /** @var IEventDispatcher $dispatcher */
518
+                $dispatcher = $this->get(IEventDispatcher::class);
519
+                $dispatcher->dispatchTyped(new UserRemovedEvent($group, $user));
520
+            });
521
+            return $groupManager;
522
+        });
523
+        /** @deprecated 19.0.0 */
524
+        $this->registerDeprecatedAlias('GroupManager', \OCP\IGroupManager::class);
525
+
526
+        $this->registerService(Store::class, function (ContainerInterface $c) {
527
+            $session = $c->get(ISession::class);
528
+            if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
529
+                $tokenProvider = $c->get(IProvider::class);
530
+            } else {
531
+                $tokenProvider = null;
532
+            }
533
+            $logger = $c->get(LoggerInterface::class);
534
+            return new Store($session, $logger, $tokenProvider);
535
+        });
536
+        $this->registerAlias(IStore::class, Store::class);
537
+        $this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
538
+
539
+        $this->registerService(\OC\User\Session::class, function (Server $c) {
540
+            $manager = $c->get(IUserManager::class);
541
+            $session = new \OC\Session\Memory('');
542
+            $timeFactory = new TimeFactory();
543
+            // Token providers might require a working database. This code
544
+            // might however be called when Nextcloud is not yet setup.
545
+            if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
546
+                $provider = $c->get(IProvider::class);
547
+            } else {
548
+                $provider = null;
549
+            }
550
+
551
+            $legacyDispatcher = $c->get(SymfonyAdapter::class);
552
+
553
+            $userSession = new \OC\User\Session(
554
+                $manager,
555
+                $session,
556
+                $timeFactory,
557
+                $provider,
558
+                $c->get(\OCP\IConfig::class),
559
+                $c->get(ISecureRandom::class),
560
+                $c->getLockdownManager(),
561
+                $c->get(LoggerInterface::class),
562
+                $c->get(IEventDispatcher::class)
563
+            );
564
+            /** @deprecated 21.0.0 use BeforeUserCreatedEvent event with the IEventDispatcher instead */
565
+            $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
566
+                \OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]);
567
+            });
568
+            /** @deprecated 21.0.0 use UserCreatedEvent event with the IEventDispatcher instead */
569
+            $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
570
+                /** @var \OC\User\User $user */
571
+                \OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]);
572
+            });
573
+            /** @deprecated 21.0.0 use BeforeUserDeletedEvent event with the IEventDispatcher instead */
574
+            $userSession->listen('\OC\User', 'preDelete', function ($user) use ($legacyDispatcher) {
575
+                /** @var \OC\User\User $user */
576
+                \OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]);
577
+                $legacyDispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user));
578
+            });
579
+            /** @deprecated 21.0.0 use UserDeletedEvent event with the IEventDispatcher instead */
580
+            $userSession->listen('\OC\User', 'postDelete', function ($user) {
581
+                /** @var \OC\User\User $user */
582
+                \OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]);
583
+            });
584
+            $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
585
+                /** @var \OC\User\User $user */
586
+                \OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
587
+
588
+                /** @var IEventDispatcher $dispatcher */
589
+                $dispatcher = $this->get(IEventDispatcher::class);
590
+                $dispatcher->dispatchTyped(new BeforePasswordUpdatedEvent($user, $password, $recoveryPassword));
591
+            });
592
+            $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
593
+                /** @var \OC\User\User $user */
594
+                \OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
595
+
596
+                /** @var IEventDispatcher $dispatcher */
597
+                $dispatcher = $this->get(IEventDispatcher::class);
598
+                $dispatcher->dispatchTyped(new PasswordUpdatedEvent($user, $password, $recoveryPassword));
599
+            });
600
+            $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
601
+                \OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]);
602
+
603
+                /** @var IEventDispatcher $dispatcher */
604
+                $dispatcher = $this->get(IEventDispatcher::class);
605
+                $dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password));
606
+            });
607
+            $userSession->listen('\OC\User', 'postLogin', function ($user, $loginName, $password, $isTokenLogin) {
608
+                /** @var \OC\User\User $user */
609
+                \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'loginName' => $loginName, 'password' => $password, 'isTokenLogin' => $isTokenLogin]);
610
+
611
+                /** @var IEventDispatcher $dispatcher */
612
+                $dispatcher = $this->get(IEventDispatcher::class);
613
+                $dispatcher->dispatchTyped(new UserLoggedInEvent($user, $loginName, $password, $isTokenLogin));
614
+            });
615
+            $userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) {
616
+                /** @var IEventDispatcher $dispatcher */
617
+                $dispatcher = $this->get(IEventDispatcher::class);
618
+                $dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid));
619
+            });
620
+            $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
621
+                /** @var \OC\User\User $user */
622
+                \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]);
623
+
624
+                /** @var IEventDispatcher $dispatcher */
625
+                $dispatcher = $this->get(IEventDispatcher::class);
626
+                $dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password));
627
+            });
628
+            $userSession->listen('\OC\User', 'logout', function ($user) {
629
+                \OC_Hook::emit('OC_User', 'logout', []);
630
+
631
+                /** @var IEventDispatcher $dispatcher */
632
+                $dispatcher = $this->get(IEventDispatcher::class);
633
+                $dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user));
634
+            });
635
+            $userSession->listen('\OC\User', 'postLogout', function ($user) {
636
+                /** @var IEventDispatcher $dispatcher */
637
+                $dispatcher = $this->get(IEventDispatcher::class);
638
+                $dispatcher->dispatchTyped(new UserLoggedOutEvent($user));
639
+            });
640
+            $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
641
+                /** @var \OC\User\User $user */
642
+                \OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]);
643
+
644
+                /** @var IEventDispatcher $dispatcher */
645
+                $dispatcher = $this->get(IEventDispatcher::class);
646
+                $dispatcher->dispatchTyped(new UserChangedEvent($user, $feature, $value, $oldValue));
647
+            });
648
+            return $userSession;
649
+        });
650
+        $this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class);
651
+        /** @deprecated 19.0.0 */
652
+        $this->registerDeprecatedAlias('UserSession', \OC\User\Session::class);
653
+
654
+        $this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class);
655
+
656
+        $this->registerAlias(INavigationManager::class, \OC\NavigationManager::class);
657
+        /** @deprecated 19.0.0 */
658
+        $this->registerDeprecatedAlias('NavigationManager', INavigationManager::class);
659
+
660
+        /** @deprecated 19.0.0 */
661
+        $this->registerDeprecatedAlias('AllConfig', \OC\AllConfig::class);
662
+        $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
663
+
664
+        $this->registerService(\OC\SystemConfig::class, function ($c) use ($config) {
665
+            return new \OC\SystemConfig($config);
666
+        });
667
+        /** @deprecated 19.0.0 */
668
+        $this->registerDeprecatedAlias('SystemConfig', \OC\SystemConfig::class);
669
+
670
+        /** @deprecated 19.0.0 */
671
+        $this->registerDeprecatedAlias('AppConfig', \OC\AppConfig::class);
672
+        $this->registerAlias(IAppConfig::class, \OC\AppConfig::class);
673
+
674
+        $this->registerService(IFactory::class, function (Server $c) {
675
+            return new \OC\L10N\Factory(
676
+                $c->get(\OCP\IConfig::class),
677
+                $c->getRequest(),
678
+                $c->get(IUserSession::class),
679
+                \OC::$SERVERROOT
680
+            );
681
+        });
682
+        /** @deprecated 19.0.0 */
683
+        $this->registerDeprecatedAlias('L10NFactory', IFactory::class);
684
+
685
+        $this->registerAlias(IURLGenerator::class, URLGenerator::class);
686
+        /** @deprecated 19.0.0 */
687
+        $this->registerDeprecatedAlias('URLGenerator', IURLGenerator::class);
688
+
689
+        /** @deprecated 19.0.0 */
690
+        $this->registerDeprecatedAlias('AppFetcher', AppFetcher::class);
691
+        /** @deprecated 19.0.0 */
692
+        $this->registerDeprecatedAlias('CategoryFetcher', CategoryFetcher::class);
693
+
694
+        $this->registerService(ICache::class, function ($c) {
695
+            return new Cache\File();
696
+        });
697
+        /** @deprecated 19.0.0 */
698
+        $this->registerDeprecatedAlias('UserCache', ICache::class);
699
+
700
+        $this->registerService(Factory::class, function (Server $c) {
701
+            $profiler = $c->get(IProfiler::class);
702
+            $arrayCacheFactory = new \OC\Memcache\Factory('', $c->get(LoggerInterface::class),
703
+                $profiler,
704
+                ArrayCache::class,
705
+                ArrayCache::class,
706
+                ArrayCache::class
707
+            );
708
+            /** @var \OCP\IConfig $config */
709
+            $config = $c->get(\OCP\IConfig::class);
710
+
711
+            if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
712
+                if (!$config->getSystemValueBool('log_query')) {
713
+                    $v = \OC_App::getAppVersions();
714
+                } else {
715
+                    // If the log_query is enabled, we can not get the app versions
716
+                    // as that does a query, which will be logged and the logging
717
+                    // depends on redis and here we are back again in the same function.
718
+                    $v = [
719
+                        'log_query' => 'enabled',
720
+                    ];
721
+                }
722
+                $v['core'] = implode(',', \OC_Util::getVersion());
723
+                $version = implode(',', $v);
724
+                $instanceId = \OC_Util::getInstanceId();
725
+                $path = \OC::$SERVERROOT;
726
+                $prefix = md5($instanceId . '-' . $version . '-' . $path);
727
+                return new \OC\Memcache\Factory($prefix,
728
+                    $c->get(LoggerInterface::class),
729
+                    $profiler,
730
+                    $config->getSystemValue('memcache.local', null),
731
+                    $config->getSystemValue('memcache.distributed', null),
732
+                    $config->getSystemValue('memcache.locking', null),
733
+                    $config->getSystemValueString('redis_log_file')
734
+                );
735
+            }
736
+            return $arrayCacheFactory;
737
+        });
738
+        /** @deprecated 19.0.0 */
739
+        $this->registerDeprecatedAlias('MemCacheFactory', Factory::class);
740
+        $this->registerAlias(ICacheFactory::class, Factory::class);
741
+
742
+        $this->registerService('RedisFactory', function (Server $c) {
743
+            $systemConfig = $c->get(SystemConfig::class);
744
+            return new RedisFactory($systemConfig, $c->getEventLogger());
745
+        });
746
+
747
+        $this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
748
+            $l10n = $this->get(IFactory::class)->get('lib');
749
+            return new \OC\Activity\Manager(
750
+                $c->getRequest(),
751
+                $c->get(IUserSession::class),
752
+                $c->get(\OCP\IConfig::class),
753
+                $c->get(IValidator::class),
754
+                $l10n
755
+            );
756
+        });
757
+        /** @deprecated 19.0.0 */
758
+        $this->registerDeprecatedAlias('ActivityManager', \OCP\Activity\IManager::class);
759
+
760
+        $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
761
+            return new \OC\Activity\EventMerger(
762
+                $c->getL10N('lib')
763
+            );
764
+        });
765
+        $this->registerAlias(IValidator::class, Validator::class);
766
+
767
+        $this->registerService(AvatarManager::class, function (Server $c) {
768
+            return new AvatarManager(
769
+                $c->get(IUserSession::class),
770
+                $c->get(\OC\User\Manager::class),
771
+                $c->getAppDataDir('avatar'),
772
+                $c->getL10N('lib'),
773
+                $c->get(LoggerInterface::class),
774
+                $c->get(\OCP\IConfig::class),
775
+                $c->get(IAccountManager::class),
776
+                $c->get(KnownUserService::class)
777
+            );
778
+        });
779
+
780
+        $this->registerAlias(IAvatarManager::class, AvatarManager::class);
781
+        /** @deprecated 19.0.0 */
782
+        $this->registerDeprecatedAlias('AvatarManager', AvatarManager::class);
783
+
784
+        $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
785
+        $this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class);
786
+
787
+        $this->registerService(\OC\Log::class, function (Server $c) {
788
+            $logType = $c->get(AllConfig::class)->getSystemValue('log_type', 'file');
789
+            $factory = new LogFactory($c, $this->get(SystemConfig::class));
790
+            $logger = $factory->get($logType);
791
+            $registry = $c->get(\OCP\Support\CrashReport\IRegistry::class);
792
+
793
+            return new Log($logger, $this->get(SystemConfig::class), null, $registry);
794
+        });
795
+        $this->registerAlias(ILogger::class, \OC\Log::class);
796
+        /** @deprecated 19.0.0 */
797
+        $this->registerDeprecatedAlias('Logger', \OC\Log::class);
798
+        // PSR-3 logger
799
+        $this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class);
800
+
801
+        $this->registerService(ILogFactory::class, function (Server $c) {
802
+            return new LogFactory($c, $this->get(SystemConfig::class));
803
+        });
804
+
805
+        $this->registerAlias(IJobList::class, \OC\BackgroundJob\JobList::class);
806
+        /** @deprecated 19.0.0 */
807
+        $this->registerDeprecatedAlias('JobList', IJobList::class);
808
+
809
+        $this->registerService(Router::class, function (Server $c) {
810
+            $cacheFactory = $c->get(ICacheFactory::class);
811
+            $logger = $c->get(LoggerInterface::class);
812
+            if ($cacheFactory->isLocalCacheAvailable()) {
813
+                $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger);
814
+            } else {
815
+                $router = new \OC\Route\Router($logger);
816
+            }
817
+            return $router;
818
+        });
819
+        $this->registerAlias(IRouter::class, Router::class);
820
+        /** @deprecated 19.0.0 */
821
+        $this->registerDeprecatedAlias('Router', IRouter::class);
822
+
823
+        $this->registerAlias(ISearch::class, Search::class);
824
+        /** @deprecated 19.0.0 */
825
+        $this->registerDeprecatedAlias('Search', ISearch::class);
826
+
827
+        $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
828
+            $cacheFactory = $c->get(ICacheFactory::class);
829
+            if ($cacheFactory->isAvailable()) {
830
+                $backend = new \OC\Security\RateLimiting\Backend\MemoryCacheBackend(
831
+                    $this->get(ICacheFactory::class),
832
+                    new \OC\AppFramework\Utility\TimeFactory()
833
+                );
834
+            } else {
835
+                $backend = new \OC\Security\RateLimiting\Backend\DatabaseBackend(
836
+                    $c->get(IDBConnection::class),
837
+                    new \OC\AppFramework\Utility\TimeFactory()
838
+                );
839
+            }
840
+
841
+            return $backend;
842
+        });
843
+
844
+        $this->registerAlias(\OCP\Security\ISecureRandom::class, SecureRandom::class);
845
+        /** @deprecated 19.0.0 */
846
+        $this->registerDeprecatedAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
847
+
848
+        $this->registerAlias(IVerificationToken::class, VerificationToken::class);
849
+
850
+        $this->registerAlias(ICrypto::class, Crypto::class);
851
+        /** @deprecated 19.0.0 */
852
+        $this->registerDeprecatedAlias('Crypto', ICrypto::class);
853
+
854
+        $this->registerAlias(IHasher::class, Hasher::class);
855
+        /** @deprecated 19.0.0 */
856
+        $this->registerDeprecatedAlias('Hasher', IHasher::class);
857
+
858
+        $this->registerAlias(ICredentialsManager::class, CredentialsManager::class);
859
+        /** @deprecated 19.0.0 */
860
+        $this->registerDeprecatedAlias('CredentialsManager', ICredentialsManager::class);
861
+
862
+        $this->registerAlias(IDBConnection::class, ConnectionAdapter::class);
863
+        $this->registerService(Connection::class, function (Server $c) {
864
+            $systemConfig = $c->get(SystemConfig::class);
865
+            $factory = new \OC\DB\ConnectionFactory($systemConfig);
866
+            $type = $systemConfig->getValue('dbtype', 'sqlite');
867
+            if (!$factory->isValidType($type)) {
868
+                throw new \OC\DatabaseException('Invalid database type');
869
+            }
870
+            $connectionParams = $factory->createConnectionParams();
871
+            $connection = $factory->getConnection($type, $connectionParams);
872
+            return $connection;
873
+        });
874
+        /** @deprecated 19.0.0 */
875
+        $this->registerDeprecatedAlias('DatabaseConnection', IDBConnection::class);
876
+
877
+        $this->registerAlias(ICertificateManager::class, CertificateManager::class);
878
+        $this->registerAlias(IClientService::class, ClientService::class);
879
+        $this->registerService(LocalAddressChecker::class, function (ContainerInterface $c) {
880
+            return new LocalAddressChecker(
881
+                $c->get(LoggerInterface::class),
882
+            );
883
+        });
884
+        $this->registerService(NegativeDnsCache::class, function (ContainerInterface $c) {
885
+            return new NegativeDnsCache(
886
+                $c->get(ICacheFactory::class),
887
+            );
888
+        });
889
+        $this->registerService(DnsPinMiddleware::class, function (ContainerInterface $c) {
890
+            return new DnsPinMiddleware(
891
+                $c->get(NegativeDnsCache::class),
892
+                $c->get(LocalAddressChecker::class)
893
+            );
894
+        });
895
+        $this->registerDeprecatedAlias('HttpClientService', IClientService::class);
896
+        $this->registerService(IEventLogger::class, function (ContainerInterface $c) {
897
+            return new EventLogger($c->get(SystemConfig::class), $c->get(LoggerInterface::class), $c->get(Log::class));
898
+        });
899
+        /** @deprecated 19.0.0 */
900
+        $this->registerDeprecatedAlias('EventLogger', IEventLogger::class);
901
+
902
+        $this->registerService(IQueryLogger::class, function (ContainerInterface $c) {
903
+            $queryLogger = new QueryLogger();
904
+            if ($c->get(SystemConfig::class)->getValue('debug', false)) {
905
+                // In debug mode, module is being activated by default
906
+                $queryLogger->activate();
907
+            }
908
+            return $queryLogger;
909
+        });
910
+        /** @deprecated 19.0.0 */
911
+        $this->registerDeprecatedAlias('QueryLogger', IQueryLogger::class);
912
+
913
+        /** @deprecated 19.0.0 */
914
+        $this->registerDeprecatedAlias('TempManager', TempManager::class);
915
+        $this->registerAlias(ITempManager::class, TempManager::class);
916
+
917
+        $this->registerService(AppManager::class, function (ContainerInterface $c) {
918
+            // TODO: use auto-wiring
919
+            return new \OC\App\AppManager(
920
+                $c->get(IUserSession::class),
921
+                $c->get(\OCP\IConfig::class),
922
+                $c->get(\OC\AppConfig::class),
923
+                $c->get(IGroupManager::class),
924
+                $c->get(ICacheFactory::class),
925
+                $c->get(SymfonyAdapter::class),
926
+                $c->get(LoggerInterface::class)
927
+            );
928
+        });
929
+        /** @deprecated 19.0.0 */
930
+        $this->registerDeprecatedAlias('AppManager', AppManager::class);
931
+        $this->registerAlias(IAppManager::class, AppManager::class);
932
+
933
+        $this->registerAlias(IDateTimeZone::class, DateTimeZone::class);
934
+        /** @deprecated 19.0.0 */
935
+        $this->registerDeprecatedAlias('DateTimeZone', IDateTimeZone::class);
936
+
937
+        $this->registerService(IDateTimeFormatter::class, function (Server $c) {
938
+            $language = $c->get(\OCP\IConfig::class)->getUserValue($c->get(ISession::class)->get('user_id'), 'core', 'lang', null);
939
+
940
+            return new DateTimeFormatter(
941
+                $c->get(IDateTimeZone::class)->getTimeZone(),
942
+                $c->getL10N('lib', $language)
943
+            );
944
+        });
945
+        /** @deprecated 19.0.0 */
946
+        $this->registerDeprecatedAlias('DateTimeFormatter', IDateTimeFormatter::class);
947
+
948
+        $this->registerService(IUserMountCache::class, function (ContainerInterface $c) {
949
+            $mountCache = new UserMountCache(
950
+                $c->get(IDBConnection::class),
951
+                $c->get(IUserManager::class),
952
+                $c->get(LoggerInterface::class)
953
+            );
954
+            $listener = new UserMountCacheListener($mountCache);
955
+            $listener->listen($c->get(IUserManager::class));
956
+            return $mountCache;
957
+        });
958
+        /** @deprecated 19.0.0 */
959
+        $this->registerDeprecatedAlias('UserMountCache', IUserMountCache::class);
960
+
961
+        $this->registerService(IMountProviderCollection::class, function (ContainerInterface $c) {
962
+            $loader = \OC\Files\Filesystem::getLoader();
963
+            $mountCache = $c->get(IUserMountCache::class);
964
+            $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
965
+
966
+            // builtin providers
967
+
968
+            $config = $c->get(\OCP\IConfig::class);
969
+            $logger = $c->get(LoggerInterface::class);
970
+            $manager->registerProvider(new CacheMountProvider($config));
971
+            $manager->registerHomeProvider(new LocalHomeMountProvider());
972
+            $manager->registerHomeProvider(new ObjectHomeMountProvider($config));
973
+            $manager->registerRootProvider(new RootMountProvider($config, $c->get(LoggerInterface::class)));
974
+            $manager->registerRootProvider(new ObjectStorePreviewCacheMountProvider($logger, $config));
975
+
976
+            return $manager;
977
+        });
978
+        /** @deprecated 19.0.0 */
979
+        $this->registerDeprecatedAlias('MountConfigManager', IMountProviderCollection::class);
980
+
981
+        /** @deprecated 20.0.0 */
982
+        $this->registerDeprecatedAlias('IniWrapper', IniGetWrapper::class);
983
+        $this->registerService(IBus::class, function (ContainerInterface $c) {
984
+            $busClass = $c->get(\OCP\IConfig::class)->getSystemValue('commandbus');
985
+            if ($busClass) {
986
+                [$app, $class] = explode('::', $busClass, 2);
987
+                if ($c->get(IAppManager::class)->isInstalled($app)) {
988
+                    \OC_App::loadApp($app);
989
+                    return $c->get($class);
990
+                } else {
991
+                    throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
992
+                }
993
+            } else {
994
+                $jobList = $c->get(IJobList::class);
995
+                return new CronBus($jobList);
996
+            }
997
+        });
998
+        $this->registerDeprecatedAlias('AsyncCommandBus', IBus::class);
999
+        /** @deprecated 20.0.0 */
1000
+        $this->registerDeprecatedAlias('TrustedDomainHelper', TrustedDomainHelper::class);
1001
+        $this->registerAlias(ITrustedDomainHelper::class, TrustedDomainHelper::class);
1002
+        /** @deprecated 19.0.0 */
1003
+        $this->registerDeprecatedAlias('Throttler', Throttler::class);
1004
+        $this->registerService('IntegrityCodeChecker', function (ContainerInterface $c) {
1005
+            // IConfig and IAppManager requires a working database. This code
1006
+            // might however be called when ownCloud is not yet setup.
1007
+            if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
1008
+                $config = $c->get(\OCP\IConfig::class);
1009
+                $appManager = $c->get(IAppManager::class);
1010
+            } else {
1011
+                $config = null;
1012
+                $appManager = null;
1013
+            }
1014
+
1015
+            return new Checker(
1016
+                new EnvironmentHelper(),
1017
+                new FileAccessHelper(),
1018
+                new AppLocator(),
1019
+                $config,
1020
+                $c->get(ICacheFactory::class),
1021
+                $appManager,
1022
+                $c->get(IMimeTypeDetector::class)
1023
+            );
1024
+        });
1025
+        $this->registerService(\OCP\IRequest::class, function (ContainerInterface $c) {
1026
+            if (isset($this['urlParams'])) {
1027
+                $urlParams = $this['urlParams'];
1028
+            } else {
1029
+                $urlParams = [];
1030
+            }
1031
+
1032
+            if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
1033
+                && in_array('fakeinput', stream_get_wrappers())
1034
+            ) {
1035
+                $stream = 'fakeinput://data';
1036
+            } else {
1037
+                $stream = 'php://input';
1038
+            }
1039
+
1040
+            return new Request(
1041
+                [
1042
+                    'get' => $_GET,
1043
+                    'post' => $_POST,
1044
+                    'files' => $_FILES,
1045
+                    'server' => $_SERVER,
1046
+                    'env' => $_ENV,
1047
+                    'cookies' => $_COOKIE,
1048
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1049
+                        ? $_SERVER['REQUEST_METHOD']
1050
+                        : '',
1051
+                    'urlParams' => $urlParams,
1052
+                ],
1053
+                $this->get(IRequestId::class),
1054
+                $this->get(\OCP\IConfig::class),
1055
+                $this->get(CsrfTokenManager::class),
1056
+                $stream
1057
+            );
1058
+        });
1059
+        /** @deprecated 19.0.0 */
1060
+        $this->registerDeprecatedAlias('Request', \OCP\IRequest::class);
1061
+
1062
+        $this->registerService(IRequestId::class, function (ContainerInterface $c): IRequestId {
1063
+            return new RequestId(
1064
+                $_SERVER['UNIQUE_ID'] ?? '',
1065
+                $this->get(ISecureRandom::class)
1066
+            );
1067
+        });
1068
+
1069
+        $this->registerService(IMailer::class, function (Server $c) {
1070
+            return new Mailer(
1071
+                $c->get(\OCP\IConfig::class),
1072
+                $c->get(LoggerInterface::class),
1073
+                $c->get(Defaults::class),
1074
+                $c->get(IURLGenerator::class),
1075
+                $c->getL10N('lib'),
1076
+                $c->get(IEventDispatcher::class),
1077
+                $c->get(IFactory::class)
1078
+            );
1079
+        });
1080
+        /** @deprecated 19.0.0 */
1081
+        $this->registerDeprecatedAlias('Mailer', IMailer::class);
1082
+
1083
+        /** @deprecated 21.0.0 */
1084
+        $this->registerDeprecatedAlias('LDAPProvider', ILDAPProvider::class);
1085
+
1086
+        $this->registerService(ILDAPProviderFactory::class, function (ContainerInterface $c) {
1087
+            $config = $c->get(\OCP\IConfig::class);
1088
+            $factoryClass = $config->getSystemValue('ldapProviderFactory', null);
1089
+            if (is_null($factoryClass) || !class_exists($factoryClass)) {
1090
+                return new NullLDAPProviderFactory($this);
1091
+            }
1092
+            /** @var \OCP\LDAP\ILDAPProviderFactory $factory */
1093
+            return new $factoryClass($this);
1094
+        });
1095
+        $this->registerService(ILDAPProvider::class, function (ContainerInterface $c) {
1096
+            $factory = $c->get(ILDAPProviderFactory::class);
1097
+            return $factory->getLDAPProvider();
1098
+        });
1099
+        $this->registerService(ILockingProvider::class, function (ContainerInterface $c) {
1100
+            $ini = $c->get(IniGetWrapper::class);
1101
+            $config = $c->get(\OCP\IConfig::class);
1102
+            $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
1103
+            if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
1104
+                /** @var \OC\Memcache\Factory $memcacheFactory */
1105
+                $memcacheFactory = $c->get(ICacheFactory::class);
1106
+                $memcache = $memcacheFactory->createLocking('lock');
1107
+                if (!($memcache instanceof \OC\Memcache\NullCache)) {
1108
+                    return new MemcacheLockingProvider($memcache, $ttl);
1109
+                }
1110
+                return new DBLockingProvider(
1111
+                    $c->get(IDBConnection::class),
1112
+                    $c->get(LoggerInterface::class),
1113
+                    new TimeFactory(),
1114
+                    $ttl,
1115
+                    !\OC::$CLI
1116
+                );
1117
+            }
1118
+            return new NoopLockingProvider();
1119
+        });
1120
+        /** @deprecated 19.0.0 */
1121
+        $this->registerDeprecatedAlias('LockingProvider', ILockingProvider::class);
1122
+
1123
+        $this->registerService(ILockManager::class, function (Server $c): LockManager {
1124
+            return new LockManager();
1125
+        });
1126
+
1127
+        $this->registerAlias(ILockdownManager::class, 'LockdownManager');
1128
+        $this->registerService(SetupManager::class, function ($c) {
1129
+            // create the setupmanager through the mount manager to resolve the cyclic dependency
1130
+            return $c->get(\OC\Files\Mount\Manager::class)->getSetupManager();
1131
+        });
1132
+        $this->registerAlias(IMountManager::class, \OC\Files\Mount\Manager::class);
1133
+        /** @deprecated 19.0.0 */
1134
+        $this->registerDeprecatedAlias('MountManager', IMountManager::class);
1135
+
1136
+        $this->registerService(IMimeTypeDetector::class, function (ContainerInterface $c) {
1137
+            return new \OC\Files\Type\Detection(
1138
+                $c->get(IURLGenerator::class),
1139
+                $c->get(LoggerInterface::class),
1140
+                \OC::$configDir,
1141
+                \OC::$SERVERROOT . '/resources/config/'
1142
+            );
1143
+        });
1144
+        /** @deprecated 19.0.0 */
1145
+        $this->registerDeprecatedAlias('MimeTypeDetector', IMimeTypeDetector::class);
1146
+
1147
+        $this->registerAlias(IMimeTypeLoader::class, Loader::class);
1148
+        /** @deprecated 19.0.0 */
1149
+        $this->registerDeprecatedAlias('MimeTypeLoader', IMimeTypeLoader::class);
1150
+        $this->registerService(BundleFetcher::class, function () {
1151
+            return new BundleFetcher($this->getL10N('lib'));
1152
+        });
1153
+        $this->registerAlias(\OCP\Notification\IManager::class, Manager::class);
1154
+        /** @deprecated 19.0.0 */
1155
+        $this->registerDeprecatedAlias('NotificationManager', \OCP\Notification\IManager::class);
1156
+
1157
+        $this->registerService(CapabilitiesManager::class, function (ContainerInterface $c) {
1158
+            $manager = new CapabilitiesManager($c->get(LoggerInterface::class));
1159
+            $manager->registerCapability(function () use ($c) {
1160
+                return new \OC\OCS\CoreCapabilities($c->get(\OCP\IConfig::class));
1161
+            });
1162
+            $manager->registerCapability(function () use ($c) {
1163
+                return $c->get(\OC\Security\Bruteforce\Capabilities::class);
1164
+            });
1165
+            $manager->registerCapability(function () use ($c) {
1166
+                return $c->get(MetadataCapabilities::class);
1167
+            });
1168
+            return $manager;
1169
+        });
1170
+        /** @deprecated 19.0.0 */
1171
+        $this->registerDeprecatedAlias('CapabilitiesManager', CapabilitiesManager::class);
1172
+
1173
+        $this->registerService(ICommentsManager::class, function (Server $c) {
1174
+            $config = $c->get(\OCP\IConfig::class);
1175
+            $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class);
1176
+            /** @var \OCP\Comments\ICommentsManagerFactory $factory */
1177
+            $factory = new $factoryClass($this);
1178
+            $manager = $factory->getManager();
1179
+
1180
+            $manager->registerDisplayNameResolver('user', function ($id) use ($c) {
1181
+                $manager = $c->get(IUserManager::class);
1182
+                $user = $manager->get($id);
1183
+                if (is_null($user)) {
1184
+                    $l = $c->getL10N('core');
1185
+                    $displayName = $l->t('Unknown user');
1186
+                } else {
1187
+                    $displayName = $user->getDisplayName();
1188
+                }
1189
+                return $displayName;
1190
+            });
1191
+
1192
+            return $manager;
1193
+        });
1194
+        /** @deprecated 19.0.0 */
1195
+        $this->registerDeprecatedAlias('CommentsManager', ICommentsManager::class);
1196
+
1197
+        $this->registerAlias(\OC_Defaults::class, 'ThemingDefaults');
1198
+        $this->registerService('ThemingDefaults', function (Server $c) {
1199
+            /*
1200 1200
 			 * Dark magic for autoloader.
1201 1201
 			 * If we do a class_exists it will try to load the class which will
1202 1202
 			 * make composer cache the result. Resulting in errors when enabling
1203 1203
 			 * the theming app.
1204 1204
 			 */
1205
-			$prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
1206
-			if (isset($prefixes['OCA\\Theming\\'])) {
1207
-				$classExists = true;
1208
-			} else {
1209
-				$classExists = false;
1210
-			}
1211
-
1212
-			if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValue('installed', false) && $c->get(IAppManager::class)->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
1213
-				return new ThemingDefaults(
1214
-					$c->get(\OCP\IConfig::class),
1215
-					$c->getL10N('theming'),
1216
-					$c->get(IURLGenerator::class),
1217
-					$c->get(ICacheFactory::class),
1218
-					new Util($c->get(\OCP\IConfig::class), $this->get(IAppManager::class), $c->getAppDataDir('theming')),
1219
-					new ImageManager(
1220
-						$c->get(\OCP\IConfig::class),
1221
-						$c->getAppDataDir('theming'),
1222
-						$c->get(IURLGenerator::class),
1223
-						$this->get(ICacheFactory::class),
1224
-						$this->get(ILogger::class),
1225
-						$this->get(ITempManager::class)
1226
-					),
1227
-					$c->get(IAppManager::class),
1228
-					$c->get(INavigationManager::class)
1229
-				);
1230
-			}
1231
-			return new \OC_Defaults();
1232
-		});
1233
-		$this->registerService(JSCombiner::class, function (Server $c) {
1234
-			return new JSCombiner(
1235
-				$c->getAppDataDir('js'),
1236
-				$c->get(IURLGenerator::class),
1237
-				$this->get(ICacheFactory::class),
1238
-				$c->get(SystemConfig::class),
1239
-				$c->get(LoggerInterface::class)
1240
-			);
1241
-		});
1242
-		$this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class);
1243
-		/** @deprecated 19.0.0 */
1244
-		$this->registerDeprecatedAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class);
1245
-		$this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class);
1246
-
1247
-		$this->registerService('CryptoWrapper', function (ContainerInterface $c) {
1248
-			// FIXME: Instantiated here due to cyclic dependency
1249
-			$request = new Request(
1250
-				[
1251
-					'get' => $_GET,
1252
-					'post' => $_POST,
1253
-					'files' => $_FILES,
1254
-					'server' => $_SERVER,
1255
-					'env' => $_ENV,
1256
-					'cookies' => $_COOKIE,
1257
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1258
-						? $_SERVER['REQUEST_METHOD']
1259
-						: null,
1260
-				],
1261
-				$c->get(IRequestId::class),
1262
-				$c->get(\OCP\IConfig::class)
1263
-			);
1264
-
1265
-			return new CryptoWrapper(
1266
-				$c->get(\OCP\IConfig::class),
1267
-				$c->get(ICrypto::class),
1268
-				$c->get(ISecureRandom::class),
1269
-				$request
1270
-			);
1271
-		});
1272
-		/** @deprecated 19.0.0 */
1273
-		$this->registerDeprecatedAlias('CsrfTokenManager', CsrfTokenManager::class);
1274
-		$this->registerService(SessionStorage::class, function (ContainerInterface $c) {
1275
-			return new SessionStorage($c->get(ISession::class));
1276
-		});
1277
-		$this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class);
1278
-		/** @deprecated 19.0.0 */
1279
-		$this->registerDeprecatedAlias('ContentSecurityPolicyManager', ContentSecurityPolicyManager::class);
1280
-
1281
-		$this->registerService(\OCP\Share\IManager::class, function (IServerContainer $c) {
1282
-			$config = $c->get(\OCP\IConfig::class);
1283
-			$factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class);
1284
-			/** @var \OCP\Share\IProviderFactory $factory */
1285
-			$factory = new $factoryClass($this);
1286
-
1287
-			$manager = new \OC\Share20\Manager(
1288
-				$c->get(LoggerInterface::class),
1289
-				$c->get(\OCP\IConfig::class),
1290
-				$c->get(ISecureRandom::class),
1291
-				$c->get(IHasher::class),
1292
-				$c->get(IMountManager::class),
1293
-				$c->get(IGroupManager::class),
1294
-				$c->getL10N('lib'),
1295
-				$c->get(IFactory::class),
1296
-				$factory,
1297
-				$c->get(IUserManager::class),
1298
-				$c->get(IRootFolder::class),
1299
-				$c->get(SymfonyAdapter::class),
1300
-				$c->get(IMailer::class),
1301
-				$c->get(IURLGenerator::class),
1302
-				$c->get('ThemingDefaults'),
1303
-				$c->get(IEventDispatcher::class),
1304
-				$c->get(IUserSession::class),
1305
-				$c->get(KnownUserService::class)
1306
-			);
1307
-
1308
-			return $manager;
1309
-		});
1310
-		/** @deprecated 19.0.0 */
1311
-		$this->registerDeprecatedAlias('ShareManager', \OCP\Share\IManager::class);
1312
-
1313
-		$this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) {
1314
-			$instance = new Collaboration\Collaborators\Search($c);
1315
-
1316
-			// register default plugins
1317
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]);
1318
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
1319
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
1320
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
1321
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]);
1322
-
1323
-			return $instance;
1324
-		});
1325
-		/** @deprecated 19.0.0 */
1326
-		$this->registerDeprecatedAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class);
1327
-		$this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class);
1328
-
1329
-		$this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
1330
-
1331
-		$this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class);
1332
-		$this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class);
1333
-
1334
-		$this->registerDeprecatedAlias('SettingsManager', \OC\Settings\Manager::class);
1335
-		$this->registerAlias(\OCP\Settings\IManager::class, \OC\Settings\Manager::class);
1336
-		$this->registerService(\OC\Files\AppData\Factory::class, function (ContainerInterface $c) {
1337
-			return new \OC\Files\AppData\Factory(
1338
-				$c->get(IRootFolder::class),
1339
-				$c->get(SystemConfig::class)
1340
-			);
1341
-		});
1342
-
1343
-		$this->registerService('LockdownManager', function (ContainerInterface $c) {
1344
-			return new LockdownManager(function () use ($c) {
1345
-				return $c->get(ISession::class);
1346
-			});
1347
-		});
1348
-
1349
-		$this->registerService(\OCP\OCS\IDiscoveryService::class, function (ContainerInterface $c) {
1350
-			return new DiscoveryService(
1351
-				$c->get(ICacheFactory::class),
1352
-				$c->get(IClientService::class)
1353
-			);
1354
-		});
1355
-
1356
-		$this->registerService(ICloudIdManager::class, function (ContainerInterface $c) {
1357
-			return new CloudIdManager($c->get(\OCP\Contacts\IManager::class), $c->get(IURLGenerator::class), $c->get(IUserManager::class));
1358
-		});
1359
-
1360
-		$this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class);
1361
-
1362
-		$this->registerService(ICloudFederationProviderManager::class, function (ContainerInterface $c) {
1363
-			return new CloudFederationProviderManager(
1364
-				$c->get(IAppManager::class),
1365
-				$c->get(IClientService::class),
1366
-				$c->get(ICloudIdManager::class),
1367
-				$c->get(LoggerInterface::class)
1368
-			);
1369
-		});
1370
-
1371
-		$this->registerService(ICloudFederationFactory::class, function (Server $c) {
1372
-			return new CloudFederationFactory();
1373
-		});
1374
-
1375
-		$this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1376
-		/** @deprecated 19.0.0 */
1377
-		$this->registerDeprecatedAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
1378
-
1379
-		$this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1380
-		/** @deprecated 19.0.0 */
1381
-		$this->registerDeprecatedAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1382
-
1383
-		$this->registerService(Defaults::class, function (Server $c) {
1384
-			return new Defaults(
1385
-				$c->getThemingDefaults()
1386
-			);
1387
-		});
1388
-		/** @deprecated 19.0.0 */
1389
-		$this->registerDeprecatedAlias('Defaults', \OCP\Defaults::class);
1390
-
1391
-		$this->registerService(\OCP\ISession::class, function (ContainerInterface $c) {
1392
-			return $c->get(\OCP\IUserSession::class)->getSession();
1393
-		}, false);
1394
-
1395
-		$this->registerService(IShareHelper::class, function (ContainerInterface $c) {
1396
-			return new ShareHelper(
1397
-				$c->get(\OCP\Share\IManager::class)
1398
-			);
1399
-		});
1400
-
1401
-		$this->registerService(Installer::class, function (ContainerInterface $c) {
1402
-			return new Installer(
1403
-				$c->get(AppFetcher::class),
1404
-				$c->get(IClientService::class),
1405
-				$c->get(ITempManager::class),
1406
-				$c->get(LoggerInterface::class),
1407
-				$c->get(\OCP\IConfig::class),
1408
-				\OC::$CLI
1409
-			);
1410
-		});
1411
-
1412
-		$this->registerService(IApiFactory::class, function (ContainerInterface $c) {
1413
-			return new ApiFactory($c->get(IClientService::class));
1414
-		});
1415
-
1416
-		$this->registerService(IInstanceFactory::class, function (ContainerInterface $c) {
1417
-			$memcacheFactory = $c->get(ICacheFactory::class);
1418
-			return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->get(IClientService::class));
1419
-		});
1420
-
1421
-		$this->registerAlias(IContactsStore::class, ContactsStore::class);
1422
-		$this->registerAlias(IAccountManager::class, AccountManager::class);
1423
-
1424
-		$this->registerAlias(IStorageFactory::class, StorageFactory::class);
1425
-
1426
-		$this->registerAlias(IDashboardManager::class, DashboardManager::class);
1427
-		$this->registerAlias(\OCP\Dashboard\IManager::class, \OC\Dashboard\Manager::class);
1428
-		$this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class);
1429
-
1430
-		$this->registerAlias(ISubAdmin::class, SubAdmin::class);
1431
-
1432
-		$this->registerAlias(IInitialStateService::class, InitialStateService::class);
1433
-
1434
-		$this->registerAlias(\OCP\IEmojiHelper::class, \OC\EmojiHelper::class);
1435
-
1436
-		$this->registerAlias(\OCP\UserStatus\IManager::class, \OC\UserStatus\Manager::class);
1437
-
1438
-		$this->registerAlias(IBroker::class, Broker::class);
1439
-
1440
-		$this->registerAlias(IMetadataManager::class, MetadataManager::class);
1441
-
1442
-		$this->connectDispatcher();
1443
-	}
1444
-
1445
-	public function boot() {
1446
-		/** @var HookConnector $hookConnector */
1447
-		$hookConnector = $this->get(HookConnector::class);
1448
-		$hookConnector->viewToNode();
1449
-	}
1450
-
1451
-	/**
1452
-	 * @return \OCP\Calendar\IManager
1453
-	 * @deprecated 20.0.0
1454
-	 */
1455
-	public function getCalendarManager() {
1456
-		return $this->get(\OC\Calendar\Manager::class);
1457
-	}
1458
-
1459
-	/**
1460
-	 * @return \OCP\Calendar\Resource\IManager
1461
-	 * @deprecated 20.0.0
1462
-	 */
1463
-	public function getCalendarResourceBackendManager() {
1464
-		return $this->get(\OC\Calendar\Resource\Manager::class);
1465
-	}
1466
-
1467
-	/**
1468
-	 * @return \OCP\Calendar\Room\IManager
1469
-	 * @deprecated 20.0.0
1470
-	 */
1471
-	public function getCalendarRoomBackendManager() {
1472
-		return $this->get(\OC\Calendar\Room\Manager::class);
1473
-	}
1474
-
1475
-	private function connectDispatcher() {
1476
-		$dispatcher = $this->get(SymfonyAdapter::class);
1477
-
1478
-		// Delete avatar on user deletion
1479
-		$dispatcher->addListener('OCP\IUser::preDelete', function (GenericEvent $e) {
1480
-			$logger = $this->get(LoggerInterface::class);
1481
-			$manager = $this->getAvatarManager();
1482
-			/** @var IUser $user */
1483
-			$user = $e->getSubject();
1484
-
1485
-			try {
1486
-				$avatar = $manager->getAvatar($user->getUID());
1487
-				$avatar->remove();
1488
-			} catch (NotFoundException $e) {
1489
-				// no avatar to remove
1490
-			} catch (\Exception $e) {
1491
-				// Ignore exceptions
1492
-				$logger->info('Could not cleanup avatar of ' . $user->getUID());
1493
-			}
1494
-		});
1495
-
1496
-		$dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) {
1497
-			$manager = $this->getAvatarManager();
1498
-			/** @var IUser $user */
1499
-			$user = $e->getSubject();
1500
-			$feature = $e->getArgument('feature');
1501
-			$oldValue = $e->getArgument('oldValue');
1502
-			$value = $e->getArgument('value');
1503
-
1504
-			// We only change the avatar on display name changes
1505
-			if ($feature !== 'displayName') {
1506
-				return;
1507
-			}
1508
-
1509
-			try {
1510
-				$avatar = $manager->getAvatar($user->getUID());
1511
-				$avatar->userChanged($feature, $oldValue, $value);
1512
-			} catch (NotFoundException $e) {
1513
-				// no avatar to remove
1514
-			}
1515
-		});
1516
-
1517
-		/** @var IEventDispatcher $eventDispatched */
1518
-		$eventDispatched = $this->get(IEventDispatcher::class);
1519
-		$eventDispatched->addServiceListener(LoginFailed::class, LoginFailedListener::class);
1520
-		$eventDispatched->addServiceListener(PostLoginEvent::class, UserLoggedInListener::class);
1521
-	}
1522
-
1523
-	/**
1524
-	 * @return \OCP\Contacts\IManager
1525
-	 * @deprecated 20.0.0
1526
-	 */
1527
-	public function getContactsManager() {
1528
-		return $this->get(\OCP\Contacts\IManager::class);
1529
-	}
1530
-
1531
-	/**
1532
-	 * @return \OC\Encryption\Manager
1533
-	 * @deprecated 20.0.0
1534
-	 */
1535
-	public function getEncryptionManager() {
1536
-		return $this->get(\OCP\Encryption\IManager::class);
1537
-	}
1538
-
1539
-	/**
1540
-	 * @return \OC\Encryption\File
1541
-	 * @deprecated 20.0.0
1542
-	 */
1543
-	public function getEncryptionFilesHelper() {
1544
-		return $this->get(IFile::class);
1545
-	}
1546
-
1547
-	/**
1548
-	 * @return \OCP\Encryption\Keys\IStorage
1549
-	 * @deprecated 20.0.0
1550
-	 */
1551
-	public function getEncryptionKeyStorage() {
1552
-		return $this->get(IStorage::class);
1553
-	}
1554
-
1555
-	/**
1556
-	 * The current request object holding all information about the request
1557
-	 * currently being processed is returned from this method.
1558
-	 * In case the current execution was not initiated by a web request null is returned
1559
-	 *
1560
-	 * @return \OCP\IRequest
1561
-	 * @deprecated 20.0.0
1562
-	 */
1563
-	public function getRequest() {
1564
-		return $this->get(IRequest::class);
1565
-	}
1566
-
1567
-	/**
1568
-	 * Returns the preview manager which can create preview images for a given file
1569
-	 *
1570
-	 * @return IPreview
1571
-	 * @deprecated 20.0.0
1572
-	 */
1573
-	public function getPreviewManager() {
1574
-		return $this->get(IPreview::class);
1575
-	}
1576
-
1577
-	/**
1578
-	 * Returns the tag manager which can get and set tags for different object types
1579
-	 *
1580
-	 * @see \OCP\ITagManager::load()
1581
-	 * @return ITagManager
1582
-	 * @deprecated 20.0.0
1583
-	 */
1584
-	public function getTagManager() {
1585
-		return $this->get(ITagManager::class);
1586
-	}
1587
-
1588
-	/**
1589
-	 * Returns the system-tag manager
1590
-	 *
1591
-	 * @return ISystemTagManager
1592
-	 *
1593
-	 * @since 9.0.0
1594
-	 * @deprecated 20.0.0
1595
-	 */
1596
-	public function getSystemTagManager() {
1597
-		return $this->get(ISystemTagManager::class);
1598
-	}
1599
-
1600
-	/**
1601
-	 * Returns the system-tag object mapper
1602
-	 *
1603
-	 * @return ISystemTagObjectMapper
1604
-	 *
1605
-	 * @since 9.0.0
1606
-	 * @deprecated 20.0.0
1607
-	 */
1608
-	public function getSystemTagObjectMapper() {
1609
-		return $this->get(ISystemTagObjectMapper::class);
1610
-	}
1611
-
1612
-	/**
1613
-	 * Returns the avatar manager, used for avatar functionality
1614
-	 *
1615
-	 * @return IAvatarManager
1616
-	 * @deprecated 20.0.0
1617
-	 */
1618
-	public function getAvatarManager() {
1619
-		return $this->get(IAvatarManager::class);
1620
-	}
1621
-
1622
-	/**
1623
-	 * Returns the root folder of ownCloud's data directory
1624
-	 *
1625
-	 * @return IRootFolder
1626
-	 * @deprecated 20.0.0
1627
-	 */
1628
-	public function getRootFolder() {
1629
-		return $this->get(IRootFolder::class);
1630
-	}
1631
-
1632
-	/**
1633
-	 * Returns the root folder of ownCloud's data directory
1634
-	 * This is the lazy variant so this gets only initialized once it
1635
-	 * is actually used.
1636
-	 *
1637
-	 * @return IRootFolder
1638
-	 * @deprecated 20.0.0
1639
-	 */
1640
-	public function getLazyRootFolder() {
1641
-		return $this->get(IRootFolder::class);
1642
-	}
1643
-
1644
-	/**
1645
-	 * Returns a view to ownCloud's files folder
1646
-	 *
1647
-	 * @param string $userId user ID
1648
-	 * @return \OCP\Files\Folder|null
1649
-	 * @deprecated 20.0.0
1650
-	 */
1651
-	public function getUserFolder($userId = null) {
1652
-		if ($userId === null) {
1653
-			$user = $this->get(IUserSession::class)->getUser();
1654
-			if (!$user) {
1655
-				return null;
1656
-			}
1657
-			$userId = $user->getUID();
1658
-		}
1659
-		$root = $this->get(IRootFolder::class);
1660
-		return $root->getUserFolder($userId);
1661
-	}
1662
-
1663
-	/**
1664
-	 * @return \OC\User\Manager
1665
-	 * @deprecated 20.0.0
1666
-	 */
1667
-	public function getUserManager() {
1668
-		return $this->get(IUserManager::class);
1669
-	}
1670
-
1671
-	/**
1672
-	 * @return \OC\Group\Manager
1673
-	 * @deprecated 20.0.0
1674
-	 */
1675
-	public function getGroupManager() {
1676
-		return $this->get(IGroupManager::class);
1677
-	}
1678
-
1679
-	/**
1680
-	 * @return \OC\User\Session
1681
-	 * @deprecated 20.0.0
1682
-	 */
1683
-	public function getUserSession() {
1684
-		return $this->get(IUserSession::class);
1685
-	}
1686
-
1687
-	/**
1688
-	 * @return \OCP\ISession
1689
-	 * @deprecated 20.0.0
1690
-	 */
1691
-	public function getSession() {
1692
-		return $this->get(IUserSession::class)->getSession();
1693
-	}
1694
-
1695
-	/**
1696
-	 * @param \OCP\ISession $session
1697
-	 */
1698
-	public function setSession(\OCP\ISession $session) {
1699
-		$this->get(SessionStorage::class)->setSession($session);
1700
-		$this->get(IUserSession::class)->setSession($session);
1701
-		$this->get(Store::class)->setSession($session);
1702
-	}
1703
-
1704
-	/**
1705
-	 * @return \OC\Authentication\TwoFactorAuth\Manager
1706
-	 * @deprecated 20.0.0
1707
-	 */
1708
-	public function getTwoFactorAuthManager() {
1709
-		return $this->get(\OC\Authentication\TwoFactorAuth\Manager::class);
1710
-	}
1711
-
1712
-	/**
1713
-	 * @return \OC\NavigationManager
1714
-	 * @deprecated 20.0.0
1715
-	 */
1716
-	public function getNavigationManager() {
1717
-		return $this->get(INavigationManager::class);
1718
-	}
1719
-
1720
-	/**
1721
-	 * @return \OCP\IConfig
1722
-	 * @deprecated 20.0.0
1723
-	 */
1724
-	public function getConfig() {
1725
-		return $this->get(AllConfig::class);
1726
-	}
1727
-
1728
-	/**
1729
-	 * @return \OC\SystemConfig
1730
-	 * @deprecated 20.0.0
1731
-	 */
1732
-	public function getSystemConfig() {
1733
-		return $this->get(SystemConfig::class);
1734
-	}
1735
-
1736
-	/**
1737
-	 * Returns the app config manager
1738
-	 *
1739
-	 * @return IAppConfig
1740
-	 * @deprecated 20.0.0
1741
-	 */
1742
-	public function getAppConfig() {
1743
-		return $this->get(IAppConfig::class);
1744
-	}
1745
-
1746
-	/**
1747
-	 * @return IFactory
1748
-	 * @deprecated 20.0.0
1749
-	 */
1750
-	public function getL10NFactory() {
1751
-		return $this->get(IFactory::class);
1752
-	}
1753
-
1754
-	/**
1755
-	 * get an L10N instance
1756
-	 *
1757
-	 * @param string $app appid
1758
-	 * @param string $lang
1759
-	 * @return IL10N
1760
-	 * @deprecated 20.0.0
1761
-	 */
1762
-	public function getL10N($app, $lang = null) {
1763
-		return $this->get(IFactory::class)->get($app, $lang);
1764
-	}
1765
-
1766
-	/**
1767
-	 * @return IURLGenerator
1768
-	 * @deprecated 20.0.0
1769
-	 */
1770
-	public function getURLGenerator() {
1771
-		return $this->get(IURLGenerator::class);
1772
-	}
1773
-
1774
-	/**
1775
-	 * @return AppFetcher
1776
-	 * @deprecated 20.0.0
1777
-	 */
1778
-	public function getAppFetcher() {
1779
-		return $this->get(AppFetcher::class);
1780
-	}
1781
-
1782
-	/**
1783
-	 * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1784
-	 * getMemCacheFactory() instead.
1785
-	 *
1786
-	 * @return ICache
1787
-	 * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1788
-	 */
1789
-	public function getCache() {
1790
-		return $this->get(ICache::class);
1791
-	}
1792
-
1793
-	/**
1794
-	 * Returns an \OCP\CacheFactory instance
1795
-	 *
1796
-	 * @return \OCP\ICacheFactory
1797
-	 * @deprecated 20.0.0
1798
-	 */
1799
-	public function getMemCacheFactory() {
1800
-		return $this->get(ICacheFactory::class);
1801
-	}
1802
-
1803
-	/**
1804
-	 * Returns an \OC\RedisFactory instance
1805
-	 *
1806
-	 * @return \OC\RedisFactory
1807
-	 * @deprecated 20.0.0
1808
-	 */
1809
-	public function getGetRedisFactory() {
1810
-		return $this->get('RedisFactory');
1811
-	}
1812
-
1813
-
1814
-	/**
1815
-	 * Returns the current session
1816
-	 *
1817
-	 * @return \OCP\IDBConnection
1818
-	 * @deprecated 20.0.0
1819
-	 */
1820
-	public function getDatabaseConnection() {
1821
-		return $this->get(IDBConnection::class);
1822
-	}
1823
-
1824
-	/**
1825
-	 * Returns the activity manager
1826
-	 *
1827
-	 * @return \OCP\Activity\IManager
1828
-	 * @deprecated 20.0.0
1829
-	 */
1830
-	public function getActivityManager() {
1831
-		return $this->get(\OCP\Activity\IManager::class);
1832
-	}
1833
-
1834
-	/**
1835
-	 * Returns an job list for controlling background jobs
1836
-	 *
1837
-	 * @return IJobList
1838
-	 * @deprecated 20.0.0
1839
-	 */
1840
-	public function getJobList() {
1841
-		return $this->get(IJobList::class);
1842
-	}
1843
-
1844
-	/**
1845
-	 * Returns a logger instance
1846
-	 *
1847
-	 * @return ILogger
1848
-	 * @deprecated 20.0.0
1849
-	 */
1850
-	public function getLogger() {
1851
-		return $this->get(ILogger::class);
1852
-	}
1853
-
1854
-	/**
1855
-	 * @return ILogFactory
1856
-	 * @throws \OCP\AppFramework\QueryException
1857
-	 * @deprecated 20.0.0
1858
-	 */
1859
-	public function getLogFactory() {
1860
-		return $this->get(ILogFactory::class);
1861
-	}
1862
-
1863
-	/**
1864
-	 * Returns a router for generating and matching urls
1865
-	 *
1866
-	 * @return IRouter
1867
-	 * @deprecated 20.0.0
1868
-	 */
1869
-	public function getRouter() {
1870
-		return $this->get(IRouter::class);
1871
-	}
1872
-
1873
-	/**
1874
-	 * Returns a search instance
1875
-	 *
1876
-	 * @return ISearch
1877
-	 * @deprecated 20.0.0
1878
-	 */
1879
-	public function getSearch() {
1880
-		return $this->get(ISearch::class);
1881
-	}
1882
-
1883
-	/**
1884
-	 * Returns a SecureRandom instance
1885
-	 *
1886
-	 * @return \OCP\Security\ISecureRandom
1887
-	 * @deprecated 20.0.0
1888
-	 */
1889
-	public function getSecureRandom() {
1890
-		return $this->get(ISecureRandom::class);
1891
-	}
1892
-
1893
-	/**
1894
-	 * Returns a Crypto instance
1895
-	 *
1896
-	 * @return ICrypto
1897
-	 * @deprecated 20.0.0
1898
-	 */
1899
-	public function getCrypto() {
1900
-		return $this->get(ICrypto::class);
1901
-	}
1902
-
1903
-	/**
1904
-	 * Returns a Hasher instance
1905
-	 *
1906
-	 * @return IHasher
1907
-	 * @deprecated 20.0.0
1908
-	 */
1909
-	public function getHasher() {
1910
-		return $this->get(IHasher::class);
1911
-	}
1912
-
1913
-	/**
1914
-	 * Returns a CredentialsManager instance
1915
-	 *
1916
-	 * @return ICredentialsManager
1917
-	 * @deprecated 20.0.0
1918
-	 */
1919
-	public function getCredentialsManager() {
1920
-		return $this->get(ICredentialsManager::class);
1921
-	}
1922
-
1923
-	/**
1924
-	 * Get the certificate manager
1925
-	 *
1926
-	 * @return \OCP\ICertificateManager
1927
-	 */
1928
-	public function getCertificateManager() {
1929
-		return $this->get(ICertificateManager::class);
1930
-	}
1931
-
1932
-	/**
1933
-	 * Returns an instance of the HTTP client service
1934
-	 *
1935
-	 * @return IClientService
1936
-	 * @deprecated 20.0.0
1937
-	 */
1938
-	public function getHTTPClientService() {
1939
-		return $this->get(IClientService::class);
1940
-	}
1941
-
1942
-	/**
1943
-	 * Create a new event source
1944
-	 *
1945
-	 * @return \OCP\IEventSource
1946
-	 * @deprecated 20.0.0
1947
-	 */
1948
-	public function createEventSource() {
1949
-		return new \OC_EventSource();
1950
-	}
1951
-
1952
-	/**
1953
-	 * Get the active event logger
1954
-	 *
1955
-	 * The returned logger only logs data when debug mode is enabled
1956
-	 *
1957
-	 * @return IEventLogger
1958
-	 * @deprecated 20.0.0
1959
-	 */
1960
-	public function getEventLogger() {
1961
-		return $this->get(IEventLogger::class);
1962
-	}
1963
-
1964
-	/**
1965
-	 * Get the active query logger
1966
-	 *
1967
-	 * The returned logger only logs data when debug mode is enabled
1968
-	 *
1969
-	 * @return IQueryLogger
1970
-	 * @deprecated 20.0.0
1971
-	 */
1972
-	public function getQueryLogger() {
1973
-		return $this->get(IQueryLogger::class);
1974
-	}
1975
-
1976
-	/**
1977
-	 * Get the manager for temporary files and folders
1978
-	 *
1979
-	 * @return \OCP\ITempManager
1980
-	 * @deprecated 20.0.0
1981
-	 */
1982
-	public function getTempManager() {
1983
-		return $this->get(ITempManager::class);
1984
-	}
1985
-
1986
-	/**
1987
-	 * Get the app manager
1988
-	 *
1989
-	 * @return \OCP\App\IAppManager
1990
-	 * @deprecated 20.0.0
1991
-	 */
1992
-	public function getAppManager() {
1993
-		return $this->get(IAppManager::class);
1994
-	}
1995
-
1996
-	/**
1997
-	 * Creates a new mailer
1998
-	 *
1999
-	 * @return IMailer
2000
-	 * @deprecated 20.0.0
2001
-	 */
2002
-	public function getMailer() {
2003
-		return $this->get(IMailer::class);
2004
-	}
2005
-
2006
-	/**
2007
-	 * Get the webroot
2008
-	 *
2009
-	 * @return string
2010
-	 * @deprecated 20.0.0
2011
-	 */
2012
-	public function getWebRoot() {
2013
-		return $this->webRoot;
2014
-	}
2015
-
2016
-	/**
2017
-	 * @return \OC\OCSClient
2018
-	 * @deprecated 20.0.0
2019
-	 */
2020
-	public function getOcsClient() {
2021
-		return $this->get('OcsClient');
2022
-	}
2023
-
2024
-	/**
2025
-	 * @return IDateTimeZone
2026
-	 * @deprecated 20.0.0
2027
-	 */
2028
-	public function getDateTimeZone() {
2029
-		return $this->get(IDateTimeZone::class);
2030
-	}
2031
-
2032
-	/**
2033
-	 * @return IDateTimeFormatter
2034
-	 * @deprecated 20.0.0
2035
-	 */
2036
-	public function getDateTimeFormatter() {
2037
-		return $this->get(IDateTimeFormatter::class);
2038
-	}
2039
-
2040
-	/**
2041
-	 * @return IMountProviderCollection
2042
-	 * @deprecated 20.0.0
2043
-	 */
2044
-	public function getMountProviderCollection() {
2045
-		return $this->get(IMountProviderCollection::class);
2046
-	}
2047
-
2048
-	/**
2049
-	 * Get the IniWrapper
2050
-	 *
2051
-	 * @return IniGetWrapper
2052
-	 * @deprecated 20.0.0
2053
-	 */
2054
-	public function getIniWrapper() {
2055
-		return $this->get(IniGetWrapper::class);
2056
-	}
2057
-
2058
-	/**
2059
-	 * @return \OCP\Command\IBus
2060
-	 * @deprecated 20.0.0
2061
-	 */
2062
-	public function getCommandBus() {
2063
-		return $this->get(IBus::class);
2064
-	}
2065
-
2066
-	/**
2067
-	 * Get the trusted domain helper
2068
-	 *
2069
-	 * @return TrustedDomainHelper
2070
-	 * @deprecated 20.0.0
2071
-	 */
2072
-	public function getTrustedDomainHelper() {
2073
-		return $this->get(TrustedDomainHelper::class);
2074
-	}
2075
-
2076
-	/**
2077
-	 * Get the locking provider
2078
-	 *
2079
-	 * @return ILockingProvider
2080
-	 * @since 8.1.0
2081
-	 * @deprecated 20.0.0
2082
-	 */
2083
-	public function getLockingProvider() {
2084
-		return $this->get(ILockingProvider::class);
2085
-	}
2086
-
2087
-	/**
2088
-	 * @return IMountManager
2089
-	 * @deprecated 20.0.0
2090
-	 **/
2091
-	public function getMountManager() {
2092
-		return $this->get(IMountManager::class);
2093
-	}
2094
-
2095
-	/**
2096
-	 * @return IUserMountCache
2097
-	 * @deprecated 20.0.0
2098
-	 */
2099
-	public function getUserMountCache() {
2100
-		return $this->get(IUserMountCache::class);
2101
-	}
2102
-
2103
-	/**
2104
-	 * Get the MimeTypeDetector
2105
-	 *
2106
-	 * @return IMimeTypeDetector
2107
-	 * @deprecated 20.0.0
2108
-	 */
2109
-	public function getMimeTypeDetector() {
2110
-		return $this->get(IMimeTypeDetector::class);
2111
-	}
2112
-
2113
-	/**
2114
-	 * Get the MimeTypeLoader
2115
-	 *
2116
-	 * @return IMimeTypeLoader
2117
-	 * @deprecated 20.0.0
2118
-	 */
2119
-	public function getMimeTypeLoader() {
2120
-		return $this->get(IMimeTypeLoader::class);
2121
-	}
2122
-
2123
-	/**
2124
-	 * Get the manager of all the capabilities
2125
-	 *
2126
-	 * @return CapabilitiesManager
2127
-	 * @deprecated 20.0.0
2128
-	 */
2129
-	public function getCapabilitiesManager() {
2130
-		return $this->get(CapabilitiesManager::class);
2131
-	}
2132
-
2133
-	/**
2134
-	 * Get the EventDispatcher
2135
-	 *
2136
-	 * @return EventDispatcherInterface
2137
-	 * @since 8.2.0
2138
-	 * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher
2139
-	 */
2140
-	public function getEventDispatcher() {
2141
-		return $this->get(\OC\EventDispatcher\SymfonyAdapter::class);
2142
-	}
2143
-
2144
-	/**
2145
-	 * Get the Notification Manager
2146
-	 *
2147
-	 * @return \OCP\Notification\IManager
2148
-	 * @since 8.2.0
2149
-	 * @deprecated 20.0.0
2150
-	 */
2151
-	public function getNotificationManager() {
2152
-		return $this->get(\OCP\Notification\IManager::class);
2153
-	}
2154
-
2155
-	/**
2156
-	 * @return ICommentsManager
2157
-	 * @deprecated 20.0.0
2158
-	 */
2159
-	public function getCommentsManager() {
2160
-		return $this->get(ICommentsManager::class);
2161
-	}
2162
-
2163
-	/**
2164
-	 * @return \OCA\Theming\ThemingDefaults
2165
-	 * @deprecated 20.0.0
2166
-	 */
2167
-	public function getThemingDefaults() {
2168
-		return $this->get('ThemingDefaults');
2169
-	}
2170
-
2171
-	/**
2172
-	 * @return \OC\IntegrityCheck\Checker
2173
-	 * @deprecated 20.0.0
2174
-	 */
2175
-	public function getIntegrityCodeChecker() {
2176
-		return $this->get('IntegrityCodeChecker');
2177
-	}
2178
-
2179
-	/**
2180
-	 * @return \OC\Session\CryptoWrapper
2181
-	 * @deprecated 20.0.0
2182
-	 */
2183
-	public function getSessionCryptoWrapper() {
2184
-		return $this->get('CryptoWrapper');
2185
-	}
2186
-
2187
-	/**
2188
-	 * @return CsrfTokenManager
2189
-	 * @deprecated 20.0.0
2190
-	 */
2191
-	public function getCsrfTokenManager() {
2192
-		return $this->get(CsrfTokenManager::class);
2193
-	}
2194
-
2195
-	/**
2196
-	 * @return Throttler
2197
-	 * @deprecated 20.0.0
2198
-	 */
2199
-	public function getBruteForceThrottler() {
2200
-		return $this->get(Throttler::class);
2201
-	}
2202
-
2203
-	/**
2204
-	 * @return IContentSecurityPolicyManager
2205
-	 * @deprecated 20.0.0
2206
-	 */
2207
-	public function getContentSecurityPolicyManager() {
2208
-		return $this->get(ContentSecurityPolicyManager::class);
2209
-	}
2210
-
2211
-	/**
2212
-	 * @return ContentSecurityPolicyNonceManager
2213
-	 * @deprecated 20.0.0
2214
-	 */
2215
-	public function getContentSecurityPolicyNonceManager() {
2216
-		return $this->get(ContentSecurityPolicyNonceManager::class);
2217
-	}
2218
-
2219
-	/**
2220
-	 * Not a public API as of 8.2, wait for 9.0
2221
-	 *
2222
-	 * @return \OCA\Files_External\Service\BackendService
2223
-	 * @deprecated 20.0.0
2224
-	 */
2225
-	public function getStoragesBackendService() {
2226
-		return $this->get(BackendService::class);
2227
-	}
2228
-
2229
-	/**
2230
-	 * Not a public API as of 8.2, wait for 9.0
2231
-	 *
2232
-	 * @return \OCA\Files_External\Service\GlobalStoragesService
2233
-	 * @deprecated 20.0.0
2234
-	 */
2235
-	public function getGlobalStoragesService() {
2236
-		return $this->get(GlobalStoragesService::class);
2237
-	}
2238
-
2239
-	/**
2240
-	 * Not a public API as of 8.2, wait for 9.0
2241
-	 *
2242
-	 * @return \OCA\Files_External\Service\UserGlobalStoragesService
2243
-	 * @deprecated 20.0.0
2244
-	 */
2245
-	public function getUserGlobalStoragesService() {
2246
-		return $this->get(UserGlobalStoragesService::class);
2247
-	}
2248
-
2249
-	/**
2250
-	 * Not a public API as of 8.2, wait for 9.0
2251
-	 *
2252
-	 * @return \OCA\Files_External\Service\UserStoragesService
2253
-	 * @deprecated 20.0.0
2254
-	 */
2255
-	public function getUserStoragesService() {
2256
-		return $this->get(UserStoragesService::class);
2257
-	}
2258
-
2259
-	/**
2260
-	 * @return \OCP\Share\IManager
2261
-	 * @deprecated 20.0.0
2262
-	 */
2263
-	public function getShareManager() {
2264
-		return $this->get(\OCP\Share\IManager::class);
2265
-	}
2266
-
2267
-	/**
2268
-	 * @return \OCP\Collaboration\Collaborators\ISearch
2269
-	 * @deprecated 20.0.0
2270
-	 */
2271
-	public function getCollaboratorSearch() {
2272
-		return $this->get(\OCP\Collaboration\Collaborators\ISearch::class);
2273
-	}
2274
-
2275
-	/**
2276
-	 * @return \OCP\Collaboration\AutoComplete\IManager
2277
-	 * @deprecated 20.0.0
2278
-	 */
2279
-	public function getAutoCompleteManager() {
2280
-		return $this->get(IManager::class);
2281
-	}
2282
-
2283
-	/**
2284
-	 * Returns the LDAP Provider
2285
-	 *
2286
-	 * @return \OCP\LDAP\ILDAPProvider
2287
-	 * @deprecated 20.0.0
2288
-	 */
2289
-	public function getLDAPProvider() {
2290
-		return $this->get('LDAPProvider');
2291
-	}
2292
-
2293
-	/**
2294
-	 * @return \OCP\Settings\IManager
2295
-	 * @deprecated 20.0.0
2296
-	 */
2297
-	public function getSettingsManager() {
2298
-		return $this->get(\OC\Settings\Manager::class);
2299
-	}
2300
-
2301
-	/**
2302
-	 * @return \OCP\Files\IAppData
2303
-	 * @deprecated 20.0.0
2304
-	 */
2305
-	public function getAppDataDir($app) {
2306
-		/** @var \OC\Files\AppData\Factory $factory */
2307
-		$factory = $this->get(\OC\Files\AppData\Factory::class);
2308
-		return $factory->get($app);
2309
-	}
2310
-
2311
-	/**
2312
-	 * @return \OCP\Lockdown\ILockdownManager
2313
-	 * @deprecated 20.0.0
2314
-	 */
2315
-	public function getLockdownManager() {
2316
-		return $this->get('LockdownManager');
2317
-	}
2318
-
2319
-	/**
2320
-	 * @return \OCP\Federation\ICloudIdManager
2321
-	 * @deprecated 20.0.0
2322
-	 */
2323
-	public function getCloudIdManager() {
2324
-		return $this->get(ICloudIdManager::class);
2325
-	}
2326
-
2327
-	/**
2328
-	 * @return \OCP\GlobalScale\IConfig
2329
-	 * @deprecated 20.0.0
2330
-	 */
2331
-	public function getGlobalScaleConfig() {
2332
-		return $this->get(IConfig::class);
2333
-	}
2334
-
2335
-	/**
2336
-	 * @return \OCP\Federation\ICloudFederationProviderManager
2337
-	 * @deprecated 20.0.0
2338
-	 */
2339
-	public function getCloudFederationProviderManager() {
2340
-		return $this->get(ICloudFederationProviderManager::class);
2341
-	}
2342
-
2343
-	/**
2344
-	 * @return \OCP\Remote\Api\IApiFactory
2345
-	 * @deprecated 20.0.0
2346
-	 */
2347
-	public function getRemoteApiFactory() {
2348
-		return $this->get(IApiFactory::class);
2349
-	}
2350
-
2351
-	/**
2352
-	 * @return \OCP\Federation\ICloudFederationFactory
2353
-	 * @deprecated 20.0.0
2354
-	 */
2355
-	public function getCloudFederationFactory() {
2356
-		return $this->get(ICloudFederationFactory::class);
2357
-	}
2358
-
2359
-	/**
2360
-	 * @return \OCP\Remote\IInstanceFactory
2361
-	 * @deprecated 20.0.0
2362
-	 */
2363
-	public function getRemoteInstanceFactory() {
2364
-		return $this->get(IInstanceFactory::class);
2365
-	}
2366
-
2367
-	/**
2368
-	 * @return IStorageFactory
2369
-	 * @deprecated 20.0.0
2370
-	 */
2371
-	public function getStorageFactory() {
2372
-		return $this->get(IStorageFactory::class);
2373
-	}
2374
-
2375
-	/**
2376
-	 * Get the Preview GeneratorHelper
2377
-	 *
2378
-	 * @return GeneratorHelper
2379
-	 * @since 17.0.0
2380
-	 * @deprecated 20.0.0
2381
-	 */
2382
-	public function getGeneratorHelper() {
2383
-		return $this->get(\OC\Preview\GeneratorHelper::class);
2384
-	}
2385
-
2386
-	private function registerDeprecatedAlias(string $alias, string $target) {
2387
-		$this->registerService($alias, function (ContainerInterface $container) use ($target, $alias) {
2388
-			try {
2389
-				/** @var LoggerInterface $logger */
2390
-				$logger = $container->get(LoggerInterface::class);
2391
-				$logger->debug('The requested alias "' . $alias . '" is deprecated. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']);
2392
-			} catch (ContainerExceptionInterface $e) {
2393
-				// Could not get logger. Continue
2394
-			}
2395
-
2396
-			return $container->get($target);
2397
-		}, false);
2398
-	}
1205
+            $prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
1206
+            if (isset($prefixes['OCA\\Theming\\'])) {
1207
+                $classExists = true;
1208
+            } else {
1209
+                $classExists = false;
1210
+            }
1211
+
1212
+            if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValue('installed', false) && $c->get(IAppManager::class)->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
1213
+                return new ThemingDefaults(
1214
+                    $c->get(\OCP\IConfig::class),
1215
+                    $c->getL10N('theming'),
1216
+                    $c->get(IURLGenerator::class),
1217
+                    $c->get(ICacheFactory::class),
1218
+                    new Util($c->get(\OCP\IConfig::class), $this->get(IAppManager::class), $c->getAppDataDir('theming')),
1219
+                    new ImageManager(
1220
+                        $c->get(\OCP\IConfig::class),
1221
+                        $c->getAppDataDir('theming'),
1222
+                        $c->get(IURLGenerator::class),
1223
+                        $this->get(ICacheFactory::class),
1224
+                        $this->get(ILogger::class),
1225
+                        $this->get(ITempManager::class)
1226
+                    ),
1227
+                    $c->get(IAppManager::class),
1228
+                    $c->get(INavigationManager::class)
1229
+                );
1230
+            }
1231
+            return new \OC_Defaults();
1232
+        });
1233
+        $this->registerService(JSCombiner::class, function (Server $c) {
1234
+            return new JSCombiner(
1235
+                $c->getAppDataDir('js'),
1236
+                $c->get(IURLGenerator::class),
1237
+                $this->get(ICacheFactory::class),
1238
+                $c->get(SystemConfig::class),
1239
+                $c->get(LoggerInterface::class)
1240
+            );
1241
+        });
1242
+        $this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class);
1243
+        /** @deprecated 19.0.0 */
1244
+        $this->registerDeprecatedAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class);
1245
+        $this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class);
1246
+
1247
+        $this->registerService('CryptoWrapper', function (ContainerInterface $c) {
1248
+            // FIXME: Instantiated here due to cyclic dependency
1249
+            $request = new Request(
1250
+                [
1251
+                    'get' => $_GET,
1252
+                    'post' => $_POST,
1253
+                    'files' => $_FILES,
1254
+                    'server' => $_SERVER,
1255
+                    'env' => $_ENV,
1256
+                    'cookies' => $_COOKIE,
1257
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1258
+                        ? $_SERVER['REQUEST_METHOD']
1259
+                        : null,
1260
+                ],
1261
+                $c->get(IRequestId::class),
1262
+                $c->get(\OCP\IConfig::class)
1263
+            );
1264
+
1265
+            return new CryptoWrapper(
1266
+                $c->get(\OCP\IConfig::class),
1267
+                $c->get(ICrypto::class),
1268
+                $c->get(ISecureRandom::class),
1269
+                $request
1270
+            );
1271
+        });
1272
+        /** @deprecated 19.0.0 */
1273
+        $this->registerDeprecatedAlias('CsrfTokenManager', CsrfTokenManager::class);
1274
+        $this->registerService(SessionStorage::class, function (ContainerInterface $c) {
1275
+            return new SessionStorage($c->get(ISession::class));
1276
+        });
1277
+        $this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class);
1278
+        /** @deprecated 19.0.0 */
1279
+        $this->registerDeprecatedAlias('ContentSecurityPolicyManager', ContentSecurityPolicyManager::class);
1280
+
1281
+        $this->registerService(\OCP\Share\IManager::class, function (IServerContainer $c) {
1282
+            $config = $c->get(\OCP\IConfig::class);
1283
+            $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class);
1284
+            /** @var \OCP\Share\IProviderFactory $factory */
1285
+            $factory = new $factoryClass($this);
1286
+
1287
+            $manager = new \OC\Share20\Manager(
1288
+                $c->get(LoggerInterface::class),
1289
+                $c->get(\OCP\IConfig::class),
1290
+                $c->get(ISecureRandom::class),
1291
+                $c->get(IHasher::class),
1292
+                $c->get(IMountManager::class),
1293
+                $c->get(IGroupManager::class),
1294
+                $c->getL10N('lib'),
1295
+                $c->get(IFactory::class),
1296
+                $factory,
1297
+                $c->get(IUserManager::class),
1298
+                $c->get(IRootFolder::class),
1299
+                $c->get(SymfonyAdapter::class),
1300
+                $c->get(IMailer::class),
1301
+                $c->get(IURLGenerator::class),
1302
+                $c->get('ThemingDefaults'),
1303
+                $c->get(IEventDispatcher::class),
1304
+                $c->get(IUserSession::class),
1305
+                $c->get(KnownUserService::class)
1306
+            );
1307
+
1308
+            return $manager;
1309
+        });
1310
+        /** @deprecated 19.0.0 */
1311
+        $this->registerDeprecatedAlias('ShareManager', \OCP\Share\IManager::class);
1312
+
1313
+        $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) {
1314
+            $instance = new Collaboration\Collaborators\Search($c);
1315
+
1316
+            // register default plugins
1317
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]);
1318
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
1319
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
1320
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
1321
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]);
1322
+
1323
+            return $instance;
1324
+        });
1325
+        /** @deprecated 19.0.0 */
1326
+        $this->registerDeprecatedAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class);
1327
+        $this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class);
1328
+
1329
+        $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
1330
+
1331
+        $this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class);
1332
+        $this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class);
1333
+
1334
+        $this->registerDeprecatedAlias('SettingsManager', \OC\Settings\Manager::class);
1335
+        $this->registerAlias(\OCP\Settings\IManager::class, \OC\Settings\Manager::class);
1336
+        $this->registerService(\OC\Files\AppData\Factory::class, function (ContainerInterface $c) {
1337
+            return new \OC\Files\AppData\Factory(
1338
+                $c->get(IRootFolder::class),
1339
+                $c->get(SystemConfig::class)
1340
+            );
1341
+        });
1342
+
1343
+        $this->registerService('LockdownManager', function (ContainerInterface $c) {
1344
+            return new LockdownManager(function () use ($c) {
1345
+                return $c->get(ISession::class);
1346
+            });
1347
+        });
1348
+
1349
+        $this->registerService(\OCP\OCS\IDiscoveryService::class, function (ContainerInterface $c) {
1350
+            return new DiscoveryService(
1351
+                $c->get(ICacheFactory::class),
1352
+                $c->get(IClientService::class)
1353
+            );
1354
+        });
1355
+
1356
+        $this->registerService(ICloudIdManager::class, function (ContainerInterface $c) {
1357
+            return new CloudIdManager($c->get(\OCP\Contacts\IManager::class), $c->get(IURLGenerator::class), $c->get(IUserManager::class));
1358
+        });
1359
+
1360
+        $this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class);
1361
+
1362
+        $this->registerService(ICloudFederationProviderManager::class, function (ContainerInterface $c) {
1363
+            return new CloudFederationProviderManager(
1364
+                $c->get(IAppManager::class),
1365
+                $c->get(IClientService::class),
1366
+                $c->get(ICloudIdManager::class),
1367
+                $c->get(LoggerInterface::class)
1368
+            );
1369
+        });
1370
+
1371
+        $this->registerService(ICloudFederationFactory::class, function (Server $c) {
1372
+            return new CloudFederationFactory();
1373
+        });
1374
+
1375
+        $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1376
+        /** @deprecated 19.0.0 */
1377
+        $this->registerDeprecatedAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
1378
+
1379
+        $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1380
+        /** @deprecated 19.0.0 */
1381
+        $this->registerDeprecatedAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1382
+
1383
+        $this->registerService(Defaults::class, function (Server $c) {
1384
+            return new Defaults(
1385
+                $c->getThemingDefaults()
1386
+            );
1387
+        });
1388
+        /** @deprecated 19.0.0 */
1389
+        $this->registerDeprecatedAlias('Defaults', \OCP\Defaults::class);
1390
+
1391
+        $this->registerService(\OCP\ISession::class, function (ContainerInterface $c) {
1392
+            return $c->get(\OCP\IUserSession::class)->getSession();
1393
+        }, false);
1394
+
1395
+        $this->registerService(IShareHelper::class, function (ContainerInterface $c) {
1396
+            return new ShareHelper(
1397
+                $c->get(\OCP\Share\IManager::class)
1398
+            );
1399
+        });
1400
+
1401
+        $this->registerService(Installer::class, function (ContainerInterface $c) {
1402
+            return new Installer(
1403
+                $c->get(AppFetcher::class),
1404
+                $c->get(IClientService::class),
1405
+                $c->get(ITempManager::class),
1406
+                $c->get(LoggerInterface::class),
1407
+                $c->get(\OCP\IConfig::class),
1408
+                \OC::$CLI
1409
+            );
1410
+        });
1411
+
1412
+        $this->registerService(IApiFactory::class, function (ContainerInterface $c) {
1413
+            return new ApiFactory($c->get(IClientService::class));
1414
+        });
1415
+
1416
+        $this->registerService(IInstanceFactory::class, function (ContainerInterface $c) {
1417
+            $memcacheFactory = $c->get(ICacheFactory::class);
1418
+            return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->get(IClientService::class));
1419
+        });
1420
+
1421
+        $this->registerAlias(IContactsStore::class, ContactsStore::class);
1422
+        $this->registerAlias(IAccountManager::class, AccountManager::class);
1423
+
1424
+        $this->registerAlias(IStorageFactory::class, StorageFactory::class);
1425
+
1426
+        $this->registerAlias(IDashboardManager::class, DashboardManager::class);
1427
+        $this->registerAlias(\OCP\Dashboard\IManager::class, \OC\Dashboard\Manager::class);
1428
+        $this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class);
1429
+
1430
+        $this->registerAlias(ISubAdmin::class, SubAdmin::class);
1431
+
1432
+        $this->registerAlias(IInitialStateService::class, InitialStateService::class);
1433
+
1434
+        $this->registerAlias(\OCP\IEmojiHelper::class, \OC\EmojiHelper::class);
1435
+
1436
+        $this->registerAlias(\OCP\UserStatus\IManager::class, \OC\UserStatus\Manager::class);
1437
+
1438
+        $this->registerAlias(IBroker::class, Broker::class);
1439
+
1440
+        $this->registerAlias(IMetadataManager::class, MetadataManager::class);
1441
+
1442
+        $this->connectDispatcher();
1443
+    }
1444
+
1445
+    public function boot() {
1446
+        /** @var HookConnector $hookConnector */
1447
+        $hookConnector = $this->get(HookConnector::class);
1448
+        $hookConnector->viewToNode();
1449
+    }
1450
+
1451
+    /**
1452
+     * @return \OCP\Calendar\IManager
1453
+     * @deprecated 20.0.0
1454
+     */
1455
+    public function getCalendarManager() {
1456
+        return $this->get(\OC\Calendar\Manager::class);
1457
+    }
1458
+
1459
+    /**
1460
+     * @return \OCP\Calendar\Resource\IManager
1461
+     * @deprecated 20.0.0
1462
+     */
1463
+    public function getCalendarResourceBackendManager() {
1464
+        return $this->get(\OC\Calendar\Resource\Manager::class);
1465
+    }
1466
+
1467
+    /**
1468
+     * @return \OCP\Calendar\Room\IManager
1469
+     * @deprecated 20.0.0
1470
+     */
1471
+    public function getCalendarRoomBackendManager() {
1472
+        return $this->get(\OC\Calendar\Room\Manager::class);
1473
+    }
1474
+
1475
+    private function connectDispatcher() {
1476
+        $dispatcher = $this->get(SymfonyAdapter::class);
1477
+
1478
+        // Delete avatar on user deletion
1479
+        $dispatcher->addListener('OCP\IUser::preDelete', function (GenericEvent $e) {
1480
+            $logger = $this->get(LoggerInterface::class);
1481
+            $manager = $this->getAvatarManager();
1482
+            /** @var IUser $user */
1483
+            $user = $e->getSubject();
1484
+
1485
+            try {
1486
+                $avatar = $manager->getAvatar($user->getUID());
1487
+                $avatar->remove();
1488
+            } catch (NotFoundException $e) {
1489
+                // no avatar to remove
1490
+            } catch (\Exception $e) {
1491
+                // Ignore exceptions
1492
+                $logger->info('Could not cleanup avatar of ' . $user->getUID());
1493
+            }
1494
+        });
1495
+
1496
+        $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) {
1497
+            $manager = $this->getAvatarManager();
1498
+            /** @var IUser $user */
1499
+            $user = $e->getSubject();
1500
+            $feature = $e->getArgument('feature');
1501
+            $oldValue = $e->getArgument('oldValue');
1502
+            $value = $e->getArgument('value');
1503
+
1504
+            // We only change the avatar on display name changes
1505
+            if ($feature !== 'displayName') {
1506
+                return;
1507
+            }
1508
+
1509
+            try {
1510
+                $avatar = $manager->getAvatar($user->getUID());
1511
+                $avatar->userChanged($feature, $oldValue, $value);
1512
+            } catch (NotFoundException $e) {
1513
+                // no avatar to remove
1514
+            }
1515
+        });
1516
+
1517
+        /** @var IEventDispatcher $eventDispatched */
1518
+        $eventDispatched = $this->get(IEventDispatcher::class);
1519
+        $eventDispatched->addServiceListener(LoginFailed::class, LoginFailedListener::class);
1520
+        $eventDispatched->addServiceListener(PostLoginEvent::class, UserLoggedInListener::class);
1521
+    }
1522
+
1523
+    /**
1524
+     * @return \OCP\Contacts\IManager
1525
+     * @deprecated 20.0.0
1526
+     */
1527
+    public function getContactsManager() {
1528
+        return $this->get(\OCP\Contacts\IManager::class);
1529
+    }
1530
+
1531
+    /**
1532
+     * @return \OC\Encryption\Manager
1533
+     * @deprecated 20.0.0
1534
+     */
1535
+    public function getEncryptionManager() {
1536
+        return $this->get(\OCP\Encryption\IManager::class);
1537
+    }
1538
+
1539
+    /**
1540
+     * @return \OC\Encryption\File
1541
+     * @deprecated 20.0.0
1542
+     */
1543
+    public function getEncryptionFilesHelper() {
1544
+        return $this->get(IFile::class);
1545
+    }
1546
+
1547
+    /**
1548
+     * @return \OCP\Encryption\Keys\IStorage
1549
+     * @deprecated 20.0.0
1550
+     */
1551
+    public function getEncryptionKeyStorage() {
1552
+        return $this->get(IStorage::class);
1553
+    }
1554
+
1555
+    /**
1556
+     * The current request object holding all information about the request
1557
+     * currently being processed is returned from this method.
1558
+     * In case the current execution was not initiated by a web request null is returned
1559
+     *
1560
+     * @return \OCP\IRequest
1561
+     * @deprecated 20.0.0
1562
+     */
1563
+    public function getRequest() {
1564
+        return $this->get(IRequest::class);
1565
+    }
1566
+
1567
+    /**
1568
+     * Returns the preview manager which can create preview images for a given file
1569
+     *
1570
+     * @return IPreview
1571
+     * @deprecated 20.0.0
1572
+     */
1573
+    public function getPreviewManager() {
1574
+        return $this->get(IPreview::class);
1575
+    }
1576
+
1577
+    /**
1578
+     * Returns the tag manager which can get and set tags for different object types
1579
+     *
1580
+     * @see \OCP\ITagManager::load()
1581
+     * @return ITagManager
1582
+     * @deprecated 20.0.0
1583
+     */
1584
+    public function getTagManager() {
1585
+        return $this->get(ITagManager::class);
1586
+    }
1587
+
1588
+    /**
1589
+     * Returns the system-tag manager
1590
+     *
1591
+     * @return ISystemTagManager
1592
+     *
1593
+     * @since 9.0.0
1594
+     * @deprecated 20.0.0
1595
+     */
1596
+    public function getSystemTagManager() {
1597
+        return $this->get(ISystemTagManager::class);
1598
+    }
1599
+
1600
+    /**
1601
+     * Returns the system-tag object mapper
1602
+     *
1603
+     * @return ISystemTagObjectMapper
1604
+     *
1605
+     * @since 9.0.0
1606
+     * @deprecated 20.0.0
1607
+     */
1608
+    public function getSystemTagObjectMapper() {
1609
+        return $this->get(ISystemTagObjectMapper::class);
1610
+    }
1611
+
1612
+    /**
1613
+     * Returns the avatar manager, used for avatar functionality
1614
+     *
1615
+     * @return IAvatarManager
1616
+     * @deprecated 20.0.0
1617
+     */
1618
+    public function getAvatarManager() {
1619
+        return $this->get(IAvatarManager::class);
1620
+    }
1621
+
1622
+    /**
1623
+     * Returns the root folder of ownCloud's data directory
1624
+     *
1625
+     * @return IRootFolder
1626
+     * @deprecated 20.0.0
1627
+     */
1628
+    public function getRootFolder() {
1629
+        return $this->get(IRootFolder::class);
1630
+    }
1631
+
1632
+    /**
1633
+     * Returns the root folder of ownCloud's data directory
1634
+     * This is the lazy variant so this gets only initialized once it
1635
+     * is actually used.
1636
+     *
1637
+     * @return IRootFolder
1638
+     * @deprecated 20.0.0
1639
+     */
1640
+    public function getLazyRootFolder() {
1641
+        return $this->get(IRootFolder::class);
1642
+    }
1643
+
1644
+    /**
1645
+     * Returns a view to ownCloud's files folder
1646
+     *
1647
+     * @param string $userId user ID
1648
+     * @return \OCP\Files\Folder|null
1649
+     * @deprecated 20.0.0
1650
+     */
1651
+    public function getUserFolder($userId = null) {
1652
+        if ($userId === null) {
1653
+            $user = $this->get(IUserSession::class)->getUser();
1654
+            if (!$user) {
1655
+                return null;
1656
+            }
1657
+            $userId = $user->getUID();
1658
+        }
1659
+        $root = $this->get(IRootFolder::class);
1660
+        return $root->getUserFolder($userId);
1661
+    }
1662
+
1663
+    /**
1664
+     * @return \OC\User\Manager
1665
+     * @deprecated 20.0.0
1666
+     */
1667
+    public function getUserManager() {
1668
+        return $this->get(IUserManager::class);
1669
+    }
1670
+
1671
+    /**
1672
+     * @return \OC\Group\Manager
1673
+     * @deprecated 20.0.0
1674
+     */
1675
+    public function getGroupManager() {
1676
+        return $this->get(IGroupManager::class);
1677
+    }
1678
+
1679
+    /**
1680
+     * @return \OC\User\Session
1681
+     * @deprecated 20.0.0
1682
+     */
1683
+    public function getUserSession() {
1684
+        return $this->get(IUserSession::class);
1685
+    }
1686
+
1687
+    /**
1688
+     * @return \OCP\ISession
1689
+     * @deprecated 20.0.0
1690
+     */
1691
+    public function getSession() {
1692
+        return $this->get(IUserSession::class)->getSession();
1693
+    }
1694
+
1695
+    /**
1696
+     * @param \OCP\ISession $session
1697
+     */
1698
+    public function setSession(\OCP\ISession $session) {
1699
+        $this->get(SessionStorage::class)->setSession($session);
1700
+        $this->get(IUserSession::class)->setSession($session);
1701
+        $this->get(Store::class)->setSession($session);
1702
+    }
1703
+
1704
+    /**
1705
+     * @return \OC\Authentication\TwoFactorAuth\Manager
1706
+     * @deprecated 20.0.0
1707
+     */
1708
+    public function getTwoFactorAuthManager() {
1709
+        return $this->get(\OC\Authentication\TwoFactorAuth\Manager::class);
1710
+    }
1711
+
1712
+    /**
1713
+     * @return \OC\NavigationManager
1714
+     * @deprecated 20.0.0
1715
+     */
1716
+    public function getNavigationManager() {
1717
+        return $this->get(INavigationManager::class);
1718
+    }
1719
+
1720
+    /**
1721
+     * @return \OCP\IConfig
1722
+     * @deprecated 20.0.0
1723
+     */
1724
+    public function getConfig() {
1725
+        return $this->get(AllConfig::class);
1726
+    }
1727
+
1728
+    /**
1729
+     * @return \OC\SystemConfig
1730
+     * @deprecated 20.0.0
1731
+     */
1732
+    public function getSystemConfig() {
1733
+        return $this->get(SystemConfig::class);
1734
+    }
1735
+
1736
+    /**
1737
+     * Returns the app config manager
1738
+     *
1739
+     * @return IAppConfig
1740
+     * @deprecated 20.0.0
1741
+     */
1742
+    public function getAppConfig() {
1743
+        return $this->get(IAppConfig::class);
1744
+    }
1745
+
1746
+    /**
1747
+     * @return IFactory
1748
+     * @deprecated 20.0.0
1749
+     */
1750
+    public function getL10NFactory() {
1751
+        return $this->get(IFactory::class);
1752
+    }
1753
+
1754
+    /**
1755
+     * get an L10N instance
1756
+     *
1757
+     * @param string $app appid
1758
+     * @param string $lang
1759
+     * @return IL10N
1760
+     * @deprecated 20.0.0
1761
+     */
1762
+    public function getL10N($app, $lang = null) {
1763
+        return $this->get(IFactory::class)->get($app, $lang);
1764
+    }
1765
+
1766
+    /**
1767
+     * @return IURLGenerator
1768
+     * @deprecated 20.0.0
1769
+     */
1770
+    public function getURLGenerator() {
1771
+        return $this->get(IURLGenerator::class);
1772
+    }
1773
+
1774
+    /**
1775
+     * @return AppFetcher
1776
+     * @deprecated 20.0.0
1777
+     */
1778
+    public function getAppFetcher() {
1779
+        return $this->get(AppFetcher::class);
1780
+    }
1781
+
1782
+    /**
1783
+     * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1784
+     * getMemCacheFactory() instead.
1785
+     *
1786
+     * @return ICache
1787
+     * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1788
+     */
1789
+    public function getCache() {
1790
+        return $this->get(ICache::class);
1791
+    }
1792
+
1793
+    /**
1794
+     * Returns an \OCP\CacheFactory instance
1795
+     *
1796
+     * @return \OCP\ICacheFactory
1797
+     * @deprecated 20.0.0
1798
+     */
1799
+    public function getMemCacheFactory() {
1800
+        return $this->get(ICacheFactory::class);
1801
+    }
1802
+
1803
+    /**
1804
+     * Returns an \OC\RedisFactory instance
1805
+     *
1806
+     * @return \OC\RedisFactory
1807
+     * @deprecated 20.0.0
1808
+     */
1809
+    public function getGetRedisFactory() {
1810
+        return $this->get('RedisFactory');
1811
+    }
1812
+
1813
+
1814
+    /**
1815
+     * Returns the current session
1816
+     *
1817
+     * @return \OCP\IDBConnection
1818
+     * @deprecated 20.0.0
1819
+     */
1820
+    public function getDatabaseConnection() {
1821
+        return $this->get(IDBConnection::class);
1822
+    }
1823
+
1824
+    /**
1825
+     * Returns the activity manager
1826
+     *
1827
+     * @return \OCP\Activity\IManager
1828
+     * @deprecated 20.0.0
1829
+     */
1830
+    public function getActivityManager() {
1831
+        return $this->get(\OCP\Activity\IManager::class);
1832
+    }
1833
+
1834
+    /**
1835
+     * Returns an job list for controlling background jobs
1836
+     *
1837
+     * @return IJobList
1838
+     * @deprecated 20.0.0
1839
+     */
1840
+    public function getJobList() {
1841
+        return $this->get(IJobList::class);
1842
+    }
1843
+
1844
+    /**
1845
+     * Returns a logger instance
1846
+     *
1847
+     * @return ILogger
1848
+     * @deprecated 20.0.0
1849
+     */
1850
+    public function getLogger() {
1851
+        return $this->get(ILogger::class);
1852
+    }
1853
+
1854
+    /**
1855
+     * @return ILogFactory
1856
+     * @throws \OCP\AppFramework\QueryException
1857
+     * @deprecated 20.0.0
1858
+     */
1859
+    public function getLogFactory() {
1860
+        return $this->get(ILogFactory::class);
1861
+    }
1862
+
1863
+    /**
1864
+     * Returns a router for generating and matching urls
1865
+     *
1866
+     * @return IRouter
1867
+     * @deprecated 20.0.0
1868
+     */
1869
+    public function getRouter() {
1870
+        return $this->get(IRouter::class);
1871
+    }
1872
+
1873
+    /**
1874
+     * Returns a search instance
1875
+     *
1876
+     * @return ISearch
1877
+     * @deprecated 20.0.0
1878
+     */
1879
+    public function getSearch() {
1880
+        return $this->get(ISearch::class);
1881
+    }
1882
+
1883
+    /**
1884
+     * Returns a SecureRandom instance
1885
+     *
1886
+     * @return \OCP\Security\ISecureRandom
1887
+     * @deprecated 20.0.0
1888
+     */
1889
+    public function getSecureRandom() {
1890
+        return $this->get(ISecureRandom::class);
1891
+    }
1892
+
1893
+    /**
1894
+     * Returns a Crypto instance
1895
+     *
1896
+     * @return ICrypto
1897
+     * @deprecated 20.0.0
1898
+     */
1899
+    public function getCrypto() {
1900
+        return $this->get(ICrypto::class);
1901
+    }
1902
+
1903
+    /**
1904
+     * Returns a Hasher instance
1905
+     *
1906
+     * @return IHasher
1907
+     * @deprecated 20.0.0
1908
+     */
1909
+    public function getHasher() {
1910
+        return $this->get(IHasher::class);
1911
+    }
1912
+
1913
+    /**
1914
+     * Returns a CredentialsManager instance
1915
+     *
1916
+     * @return ICredentialsManager
1917
+     * @deprecated 20.0.0
1918
+     */
1919
+    public function getCredentialsManager() {
1920
+        return $this->get(ICredentialsManager::class);
1921
+    }
1922
+
1923
+    /**
1924
+     * Get the certificate manager
1925
+     *
1926
+     * @return \OCP\ICertificateManager
1927
+     */
1928
+    public function getCertificateManager() {
1929
+        return $this->get(ICertificateManager::class);
1930
+    }
1931
+
1932
+    /**
1933
+     * Returns an instance of the HTTP client service
1934
+     *
1935
+     * @return IClientService
1936
+     * @deprecated 20.0.0
1937
+     */
1938
+    public function getHTTPClientService() {
1939
+        return $this->get(IClientService::class);
1940
+    }
1941
+
1942
+    /**
1943
+     * Create a new event source
1944
+     *
1945
+     * @return \OCP\IEventSource
1946
+     * @deprecated 20.0.0
1947
+     */
1948
+    public function createEventSource() {
1949
+        return new \OC_EventSource();
1950
+    }
1951
+
1952
+    /**
1953
+     * Get the active event logger
1954
+     *
1955
+     * The returned logger only logs data when debug mode is enabled
1956
+     *
1957
+     * @return IEventLogger
1958
+     * @deprecated 20.0.0
1959
+     */
1960
+    public function getEventLogger() {
1961
+        return $this->get(IEventLogger::class);
1962
+    }
1963
+
1964
+    /**
1965
+     * Get the active query logger
1966
+     *
1967
+     * The returned logger only logs data when debug mode is enabled
1968
+     *
1969
+     * @return IQueryLogger
1970
+     * @deprecated 20.0.0
1971
+     */
1972
+    public function getQueryLogger() {
1973
+        return $this->get(IQueryLogger::class);
1974
+    }
1975
+
1976
+    /**
1977
+     * Get the manager for temporary files and folders
1978
+     *
1979
+     * @return \OCP\ITempManager
1980
+     * @deprecated 20.0.0
1981
+     */
1982
+    public function getTempManager() {
1983
+        return $this->get(ITempManager::class);
1984
+    }
1985
+
1986
+    /**
1987
+     * Get the app manager
1988
+     *
1989
+     * @return \OCP\App\IAppManager
1990
+     * @deprecated 20.0.0
1991
+     */
1992
+    public function getAppManager() {
1993
+        return $this->get(IAppManager::class);
1994
+    }
1995
+
1996
+    /**
1997
+     * Creates a new mailer
1998
+     *
1999
+     * @return IMailer
2000
+     * @deprecated 20.0.0
2001
+     */
2002
+    public function getMailer() {
2003
+        return $this->get(IMailer::class);
2004
+    }
2005
+
2006
+    /**
2007
+     * Get the webroot
2008
+     *
2009
+     * @return string
2010
+     * @deprecated 20.0.0
2011
+     */
2012
+    public function getWebRoot() {
2013
+        return $this->webRoot;
2014
+    }
2015
+
2016
+    /**
2017
+     * @return \OC\OCSClient
2018
+     * @deprecated 20.0.0
2019
+     */
2020
+    public function getOcsClient() {
2021
+        return $this->get('OcsClient');
2022
+    }
2023
+
2024
+    /**
2025
+     * @return IDateTimeZone
2026
+     * @deprecated 20.0.0
2027
+     */
2028
+    public function getDateTimeZone() {
2029
+        return $this->get(IDateTimeZone::class);
2030
+    }
2031
+
2032
+    /**
2033
+     * @return IDateTimeFormatter
2034
+     * @deprecated 20.0.0
2035
+     */
2036
+    public function getDateTimeFormatter() {
2037
+        return $this->get(IDateTimeFormatter::class);
2038
+    }
2039
+
2040
+    /**
2041
+     * @return IMountProviderCollection
2042
+     * @deprecated 20.0.0
2043
+     */
2044
+    public function getMountProviderCollection() {
2045
+        return $this->get(IMountProviderCollection::class);
2046
+    }
2047
+
2048
+    /**
2049
+     * Get the IniWrapper
2050
+     *
2051
+     * @return IniGetWrapper
2052
+     * @deprecated 20.0.0
2053
+     */
2054
+    public function getIniWrapper() {
2055
+        return $this->get(IniGetWrapper::class);
2056
+    }
2057
+
2058
+    /**
2059
+     * @return \OCP\Command\IBus
2060
+     * @deprecated 20.0.0
2061
+     */
2062
+    public function getCommandBus() {
2063
+        return $this->get(IBus::class);
2064
+    }
2065
+
2066
+    /**
2067
+     * Get the trusted domain helper
2068
+     *
2069
+     * @return TrustedDomainHelper
2070
+     * @deprecated 20.0.0
2071
+     */
2072
+    public function getTrustedDomainHelper() {
2073
+        return $this->get(TrustedDomainHelper::class);
2074
+    }
2075
+
2076
+    /**
2077
+     * Get the locking provider
2078
+     *
2079
+     * @return ILockingProvider
2080
+     * @since 8.1.0
2081
+     * @deprecated 20.0.0
2082
+     */
2083
+    public function getLockingProvider() {
2084
+        return $this->get(ILockingProvider::class);
2085
+    }
2086
+
2087
+    /**
2088
+     * @return IMountManager
2089
+     * @deprecated 20.0.0
2090
+     **/
2091
+    public function getMountManager() {
2092
+        return $this->get(IMountManager::class);
2093
+    }
2094
+
2095
+    /**
2096
+     * @return IUserMountCache
2097
+     * @deprecated 20.0.0
2098
+     */
2099
+    public function getUserMountCache() {
2100
+        return $this->get(IUserMountCache::class);
2101
+    }
2102
+
2103
+    /**
2104
+     * Get the MimeTypeDetector
2105
+     *
2106
+     * @return IMimeTypeDetector
2107
+     * @deprecated 20.0.0
2108
+     */
2109
+    public function getMimeTypeDetector() {
2110
+        return $this->get(IMimeTypeDetector::class);
2111
+    }
2112
+
2113
+    /**
2114
+     * Get the MimeTypeLoader
2115
+     *
2116
+     * @return IMimeTypeLoader
2117
+     * @deprecated 20.0.0
2118
+     */
2119
+    public function getMimeTypeLoader() {
2120
+        return $this->get(IMimeTypeLoader::class);
2121
+    }
2122
+
2123
+    /**
2124
+     * Get the manager of all the capabilities
2125
+     *
2126
+     * @return CapabilitiesManager
2127
+     * @deprecated 20.0.0
2128
+     */
2129
+    public function getCapabilitiesManager() {
2130
+        return $this->get(CapabilitiesManager::class);
2131
+    }
2132
+
2133
+    /**
2134
+     * Get the EventDispatcher
2135
+     *
2136
+     * @return EventDispatcherInterface
2137
+     * @since 8.2.0
2138
+     * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher
2139
+     */
2140
+    public function getEventDispatcher() {
2141
+        return $this->get(\OC\EventDispatcher\SymfonyAdapter::class);
2142
+    }
2143
+
2144
+    /**
2145
+     * Get the Notification Manager
2146
+     *
2147
+     * @return \OCP\Notification\IManager
2148
+     * @since 8.2.0
2149
+     * @deprecated 20.0.0
2150
+     */
2151
+    public function getNotificationManager() {
2152
+        return $this->get(\OCP\Notification\IManager::class);
2153
+    }
2154
+
2155
+    /**
2156
+     * @return ICommentsManager
2157
+     * @deprecated 20.0.0
2158
+     */
2159
+    public function getCommentsManager() {
2160
+        return $this->get(ICommentsManager::class);
2161
+    }
2162
+
2163
+    /**
2164
+     * @return \OCA\Theming\ThemingDefaults
2165
+     * @deprecated 20.0.0
2166
+     */
2167
+    public function getThemingDefaults() {
2168
+        return $this->get('ThemingDefaults');
2169
+    }
2170
+
2171
+    /**
2172
+     * @return \OC\IntegrityCheck\Checker
2173
+     * @deprecated 20.0.0
2174
+     */
2175
+    public function getIntegrityCodeChecker() {
2176
+        return $this->get('IntegrityCodeChecker');
2177
+    }
2178
+
2179
+    /**
2180
+     * @return \OC\Session\CryptoWrapper
2181
+     * @deprecated 20.0.0
2182
+     */
2183
+    public function getSessionCryptoWrapper() {
2184
+        return $this->get('CryptoWrapper');
2185
+    }
2186
+
2187
+    /**
2188
+     * @return CsrfTokenManager
2189
+     * @deprecated 20.0.0
2190
+     */
2191
+    public function getCsrfTokenManager() {
2192
+        return $this->get(CsrfTokenManager::class);
2193
+    }
2194
+
2195
+    /**
2196
+     * @return Throttler
2197
+     * @deprecated 20.0.0
2198
+     */
2199
+    public function getBruteForceThrottler() {
2200
+        return $this->get(Throttler::class);
2201
+    }
2202
+
2203
+    /**
2204
+     * @return IContentSecurityPolicyManager
2205
+     * @deprecated 20.0.0
2206
+     */
2207
+    public function getContentSecurityPolicyManager() {
2208
+        return $this->get(ContentSecurityPolicyManager::class);
2209
+    }
2210
+
2211
+    /**
2212
+     * @return ContentSecurityPolicyNonceManager
2213
+     * @deprecated 20.0.0
2214
+     */
2215
+    public function getContentSecurityPolicyNonceManager() {
2216
+        return $this->get(ContentSecurityPolicyNonceManager::class);
2217
+    }
2218
+
2219
+    /**
2220
+     * Not a public API as of 8.2, wait for 9.0
2221
+     *
2222
+     * @return \OCA\Files_External\Service\BackendService
2223
+     * @deprecated 20.0.0
2224
+     */
2225
+    public function getStoragesBackendService() {
2226
+        return $this->get(BackendService::class);
2227
+    }
2228
+
2229
+    /**
2230
+     * Not a public API as of 8.2, wait for 9.0
2231
+     *
2232
+     * @return \OCA\Files_External\Service\GlobalStoragesService
2233
+     * @deprecated 20.0.0
2234
+     */
2235
+    public function getGlobalStoragesService() {
2236
+        return $this->get(GlobalStoragesService::class);
2237
+    }
2238
+
2239
+    /**
2240
+     * Not a public API as of 8.2, wait for 9.0
2241
+     *
2242
+     * @return \OCA\Files_External\Service\UserGlobalStoragesService
2243
+     * @deprecated 20.0.0
2244
+     */
2245
+    public function getUserGlobalStoragesService() {
2246
+        return $this->get(UserGlobalStoragesService::class);
2247
+    }
2248
+
2249
+    /**
2250
+     * Not a public API as of 8.2, wait for 9.0
2251
+     *
2252
+     * @return \OCA\Files_External\Service\UserStoragesService
2253
+     * @deprecated 20.0.0
2254
+     */
2255
+    public function getUserStoragesService() {
2256
+        return $this->get(UserStoragesService::class);
2257
+    }
2258
+
2259
+    /**
2260
+     * @return \OCP\Share\IManager
2261
+     * @deprecated 20.0.0
2262
+     */
2263
+    public function getShareManager() {
2264
+        return $this->get(\OCP\Share\IManager::class);
2265
+    }
2266
+
2267
+    /**
2268
+     * @return \OCP\Collaboration\Collaborators\ISearch
2269
+     * @deprecated 20.0.0
2270
+     */
2271
+    public function getCollaboratorSearch() {
2272
+        return $this->get(\OCP\Collaboration\Collaborators\ISearch::class);
2273
+    }
2274
+
2275
+    /**
2276
+     * @return \OCP\Collaboration\AutoComplete\IManager
2277
+     * @deprecated 20.0.0
2278
+     */
2279
+    public function getAutoCompleteManager() {
2280
+        return $this->get(IManager::class);
2281
+    }
2282
+
2283
+    /**
2284
+     * Returns the LDAP Provider
2285
+     *
2286
+     * @return \OCP\LDAP\ILDAPProvider
2287
+     * @deprecated 20.0.0
2288
+     */
2289
+    public function getLDAPProvider() {
2290
+        return $this->get('LDAPProvider');
2291
+    }
2292
+
2293
+    /**
2294
+     * @return \OCP\Settings\IManager
2295
+     * @deprecated 20.0.0
2296
+     */
2297
+    public function getSettingsManager() {
2298
+        return $this->get(\OC\Settings\Manager::class);
2299
+    }
2300
+
2301
+    /**
2302
+     * @return \OCP\Files\IAppData
2303
+     * @deprecated 20.0.0
2304
+     */
2305
+    public function getAppDataDir($app) {
2306
+        /** @var \OC\Files\AppData\Factory $factory */
2307
+        $factory = $this->get(\OC\Files\AppData\Factory::class);
2308
+        return $factory->get($app);
2309
+    }
2310
+
2311
+    /**
2312
+     * @return \OCP\Lockdown\ILockdownManager
2313
+     * @deprecated 20.0.0
2314
+     */
2315
+    public function getLockdownManager() {
2316
+        return $this->get('LockdownManager');
2317
+    }
2318
+
2319
+    /**
2320
+     * @return \OCP\Federation\ICloudIdManager
2321
+     * @deprecated 20.0.0
2322
+     */
2323
+    public function getCloudIdManager() {
2324
+        return $this->get(ICloudIdManager::class);
2325
+    }
2326
+
2327
+    /**
2328
+     * @return \OCP\GlobalScale\IConfig
2329
+     * @deprecated 20.0.0
2330
+     */
2331
+    public function getGlobalScaleConfig() {
2332
+        return $this->get(IConfig::class);
2333
+    }
2334
+
2335
+    /**
2336
+     * @return \OCP\Federation\ICloudFederationProviderManager
2337
+     * @deprecated 20.0.0
2338
+     */
2339
+    public function getCloudFederationProviderManager() {
2340
+        return $this->get(ICloudFederationProviderManager::class);
2341
+    }
2342
+
2343
+    /**
2344
+     * @return \OCP\Remote\Api\IApiFactory
2345
+     * @deprecated 20.0.0
2346
+     */
2347
+    public function getRemoteApiFactory() {
2348
+        return $this->get(IApiFactory::class);
2349
+    }
2350
+
2351
+    /**
2352
+     * @return \OCP\Federation\ICloudFederationFactory
2353
+     * @deprecated 20.0.0
2354
+     */
2355
+    public function getCloudFederationFactory() {
2356
+        return $this->get(ICloudFederationFactory::class);
2357
+    }
2358
+
2359
+    /**
2360
+     * @return \OCP\Remote\IInstanceFactory
2361
+     * @deprecated 20.0.0
2362
+     */
2363
+    public function getRemoteInstanceFactory() {
2364
+        return $this->get(IInstanceFactory::class);
2365
+    }
2366
+
2367
+    /**
2368
+     * @return IStorageFactory
2369
+     * @deprecated 20.0.0
2370
+     */
2371
+    public function getStorageFactory() {
2372
+        return $this->get(IStorageFactory::class);
2373
+    }
2374
+
2375
+    /**
2376
+     * Get the Preview GeneratorHelper
2377
+     *
2378
+     * @return GeneratorHelper
2379
+     * @since 17.0.0
2380
+     * @deprecated 20.0.0
2381
+     */
2382
+    public function getGeneratorHelper() {
2383
+        return $this->get(\OC\Preview\GeneratorHelper::class);
2384
+    }
2385
+
2386
+    private function registerDeprecatedAlias(string $alias, string $target) {
2387
+        $this->registerService($alias, function (ContainerInterface $container) use ($target, $alias) {
2388
+            try {
2389
+                /** @var LoggerInterface $logger */
2390
+                $logger = $container->get(LoggerInterface::class);
2391
+                $logger->debug('The requested alias "' . $alias . '" is deprecated. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']);
2392
+            } catch (ContainerExceptionInterface $e) {
2393
+                // Could not get logger. Continue
2394
+            }
2395
+
2396
+            return $container->get($target);
2397
+        }, false);
2398
+    }
2399 2399
 }
Please login to merge, or discard this patch.
lib/private/Comments/Manager.php 1 patch
Indentation   +1589 added lines, -1589 removed lines patch added patch discarded remove patch
@@ -48,1593 +48,1593 @@
 block discarded – undo
48 48
 
49 49
 class Manager implements ICommentsManager {
50 50
 
51
-	/** @var  IDBConnection */
52
-	protected $dbConn;
53
-
54
-	/** @var  LoggerInterface */
55
-	protected $logger;
56
-
57
-	/** @var IConfig */
58
-	protected $config;
59
-
60
-	/** @var ITimeFactory */
61
-	protected $timeFactory;
62
-
63
-	/** @var IEmojiHelper */
64
-	protected $emojiHelper;
65
-
66
-	/** @var IInitialStateService */
67
-	protected $initialStateService;
68
-
69
-	/** @var IComment[] */
70
-	protected $commentsCache = [];
71
-
72
-	/** @var  \Closure[] */
73
-	protected $eventHandlerClosures = [];
74
-
75
-	/** @var  ICommentsEventHandler[] */
76
-	protected $eventHandlers = [];
77
-
78
-	/** @var \Closure[] */
79
-	protected $displayNameResolvers = [];
80
-
81
-	public function __construct(IDBConnection $dbConn,
82
-								LoggerInterface $logger,
83
-								IConfig $config,
84
-								ITimeFactory $timeFactory,
85
-								IEmojiHelper $emojiHelper,
86
-								IInitialStateService $initialStateService) {
87
-		$this->dbConn = $dbConn;
88
-		$this->logger = $logger;
89
-		$this->config = $config;
90
-		$this->timeFactory = $timeFactory;
91
-		$this->emojiHelper = $emojiHelper;
92
-		$this->initialStateService = $initialStateService;
93
-	}
94
-
95
-	/**
96
-	 * converts data base data into PHP native, proper types as defined by
97
-	 * IComment interface.
98
-	 *
99
-	 * @param array $data
100
-	 * @return array
101
-	 */
102
-	protected function normalizeDatabaseData(array $data) {
103
-		$data['id'] = (string)$data['id'];
104
-		$data['parent_id'] = (string)$data['parent_id'];
105
-		$data['topmost_parent_id'] = (string)$data['topmost_parent_id'];
106
-		$data['creation_timestamp'] = new \DateTime($data['creation_timestamp']);
107
-		if (!is_null($data['latest_child_timestamp'])) {
108
-			$data['latest_child_timestamp'] = new \DateTime($data['latest_child_timestamp']);
109
-		}
110
-		$data['children_count'] = (int)$data['children_count'];
111
-		$data['reference_id'] = $data['reference_id'] ?? null;
112
-		if ($this->supportReactions()) {
113
-			$list = json_decode($data['reactions'], true);
114
-			// Ordering does not work on the database with group concat and Oracle,
115
-			// So we simply sort on the output.
116
-			if (is_array($list)) {
117
-				uasort($list, static function ($a, $b) {
118
-					if ($a === $b) {
119
-						return 0;
120
-					}
121
-					return ($a > $b) ? -1 : 1;
122
-				});
123
-			}
124
-			$data['reactions'] = $list;
125
-		}
126
-		return $data;
127
-	}
128
-
129
-
130
-	/**
131
-	 * @param array $data
132
-	 * @return IComment
133
-	 */
134
-	public function getCommentFromData(array $data): IComment {
135
-		return new Comment($this->normalizeDatabaseData($data));
136
-	}
137
-
138
-	/**
139
-	 * prepares a comment for an insert or update operation after making sure
140
-	 * all necessary fields have a value assigned.
141
-	 *
142
-	 * @param IComment $comment
143
-	 * @return IComment returns the same updated IComment instance as provided
144
-	 *                  by parameter for convenience
145
-	 * @throws \UnexpectedValueException
146
-	 */
147
-	protected function prepareCommentForDatabaseWrite(IComment $comment) {
148
-		if (!$comment->getActorType()
149
-			|| $comment->getActorId() === ''
150
-			|| !$comment->getObjectType()
151
-			|| $comment->getObjectId() === ''
152
-			|| !$comment->getVerb()
153
-		) {
154
-			throw new \UnexpectedValueException('Actor, Object and Verb information must be provided for saving');
155
-		}
156
-
157
-		if ($comment->getVerb() === 'reaction' && !$this->emojiHelper->isValidSingleEmoji($comment->getMessage())) {
158
-			// 4 characters: laptop + person + gender + skin color => "
Please login to merge, or discard this patch.