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