Completed
Push — master ( b69109...1a2d0d )
by
unknown
39:14 queued 16:05
created
tests/lib/Activity/ManagerTest.php 1 patch
Indentation   +268 added lines, -268 removed lines patch added patch discarded remove patch
@@ -23,275 +23,275 @@
 block discarded – undo
23 23
 use Test\TestCase;
24 24
 
25 25
 class ManagerTest extends TestCase {
26
-	/** @var \OC\Activity\Manager */
27
-	private $activityManager;
28
-
29
-	protected IRequest&MockObject $request;
30
-	protected IUserSession&MockObject $session;
31
-	protected IConfig&MockObject $config;
32
-	protected IValidator&MockObject $validator;
33
-	protected IRichTextFormatter&MockObject $richTextFormatter;
34
-	private ITimeFactory&MockObject $time;
35
-
36
-	protected function setUp(): void {
37
-		parent::setUp();
38
-
39
-		$this->request = $this->createMock(IRequest::class);
40
-		$this->session = $this->createMock(IUserSession::class);
41
-		$this->config = $this->createMock(IConfig::class);
42
-		$this->validator = $this->createMock(IValidator::class);
43
-		$this->richTextFormatter = $this->createMock(IRichTextFormatter::class);
44
-		$this->time = $this->createMock(ITimeFactory::class);
45
-
46
-		$this->activityManager = new \OC\Activity\Manager(
47
-			$this->request,
48
-			$this->session,
49
-			$this->config,
50
-			$this->validator,
51
-			$this->richTextFormatter,
52
-			$this->createMock(IL10N::class),
53
-			$this->time,
54
-		);
55
-
56
-		$this->assertSame([], self::invokePrivate($this->activityManager, 'getConsumers'));
57
-
58
-		$this->activityManager->registerConsumer(function () {
59
-			return new NoOpConsumer();
60
-		});
61
-
62
-		$this->assertNotEmpty(self::invokePrivate($this->activityManager, 'getConsumers'));
63
-		$this->assertNotEmpty(self::invokePrivate($this->activityManager, 'getConsumers'));
64
-	}
65
-
66
-	public function testGetConsumers(): void {
67
-		$consumers = self::invokePrivate($this->activityManager, 'getConsumers');
68
-
69
-		$this->assertNotEmpty($consumers);
70
-	}
71
-
72
-
73
-	public function testGetConsumersInvalidConsumer(): void {
74
-		$this->expectException(\InvalidArgumentException::class);
75
-
76
-		$this->activityManager->registerConsumer(function () {
77
-			return new \stdClass();
78
-		});
79
-
80
-		self::invokePrivate($this->activityManager, 'getConsumers');
81
-	}
82
-
83
-	public static function getUserFromTokenThrowInvalidTokenData(): array {
84
-		return [
85
-			[null, []],
86
-			['', []],
87
-			['12345678901234567890123456789', []],
88
-			['1234567890123456789012345678901', []],
89
-			['123456789012345678901234567890', []],
90
-			['123456789012345678901234567890', ['user1', 'user2']],
91
-		];
92
-	}
93
-
94
-	/**
95
-	 *
96
-	 * @param string $token
97
-	 * @param array $users
98
-	 */
99
-	#[\PHPUnit\Framework\Attributes\DataProvider('getUserFromTokenThrowInvalidTokenData')]
100
-	public function testGetUserFromTokenThrowInvalidToken($token, $users): void {
101
-		$this->expectException(\UnexpectedValueException::class);
102
-
103
-		$this->mockRSSToken($token, $token, $users);
104
-		self::invokePrivate($this->activityManager, 'getUserFromToken');
105
-	}
106
-
107
-	public static function getUserFromTokenData(): array {
108
-		return [
109
-			[null, '123456789012345678901234567890', 'user1'],
110
-			['user2', null, 'user2'],
111
-			['user2', '123456789012345678901234567890', 'user2'],
112
-		];
113
-	}
114
-
115
-	/**
116
-	 *
117
-	 * @param string $userLoggedIn
118
-	 * @param string $token
119
-	 * @param string $expected
120
-	 */
121
-	#[\PHPUnit\Framework\Attributes\DataProvider('getUserFromTokenData')]
122
-	public function testGetUserFromToken($userLoggedIn, $token, $expected): void {
123
-		if ($userLoggedIn !== null) {
124
-			$this->mockUserSession($userLoggedIn);
125
-		}
126
-		$this->mockRSSToken($token, '123456789012345678901234567890', ['user1']);
127
-
128
-		$this->assertEquals($expected, $this->activityManager->getCurrentUserId());
129
-	}
130
-
131
-	protected function mockRSSToken($requestToken, $userToken, $users) {
132
-		if ($requestToken !== null) {
133
-			$this->request->expects($this->any())
134
-				->method('getParam')
135
-				->with('token', '')
136
-				->willReturn($requestToken);
137
-		}
138
-
139
-		$this->config->expects($this->any())
140
-			->method('getUsersForUserValue')
141
-			->with('activity', 'rsstoken', $userToken)
142
-			->willReturn($users);
143
-	}
144
-
145
-	protected function mockUserSession($user) {
146
-		$mockUser = $this->getMockBuilder(IUser::class)
147
-			->disableOriginalConstructor()
148
-			->getMock();
149
-		$mockUser->expects($this->any())
150
-			->method('getUID')
151
-			->willReturn($user);
152
-
153
-		$this->session->expects($this->any())
154
-			->method('isLoggedIn')
155
-			->willReturn(true);
156
-		$this->session->expects($this->any())
157
-			->method('getUser')
158
-			->willReturn($mockUser);
159
-	}
160
-
161
-
162
-	public function testPublishExceptionNoApp(): void {
163
-		$this->expectException(IncompleteActivityException::class);
164
-
165
-		$event = $this->activityManager->generateEvent();
166
-		$this->activityManager->publish($event);
167
-	}
168
-
169
-
170
-	public function testPublishExceptionNoType(): void {
171
-		$this->expectException(IncompleteActivityException::class);
172
-
173
-		$event = $this->activityManager->generateEvent();
174
-		$event->setApp('test');
175
-		$this->activityManager->publish($event);
176
-	}
177
-
178
-
179
-	public function testPublishExceptionNoAffectedUser(): void {
180
-		$this->expectException(IncompleteActivityException::class);
181
-
182
-		$event = $this->activityManager->generateEvent();
183
-		$event->setApp('test')
184
-			->setType('test_type');
185
-		$this->activityManager->publish($event);
186
-	}
187
-
188
-
189
-	public function testPublishExceptionNoSubject(): void {
190
-		$this->expectException(IncompleteActivityException::class);
191
-
192
-		$event = $this->activityManager->generateEvent();
193
-		$event->setApp('test')
194
-			->setType('test_type')
195
-			->setAffectedUser('test_affected');
196
-		$this->activityManager->publish($event);
197
-	}
198
-
199
-	public static function dataPublish(): array {
200
-		return [
201
-			[null, ''],
202
-			['test_author', 'test_author'],
203
-		];
204
-	}
205
-
206
-	/**
207
-	 * @param string|null $author
208
-	 * @param string $expected
209
-	 */
210
-	#[\PHPUnit\Framework\Attributes\DataProvider('dataPublish')]
211
-	public function testPublish($author, $expected): void {
212
-		if ($author !== null) {
213
-			$authorObject = $this->getMockBuilder(IUser::class)
214
-				->disableOriginalConstructor()
215
-				->getMock();
216
-			$authorObject->expects($this->once())
217
-				->method('getUID')
218
-				->willReturn($author);
219
-			$this->session->expects($this->atLeastOnce())
220
-				->method('getUser')
221
-				->willReturn($authorObject);
222
-		}
223
-
224
-		$time = time();
225
-		$this->time
226
-			->method('getTime')
227
-			->willReturn($time);
228
-
229
-		$event = $this->activityManager->generateEvent();
230
-		$event->setApp('test')
231
-			->setType('test_type')
232
-			->setSubject('test_subject', [])
233
-			->setAffectedUser('test_affected')
234
-			->setObject('file', 123);
235
-
236
-		$consumer = $this->getMockBuilder('OCP\Activity\IConsumer')
237
-			->disableOriginalConstructor()
238
-			->getMock();
239
-		$consumer->expects($this->once())
240
-			->method('receive')
241
-			->with($event)
242
-			->willReturnCallback(function (IEvent $event) use ($expected, $time): void {
243
-				$this->assertEquals($time, $event->getTimestamp(), 'Timestamp not set correctly');
244
-				$this->assertSame($expected, $event->getAuthor(), 'Author name not set correctly');
245
-			});
246
-		$this->activityManager->registerConsumer(function () use ($consumer) {
247
-			return $consumer;
248
-		});
249
-
250
-		$this->activityManager->publish($event);
251
-	}
252
-
253
-	public function testPublishAllManually(): void {
254
-		$event = $this->activityManager->generateEvent();
255
-		$event->setApp('test_app')
256
-			->setType('test_type')
257
-			->setAffectedUser('test_affected')
258
-			->setAuthor('test_author')
259
-			->setTimestamp(1337)
260
-			->setSubject('test_subject', ['test_subject_param'])
261
-			->setMessage('test_message', ['test_message_param'])
262
-			->setObject('test_object_type', 42, 'test_object_name')
263
-			->setLink('test_link')
264
-		;
265
-
266
-		$consumer = $this->getMockBuilder('OCP\Activity\IConsumer')
267
-			->disableOriginalConstructor()
268
-			->getMock();
269
-		$consumer->expects($this->once())
270
-			->method('receive')
271
-			->willReturnCallback(function (IEvent $event): void {
272
-				$this->assertSame('test_app', $event->getApp(), 'App not set correctly');
273
-				$this->assertSame('test_type', $event->getType(), 'Type not set correctly');
274
-				$this->assertSame('test_affected', $event->getAffectedUser(), 'Affected user not set correctly');
275
-				$this->assertSame('test_author', $event->getAuthor(), 'Author not set correctly');
276
-				$this->assertSame(1337, $event->getTimestamp(), 'Timestamp not set correctly');
277
-				$this->assertSame('test_subject', $event->getSubject(), 'Subject not set correctly');
278
-				$this->assertSame(['test_subject_param'], $event->getSubjectParameters(), 'Subject parameter not set correctly');
279
-				$this->assertSame('test_message', $event->getMessage(), 'Message not set correctly');
280
-				$this->assertSame(['test_message_param'], $event->getMessageParameters(), 'Message parameter not set correctly');
281
-				$this->assertSame('test_object_type', $event->getObjectType(), 'Object type not set correctly');
282
-				$this->assertSame(42, $event->getObjectId(), 'Object ID not set correctly');
283
-				$this->assertSame('test_object_name', $event->getObjectName(), 'Object name not set correctly');
284
-				$this->assertSame('test_link', $event->getLink(), 'Link not set correctly');
285
-			});
286
-		$this->activityManager->registerConsumer(function () use ($consumer) {
287
-			return $consumer;
288
-		});
289
-
290
-		$this->activityManager->publish($event);
291
-	}
26
+    /** @var \OC\Activity\Manager */
27
+    private $activityManager;
28
+
29
+    protected IRequest&MockObject $request;
30
+    protected IUserSession&MockObject $session;
31
+    protected IConfig&MockObject $config;
32
+    protected IValidator&MockObject $validator;
33
+    protected IRichTextFormatter&MockObject $richTextFormatter;
34
+    private ITimeFactory&MockObject $time;
35
+
36
+    protected function setUp(): void {
37
+        parent::setUp();
38
+
39
+        $this->request = $this->createMock(IRequest::class);
40
+        $this->session = $this->createMock(IUserSession::class);
41
+        $this->config = $this->createMock(IConfig::class);
42
+        $this->validator = $this->createMock(IValidator::class);
43
+        $this->richTextFormatter = $this->createMock(IRichTextFormatter::class);
44
+        $this->time = $this->createMock(ITimeFactory::class);
45
+
46
+        $this->activityManager = new \OC\Activity\Manager(
47
+            $this->request,
48
+            $this->session,
49
+            $this->config,
50
+            $this->validator,
51
+            $this->richTextFormatter,
52
+            $this->createMock(IL10N::class),
53
+            $this->time,
54
+        );
55
+
56
+        $this->assertSame([], self::invokePrivate($this->activityManager, 'getConsumers'));
57
+
58
+        $this->activityManager->registerConsumer(function () {
59
+            return new NoOpConsumer();
60
+        });
61
+
62
+        $this->assertNotEmpty(self::invokePrivate($this->activityManager, 'getConsumers'));
63
+        $this->assertNotEmpty(self::invokePrivate($this->activityManager, 'getConsumers'));
64
+    }
65
+
66
+    public function testGetConsumers(): void {
67
+        $consumers = self::invokePrivate($this->activityManager, 'getConsumers');
68
+
69
+        $this->assertNotEmpty($consumers);
70
+    }
71
+
72
+
73
+    public function testGetConsumersInvalidConsumer(): void {
74
+        $this->expectException(\InvalidArgumentException::class);
75
+
76
+        $this->activityManager->registerConsumer(function () {
77
+            return new \stdClass();
78
+        });
79
+
80
+        self::invokePrivate($this->activityManager, 'getConsumers');
81
+    }
82
+
83
+    public static function getUserFromTokenThrowInvalidTokenData(): array {
84
+        return [
85
+            [null, []],
86
+            ['', []],
87
+            ['12345678901234567890123456789', []],
88
+            ['1234567890123456789012345678901', []],
89
+            ['123456789012345678901234567890', []],
90
+            ['123456789012345678901234567890', ['user1', 'user2']],
91
+        ];
92
+    }
93
+
94
+    /**
95
+     *
96
+     * @param string $token
97
+     * @param array $users
98
+     */
99
+    #[\PHPUnit\Framework\Attributes\DataProvider('getUserFromTokenThrowInvalidTokenData')]
100
+    public function testGetUserFromTokenThrowInvalidToken($token, $users): void {
101
+        $this->expectException(\UnexpectedValueException::class);
102
+
103
+        $this->mockRSSToken($token, $token, $users);
104
+        self::invokePrivate($this->activityManager, 'getUserFromToken');
105
+    }
106
+
107
+    public static function getUserFromTokenData(): array {
108
+        return [
109
+            [null, '123456789012345678901234567890', 'user1'],
110
+            ['user2', null, 'user2'],
111
+            ['user2', '123456789012345678901234567890', 'user2'],
112
+        ];
113
+    }
114
+
115
+    /**
116
+     *
117
+     * @param string $userLoggedIn
118
+     * @param string $token
119
+     * @param string $expected
120
+     */
121
+    #[\PHPUnit\Framework\Attributes\DataProvider('getUserFromTokenData')]
122
+    public function testGetUserFromToken($userLoggedIn, $token, $expected): void {
123
+        if ($userLoggedIn !== null) {
124
+            $this->mockUserSession($userLoggedIn);
125
+        }
126
+        $this->mockRSSToken($token, '123456789012345678901234567890', ['user1']);
127
+
128
+        $this->assertEquals($expected, $this->activityManager->getCurrentUserId());
129
+    }
130
+
131
+    protected function mockRSSToken($requestToken, $userToken, $users) {
132
+        if ($requestToken !== null) {
133
+            $this->request->expects($this->any())
134
+                ->method('getParam')
135
+                ->with('token', '')
136
+                ->willReturn($requestToken);
137
+        }
138
+
139
+        $this->config->expects($this->any())
140
+            ->method('getUsersForUserValue')
141
+            ->with('activity', 'rsstoken', $userToken)
142
+            ->willReturn($users);
143
+    }
144
+
145
+    protected function mockUserSession($user) {
146
+        $mockUser = $this->getMockBuilder(IUser::class)
147
+            ->disableOriginalConstructor()
148
+            ->getMock();
149
+        $mockUser->expects($this->any())
150
+            ->method('getUID')
151
+            ->willReturn($user);
152
+
153
+        $this->session->expects($this->any())
154
+            ->method('isLoggedIn')
155
+            ->willReturn(true);
156
+        $this->session->expects($this->any())
157
+            ->method('getUser')
158
+            ->willReturn($mockUser);
159
+    }
160
+
161
+
162
+    public function testPublishExceptionNoApp(): void {
163
+        $this->expectException(IncompleteActivityException::class);
164
+
165
+        $event = $this->activityManager->generateEvent();
166
+        $this->activityManager->publish($event);
167
+    }
168
+
169
+
170
+    public function testPublishExceptionNoType(): void {
171
+        $this->expectException(IncompleteActivityException::class);
172
+
173
+        $event = $this->activityManager->generateEvent();
174
+        $event->setApp('test');
175
+        $this->activityManager->publish($event);
176
+    }
177
+
178
+
179
+    public function testPublishExceptionNoAffectedUser(): void {
180
+        $this->expectException(IncompleteActivityException::class);
181
+
182
+        $event = $this->activityManager->generateEvent();
183
+        $event->setApp('test')
184
+            ->setType('test_type');
185
+        $this->activityManager->publish($event);
186
+    }
187
+
188
+
189
+    public function testPublishExceptionNoSubject(): void {
190
+        $this->expectException(IncompleteActivityException::class);
191
+
192
+        $event = $this->activityManager->generateEvent();
193
+        $event->setApp('test')
194
+            ->setType('test_type')
195
+            ->setAffectedUser('test_affected');
196
+        $this->activityManager->publish($event);
197
+    }
198
+
199
+    public static function dataPublish(): array {
200
+        return [
201
+            [null, ''],
202
+            ['test_author', 'test_author'],
203
+        ];
204
+    }
205
+
206
+    /**
207
+     * @param string|null $author
208
+     * @param string $expected
209
+     */
210
+    #[\PHPUnit\Framework\Attributes\DataProvider('dataPublish')]
211
+    public function testPublish($author, $expected): void {
212
+        if ($author !== null) {
213
+            $authorObject = $this->getMockBuilder(IUser::class)
214
+                ->disableOriginalConstructor()
215
+                ->getMock();
216
+            $authorObject->expects($this->once())
217
+                ->method('getUID')
218
+                ->willReturn($author);
219
+            $this->session->expects($this->atLeastOnce())
220
+                ->method('getUser')
221
+                ->willReturn($authorObject);
222
+        }
223
+
224
+        $time = time();
225
+        $this->time
226
+            ->method('getTime')
227
+            ->willReturn($time);
228
+
229
+        $event = $this->activityManager->generateEvent();
230
+        $event->setApp('test')
231
+            ->setType('test_type')
232
+            ->setSubject('test_subject', [])
233
+            ->setAffectedUser('test_affected')
234
+            ->setObject('file', 123);
235
+
236
+        $consumer = $this->getMockBuilder('OCP\Activity\IConsumer')
237
+            ->disableOriginalConstructor()
238
+            ->getMock();
239
+        $consumer->expects($this->once())
240
+            ->method('receive')
241
+            ->with($event)
242
+            ->willReturnCallback(function (IEvent $event) use ($expected, $time): void {
243
+                $this->assertEquals($time, $event->getTimestamp(), 'Timestamp not set correctly');
244
+                $this->assertSame($expected, $event->getAuthor(), 'Author name not set correctly');
245
+            });
246
+        $this->activityManager->registerConsumer(function () use ($consumer) {
247
+            return $consumer;
248
+        });
249
+
250
+        $this->activityManager->publish($event);
251
+    }
252
+
253
+    public function testPublishAllManually(): void {
254
+        $event = $this->activityManager->generateEvent();
255
+        $event->setApp('test_app')
256
+            ->setType('test_type')
257
+            ->setAffectedUser('test_affected')
258
+            ->setAuthor('test_author')
259
+            ->setTimestamp(1337)
260
+            ->setSubject('test_subject', ['test_subject_param'])
261
+            ->setMessage('test_message', ['test_message_param'])
262
+            ->setObject('test_object_type', 42, 'test_object_name')
263
+            ->setLink('test_link')
264
+        ;
265
+
266
+        $consumer = $this->getMockBuilder('OCP\Activity\IConsumer')
267
+            ->disableOriginalConstructor()
268
+            ->getMock();
269
+        $consumer->expects($this->once())
270
+            ->method('receive')
271
+            ->willReturnCallback(function (IEvent $event): void {
272
+                $this->assertSame('test_app', $event->getApp(), 'App not set correctly');
273
+                $this->assertSame('test_type', $event->getType(), 'Type not set correctly');
274
+                $this->assertSame('test_affected', $event->getAffectedUser(), 'Affected user not set correctly');
275
+                $this->assertSame('test_author', $event->getAuthor(), 'Author not set correctly');
276
+                $this->assertSame(1337, $event->getTimestamp(), 'Timestamp not set correctly');
277
+                $this->assertSame('test_subject', $event->getSubject(), 'Subject not set correctly');
278
+                $this->assertSame(['test_subject_param'], $event->getSubjectParameters(), 'Subject parameter not set correctly');
279
+                $this->assertSame('test_message', $event->getMessage(), 'Message not set correctly');
280
+                $this->assertSame(['test_message_param'], $event->getMessageParameters(), 'Message parameter not set correctly');
281
+                $this->assertSame('test_object_type', $event->getObjectType(), 'Object type not set correctly');
282
+                $this->assertSame(42, $event->getObjectId(), 'Object ID not set correctly');
283
+                $this->assertSame('test_object_name', $event->getObjectName(), 'Object name not set correctly');
284
+                $this->assertSame('test_link', $event->getLink(), 'Link not set correctly');
285
+            });
286
+        $this->activityManager->registerConsumer(function () use ($consumer) {
287
+            return $consumer;
288
+        });
289
+
290
+        $this->activityManager->publish($event);
291
+    }
292 292
 }
293 293
 
294 294
 class NoOpConsumer implements IConsumer {
295
-	public function receive(IEvent $event) {
296
-	}
295
+    public function receive(IEvent $event) {
296
+    }
297 297
 }
Please login to merge, or discard this patch.
lib/private/Server.php 1 patch
Indentation   +1408 added lines, -1408 removed lines patch added patch discarded remove patch
@@ -248,1449 +248,1449 @@
 block discarded – undo
248 248
  * TODO: hookup all manager classes
249 249
  */
250 250
 class Server extends ServerContainer implements IServerContainer {
251
-	/** @var string */
252
-	private $webRoot;
253
-
254
-	/**
255
-	 * @param string $webRoot
256
-	 * @param \OC\Config $config
257
-	 */
258
-	public function __construct($webRoot, \OC\Config $config) {
259
-		parent::__construct();
260
-		$this->webRoot = $webRoot;
261
-
262
-		// To find out if we are running from CLI or not
263
-		$this->registerParameter('isCLI', \OC::$CLI);
264
-		$this->registerParameter('serverRoot', \OC::$SERVERROOT);
265
-
266
-		$this->registerService(ContainerInterface::class, function (ContainerInterface $c) {
267
-			return $c;
268
-		});
269
-		$this->registerDeprecatedAlias(\OCP\IServerContainer::class, ContainerInterface::class);
270
-
271
-		$this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
272
-
273
-		$this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class);
274
-
275
-		$this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class);
276
-
277
-		$this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
278
-
279
-		$this->registerAlias(\OCP\ContextChat\IContentManager::class, \OC\ContextChat\ContentManager::class);
280
-
281
-		$this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class);
282
-		$this->registerAlias(ITemplateManager::class, TemplateManager::class);
283
-		$this->registerAlias(\OCP\Template\ITemplateManager::class, \OC\Template\TemplateManager::class);
284
-
285
-		$this->registerAlias(IActionFactory::class, ActionFactory::class);
286
-
287
-		$this->registerService(View::class, function (Server $c) {
288
-			return new View();
289
-		}, false);
290
-
291
-		$this->registerService(IPreview::class, function (ContainerInterface $c) {
292
-			return new PreviewManager(
293
-				$c->get(\OCP\IConfig::class),
294
-				$c->get(IRootFolder::class),
295
-				new \OC\Preview\Storage\Root(
296
-					$c->get(IRootFolder::class),
297
-					$c->get(SystemConfig::class)
298
-				),
299
-				$c->get(IEventDispatcher::class),
300
-				$c->get(GeneratorHelper::class),
301
-				$c->get(ISession::class)->get('user_id'),
302
-				$c->get(Coordinator::class),
303
-				$c->get(IServerContainer::class),
304
-				$c->get(IBinaryFinder::class),
305
-				$c->get(IMagickSupport::class)
306
-			);
307
-		});
308
-		$this->registerAlias(IMimeIconProvider::class, MimeIconProvider::class);
309
-
310
-		$this->registerService(\OC\Preview\Watcher::class, function (ContainerInterface $c) {
311
-			return new \OC\Preview\Watcher(
312
-				new \OC\Preview\Storage\Root(
313
-					$c->get(IRootFolder::class),
314
-					$c->get(SystemConfig::class)
315
-				)
316
-			);
317
-		});
318
-
319
-		$this->registerService(IProfiler::class, function (Server $c) {
320
-			return new Profiler($c->get(SystemConfig::class));
321
-		});
322
-
323
-		$this->registerService(Encryption\Manager::class, function (Server $c): Encryption\Manager {
324
-			$view = new View();
325
-			$util = new Encryption\Util(
326
-				$view,
327
-				$c->get(IUserManager::class),
328
-				$c->get(IGroupManager::class),
329
-				$c->get(\OCP\IConfig::class)
330
-			);
331
-			return new Encryption\Manager(
332
-				$c->get(\OCP\IConfig::class),
333
-				$c->get(LoggerInterface::class),
334
-				$c->getL10N('core'),
335
-				new View(),
336
-				$util,
337
-				new ArrayCache()
338
-			);
339
-		});
340
-		$this->registerAlias(\OCP\Encryption\IManager::class, Encryption\Manager::class);
341
-
342
-		$this->registerService(IFile::class, function (ContainerInterface $c) {
343
-			$util = new Encryption\Util(
344
-				new View(),
345
-				$c->get(IUserManager::class),
346
-				$c->get(IGroupManager::class),
347
-				$c->get(\OCP\IConfig::class)
348
-			);
349
-			return new Encryption\File(
350
-				$util,
351
-				$c->get(IRootFolder::class),
352
-				$c->get(\OCP\Share\IManager::class)
353
-			);
354
-		});
355
-
356
-		$this->registerService(IStorage::class, function (ContainerInterface $c) {
357
-			$view = new View();
358
-			$util = new Encryption\Util(
359
-				$view,
360
-				$c->get(IUserManager::class),
361
-				$c->get(IGroupManager::class),
362
-				$c->get(\OCP\IConfig::class)
363
-			);
364
-
365
-			return new Encryption\Keys\Storage(
366
-				$view,
367
-				$util,
368
-				$c->get(ICrypto::class),
369
-				$c->get(\OCP\IConfig::class)
370
-			);
371
-		});
372
-
373
-		$this->registerAlias(\OCP\ITagManager::class, TagManager::class);
374
-
375
-		$this->registerService('SystemTagManagerFactory', function (ContainerInterface $c) {
376
-			/** @var \OCP\IConfig $config */
377
-			$config = $c->get(\OCP\IConfig::class);
378
-			$factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class);
379
-			return new $factoryClass($this);
380
-		});
381
-		$this->registerService(ISystemTagManager::class, function (ContainerInterface $c) {
382
-			return $c->get('SystemTagManagerFactory')->getManager();
383
-		});
384
-		/** @deprecated 19.0.0 */
385
-		$this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class);
386
-
387
-		$this->registerService(ISystemTagObjectMapper::class, function (ContainerInterface $c) {
388
-			return $c->get('SystemTagManagerFactory')->getObjectMapper();
389
-		});
390
-		$this->registerAlias(IFileAccess::class, FileAccess::class);
391
-		$this->registerService('RootFolder', function (ContainerInterface $c) {
392
-			$manager = \OC\Files\Filesystem::getMountManager();
393
-			$view = new View();
394
-			/** @var IUserSession $userSession */
395
-			$userSession = $c->get(IUserSession::class);
396
-			$root = new Root(
397
-				$manager,
398
-				$view,
399
-				$userSession->getUser(),
400
-				$c->get(IUserMountCache::class),
401
-				$this->get(LoggerInterface::class),
402
-				$this->get(IUserManager::class),
403
-				$this->get(IEventDispatcher::class),
404
-				$this->get(ICacheFactory::class),
405
-			);
406
-
407
-			$previewConnector = new \OC\Preview\WatcherConnector(
408
-				$root,
409
-				$c->get(SystemConfig::class),
410
-				$this->get(IEventDispatcher::class)
411
-			);
412
-			$previewConnector->connectWatcher();
413
-
414
-			return $root;
415
-		});
416
-		$this->registerService(HookConnector::class, function (ContainerInterface $c) {
417
-			return new HookConnector(
418
-				$c->get(IRootFolder::class),
419
-				new View(),
420
-				$c->get(IEventDispatcher::class),
421
-				$c->get(LoggerInterface::class)
422
-			);
423
-		});
424
-
425
-		$this->registerService(IRootFolder::class, function (ContainerInterface $c) {
426
-			return new LazyRoot(function () use ($c) {
427
-				return $c->get('RootFolder');
428
-			});
429
-		});
430
-
431
-		$this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
432
-
433
-		$this->registerService(DisplayNameCache::class, function (ContainerInterface $c) {
434
-			return $c->get(\OC\User\Manager::class)->getDisplayNameCache();
435
-		});
436
-
437
-		$this->registerService(\OCP\IGroupManager::class, function (ContainerInterface $c) {
438
-			$groupManager = new \OC\Group\Manager(
439
-				$this->get(IUserManager::class),
440
-				$this->get(IEventDispatcher::class),
441
-				$this->get(LoggerInterface::class),
442
-				$this->get(ICacheFactory::class),
443
-				$this->get(IRemoteAddress::class),
444
-			);
445
-			return $groupManager;
446
-		});
447
-
448
-		$this->registerService(Store::class, function (ContainerInterface $c) {
449
-			$session = $c->get(ISession::class);
450
-			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
451
-				$tokenProvider = $c->get(IProvider::class);
452
-			} else {
453
-				$tokenProvider = null;
454
-			}
455
-			$logger = $c->get(LoggerInterface::class);
456
-			$crypto = $c->get(ICrypto::class);
457
-			return new Store($session, $logger, $crypto, $tokenProvider);
458
-		});
459
-		$this->registerAlias(IStore::class, Store::class);
460
-		$this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
461
-		$this->registerAlias(OCPIProvider::class, Authentication\Token\Manager::class);
462
-
463
-		$this->registerService(\OC\User\Session::class, function (Server $c) {
464
-			$manager = $c->get(IUserManager::class);
465
-			$session = new \OC\Session\Memory();
466
-			$timeFactory = new TimeFactory();
467
-			// Token providers might require a working database. This code
468
-			// might however be called when Nextcloud is not yet setup.
469
-			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
470
-				$provider = $c->get(IProvider::class);
471
-			} else {
472
-				$provider = null;
473
-			}
474
-
475
-			$userSession = new \OC\User\Session(
476
-				$manager,
477
-				$session,
478
-				$timeFactory,
479
-				$provider,
480
-				$c->get(\OCP\IConfig::class),
481
-				$c->get(ISecureRandom::class),
482
-				$c->get('LockdownManager'),
483
-				$c->get(LoggerInterface::class),
484
-				$c->get(IEventDispatcher::class),
485
-			);
486
-			/** @deprecated 21.0.0 use BeforeUserCreatedEvent event with the IEventDispatcher instead */
487
-			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
488
-				\OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]);
489
-			});
490
-			/** @deprecated 21.0.0 use UserCreatedEvent event with the IEventDispatcher instead */
491
-			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
492
-				/** @var \OC\User\User $user */
493
-				\OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]);
494
-			});
495
-			/** @deprecated 21.0.0 use BeforeUserDeletedEvent event with the IEventDispatcher instead */
496
-			$userSession->listen('\OC\User', 'preDelete', function ($user) {
497
-				/** @var \OC\User\User $user */
498
-				\OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]);
499
-			});
500
-			/** @deprecated 21.0.0 use UserDeletedEvent event with the IEventDispatcher instead */
501
-			$userSession->listen('\OC\User', 'postDelete', function ($user) {
502
-				/** @var \OC\User\User $user */
503
-				\OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]);
504
-			});
505
-			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
506
-				/** @var \OC\User\User $user */
507
-				\OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
508
-			});
509
-			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
510
-				/** @var \OC\User\User $user */
511
-				\OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
512
-			});
513
-			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
514
-				\OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]);
515
-
516
-				/** @var IEventDispatcher $dispatcher */
517
-				$dispatcher = $this->get(IEventDispatcher::class);
518
-				$dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password));
519
-			});
520
-			$userSession->listen('\OC\User', 'postLogin', function ($user, $loginName, $password, $isTokenLogin) {
521
-				/** @var \OC\User\User $user */
522
-				\OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'loginName' => $loginName, 'password' => $password, 'isTokenLogin' => $isTokenLogin]);
523
-
524
-				/** @var IEventDispatcher $dispatcher */
525
-				$dispatcher = $this->get(IEventDispatcher::class);
526
-				$dispatcher->dispatchTyped(new UserLoggedInEvent($user, $loginName, $password, $isTokenLogin));
527
-			});
528
-			$userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) {
529
-				/** @var IEventDispatcher $dispatcher */
530
-				$dispatcher = $this->get(IEventDispatcher::class);
531
-				$dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid));
532
-			});
533
-			$userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
534
-				/** @var \OC\User\User $user */
535
-				\OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]);
536
-
537
-				/** @var IEventDispatcher $dispatcher */
538
-				$dispatcher = $this->get(IEventDispatcher::class);
539
-				$dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password));
540
-			});
541
-			$userSession->listen('\OC\User', 'logout', function ($user) {
542
-				\OC_Hook::emit('OC_User', 'logout', []);
543
-
544
-				/** @var IEventDispatcher $dispatcher */
545
-				$dispatcher = $this->get(IEventDispatcher::class);
546
-				$dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user));
547
-			});
548
-			$userSession->listen('\OC\User', 'postLogout', function ($user) {
549
-				/** @var IEventDispatcher $dispatcher */
550
-				$dispatcher = $this->get(IEventDispatcher::class);
551
-				$dispatcher->dispatchTyped(new UserLoggedOutEvent($user));
552
-			});
553
-			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
554
-				/** @var \OC\User\User $user */
555
-				\OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]);
556
-			});
557
-			return $userSession;
558
-		});
559
-		$this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class);
560
-
561
-		$this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class);
562
-
563
-		$this->registerAlias(INavigationManager::class, \OC\NavigationManager::class);
564
-
565
-		$this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
566
-
567
-		$this->registerService(\OC\SystemConfig::class, function ($c) use ($config) {
568
-			return new \OC\SystemConfig($config);
569
-		});
570
-
571
-		$this->registerAlias(IAppConfig::class, \OC\AppConfig::class);
572
-		$this->registerAlias(IUserConfig::class, \OC\Config\UserConfig::class);
573
-		$this->registerAlias(IAppManager::class, AppManager::class);
574
-
575
-		$this->registerService(IFactory::class, function (Server $c) {
576
-			return new \OC\L10N\Factory(
577
-				$c->get(\OCP\IConfig::class),
578
-				$c->getRequest(),
579
-				$c->get(IUserSession::class),
580
-				$c->get(ICacheFactory::class),
581
-				\OC::$SERVERROOT,
582
-				$c->get(IAppManager::class),
583
-			);
584
-		});
585
-
586
-		$this->registerAlias(IURLGenerator::class, URLGenerator::class);
587
-
588
-		$this->registerService(ICache::class, function ($c) {
589
-			return new Cache\File();
590
-		});
591
-
592
-		$this->registerService(Factory::class, function (Server $c) {
593
-			$profiler = $c->get(IProfiler::class);
594
-			$arrayCacheFactory = new \OC\Memcache\Factory(fn () => '', $c->get(LoggerInterface::class),
595
-				$profiler,
596
-				ArrayCache::class,
597
-				ArrayCache::class,
598
-				ArrayCache::class
599
-			);
600
-			/** @var SystemConfig $config */
601
-			$config = $c->get(SystemConfig::class);
602
-			/** @var ServerVersion $serverVersion */
603
-			$serverVersion = $c->get(ServerVersion::class);
604
-
605
-			if ($config->getValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
606
-				$logQuery = $config->getValue('log_query');
607
-				$prefixClosure = function () use ($logQuery, $serverVersion): ?string {
608
-					if (!$logQuery) {
609
-						try {
610
-							$v = \OCP\Server::get(IAppConfig::class)->getAppInstalledVersions(true);
611
-						} catch (\Doctrine\DBAL\Exception $e) {
612
-							// Database service probably unavailable
613
-							// Probably related to https://github.com/nextcloud/server/issues/37424
614
-							return null;
615
-						}
616
-					} else {
617
-						// If the log_query is enabled, we can not get the app versions
618
-						// as that does a query, which will be logged and the logging
619
-						// depends on redis and here we are back again in the same function.
620
-						$v = [
621
-							'log_query' => 'enabled',
622
-						];
623
-					}
624
-					$v['core'] = implode(',', $serverVersion->getVersion());
625
-					$version = implode(',', array_keys($v)) . implode(',', $v);
626
-					$instanceId = \OC_Util::getInstanceId();
627
-					$path = \OC::$SERVERROOT;
628
-					return md5($instanceId . '-' . $version . '-' . $path);
629
-				};
630
-				return new \OC\Memcache\Factory($prefixClosure,
631
-					$c->get(LoggerInterface::class),
632
-					$profiler,
633
-					/** @psalm-taint-escape callable */
634
-					$config->getValue('memcache.local', null),
635
-					/** @psalm-taint-escape callable */
636
-					$config->getValue('memcache.distributed', null),
637
-					/** @psalm-taint-escape callable */
638
-					$config->getValue('memcache.locking', null),
639
-					/** @psalm-taint-escape callable */
640
-					$config->getValue('redis_log_file')
641
-				);
642
-			}
643
-			return $arrayCacheFactory;
644
-		});
645
-		$this->registerAlias(ICacheFactory::class, Factory::class);
646
-
647
-		$this->registerService('RedisFactory', function (Server $c) {
648
-			$systemConfig = $c->get(SystemConfig::class);
649
-			return new RedisFactory($systemConfig, $c->get(IEventLogger::class));
650
-		});
651
-
652
-		$this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
653
-			$l10n = $this->get(IFactory::class)->get('lib');
654
-			return new \OC\Activity\Manager(
655
-				$c->getRequest(),
656
-				$c->get(IUserSession::class),
657
-				$c->get(\OCP\IConfig::class),
658
-				$c->get(IValidator::class),
659
-				$c->get(IRichTextFormatter::class),
660
-				$l10n,
661
-				$c->get(ITimeFactory::class),
662
-			);
663
-		});
664
-
665
-		$this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
666
-			return new \OC\Activity\EventMerger(
667
-				$c->getL10N('lib')
668
-			);
669
-		});
670
-		$this->registerAlias(IValidator::class, Validator::class);
671
-
672
-		$this->registerService(AvatarManager::class, function (Server $c) {
673
-			return new AvatarManager(
674
-				$c->get(IUserSession::class),
675
-				$c->get(\OC\User\Manager::class),
676
-				$c->getAppDataDir('avatar'),
677
-				$c->getL10N('lib'),
678
-				$c->get(LoggerInterface::class),
679
-				$c->get(\OCP\IConfig::class),
680
-				$c->get(IAccountManager::class),
681
-				$c->get(KnownUserService::class)
682
-			);
683
-		});
684
-
685
-		$this->registerAlias(IAvatarManager::class, AvatarManager::class);
686
-
687
-		$this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
688
-		$this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class);
689
-		$this->registerAlias(\OCP\Support\Subscription\IAssertion::class, \OC\Support\Subscription\Assertion::class);
690
-
691
-		/** Only used by the PsrLoggerAdapter should not be used by apps */
692
-		$this->registerService(\OC\Log::class, function (Server $c) {
693
-			$logType = $c->get(AllConfig::class)->getSystemValue('log_type', 'file');
694
-			$factory = new LogFactory($c, $this->get(SystemConfig::class));
695
-			$logger = $factory->get($logType);
696
-			$registry = $c->get(\OCP\Support\CrashReport\IRegistry::class);
697
-
698
-			return new Log($logger, $this->get(SystemConfig::class), crashReporters: $registry);
699
-		});
700
-		// PSR-3 logger
701
-		$this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class);
702
-
703
-		$this->registerService(ILogFactory::class, function (Server $c) {
704
-			return new LogFactory($c, $this->get(SystemConfig::class));
705
-		});
706
-
707
-		$this->registerAlias(IJobList::class, \OC\BackgroundJob\JobList::class);
708
-
709
-		$this->registerService(Router::class, function (Server $c) {
710
-			$cacheFactory = $c->get(ICacheFactory::class);
711
-			if ($cacheFactory->isLocalCacheAvailable()) {
712
-				$router = $c->resolve(CachingRouter::class);
713
-			} else {
714
-				$router = $c->resolve(Router::class);
715
-			}
716
-			return $router;
717
-		});
718
-		$this->registerAlias(IRouter::class, Router::class);
719
-
720
-		$this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
721
-			$config = $c->get(\OCP\IConfig::class);
722
-			if (ltrim($config->getSystemValueString('memcache.distributed', ''), '\\') === \OC\Memcache\Redis::class) {
723
-				$backend = new \OC\Security\RateLimiting\Backend\MemoryCacheBackend(
724
-					$c->get(AllConfig::class),
725
-					$this->get(ICacheFactory::class),
726
-					new \OC\AppFramework\Utility\TimeFactory()
727
-				);
728
-			} else {
729
-				$backend = new \OC\Security\RateLimiting\Backend\DatabaseBackend(
730
-					$c->get(AllConfig::class),
731
-					$c->get(IDBConnection::class),
732
-					new \OC\AppFramework\Utility\TimeFactory()
733
-				);
734
-			}
735
-
736
-			return $backend;
737
-		});
738
-
739
-		$this->registerAlias(\OCP\Security\ISecureRandom::class, SecureRandom::class);
740
-		$this->registerAlias(\OCP\Security\IRemoteHostValidator::class, \OC\Security\RemoteHostValidator::class);
741
-		$this->registerAlias(IVerificationToken::class, VerificationToken::class);
742
-
743
-		$this->registerAlias(ICrypto::class, Crypto::class);
744
-
745
-		$this->registerAlias(IHasher::class, Hasher::class);
746
-
747
-		$this->registerAlias(ICredentialsManager::class, CredentialsManager::class);
748
-
749
-		$this->registerAlias(IDBConnection::class, ConnectionAdapter::class);
750
-		$this->registerService(Connection::class, function (Server $c) {
751
-			$systemConfig = $c->get(SystemConfig::class);
752
-			$factory = new \OC\DB\ConnectionFactory($systemConfig, $c->get(ICacheFactory::class));
753
-			$type = $systemConfig->getValue('dbtype', 'sqlite');
754
-			if (!$factory->isValidType($type)) {
755
-				throw new \OC\DatabaseException('Invalid database type');
756
-			}
757
-			$connection = $factory->getConnection($type, []);
758
-			return $connection;
759
-		});
760
-
761
-		$this->registerAlias(ICertificateManager::class, CertificateManager::class);
762
-		$this->registerAlias(IClientService::class, ClientService::class);
763
-		$this->registerService(NegativeDnsCache::class, function (ContainerInterface $c) {
764
-			return new NegativeDnsCache(
765
-				$c->get(ICacheFactory::class),
766
-			);
767
-		});
768
-		$this->registerDeprecatedAlias('HttpClientService', IClientService::class);
769
-		$this->registerService(IEventLogger::class, function (ContainerInterface $c) {
770
-			return new EventLogger($c->get(SystemConfig::class), $c->get(LoggerInterface::class), $c->get(Log::class));
771
-		});
772
-
773
-		$this->registerService(IQueryLogger::class, function (ContainerInterface $c) {
774
-			$queryLogger = new QueryLogger();
775
-			if ($c->get(SystemConfig::class)->getValue('debug', false)) {
776
-				// In debug mode, module is being activated by default
777
-				$queryLogger->activate();
778
-			}
779
-			return $queryLogger;
780
-		});
781
-
782
-		$this->registerAlias(ITempManager::class, TempManager::class);
783
-		$this->registerAlias(IDateTimeZone::class, DateTimeZone::class);
784
-
785
-		$this->registerService(IDateTimeFormatter::class, function (Server $c) {
786
-			$language = $c->get(\OCP\IConfig::class)->getUserValue($c->get(ISession::class)->get('user_id'), 'core', 'lang', null);
787
-
788
-			return new DateTimeFormatter(
789
-				$c->get(IDateTimeZone::class)->getTimeZone(),
790
-				$c->getL10N('lib', $language)
791
-			);
792
-		});
793
-
794
-		$this->registerService(IUserMountCache::class, function (ContainerInterface $c) {
795
-			$mountCache = $c->get(UserMountCache::class);
796
-			$listener = new UserMountCacheListener($mountCache);
797
-			$listener->listen($c->get(IUserManager::class));
798
-			return $mountCache;
799
-		});
800
-
801
-		$this->registerService(IMountProviderCollection::class, function (ContainerInterface $c) {
802
-			$loader = $c->get(IStorageFactory::class);
803
-			$mountCache = $c->get(IUserMountCache::class);
804
-			$eventLogger = $c->get(IEventLogger::class);
805
-			$manager = new MountProviderCollection($loader, $mountCache, $eventLogger);
806
-
807
-			// builtin providers
808
-
809
-			$config = $c->get(\OCP\IConfig::class);
810
-			$logger = $c->get(LoggerInterface::class);
811
-			$objectStoreConfig = $c->get(PrimaryObjectStoreConfig::class);
812
-			$manager->registerProvider(new CacheMountProvider($config));
813
-			$manager->registerHomeProvider(new LocalHomeMountProvider());
814
-			$manager->registerHomeProvider(new ObjectHomeMountProvider($objectStoreConfig));
815
-			$manager->registerRootProvider(new RootMountProvider($objectStoreConfig, $config));
816
-			$manager->registerRootProvider(new ObjectStorePreviewCacheMountProvider($logger, $config));
817
-
818
-			return $manager;
819
-		});
820
-
821
-		$this->registerService(IBus::class, function (ContainerInterface $c) {
822
-			$busClass = $c->get(\OCP\IConfig::class)->getSystemValueString('commandbus');
823
-			if ($busClass) {
824
-				[$app, $class] = explode('::', $busClass, 2);
825
-				if ($c->get(IAppManager::class)->isEnabledForUser($app)) {
826
-					$c->get(IAppManager::class)->loadApp($app);
827
-					return $c->get($class);
828
-				} else {
829
-					throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
830
-				}
831
-			} else {
832
-				$jobList = $c->get(IJobList::class);
833
-				return new CronBus($jobList);
834
-			}
835
-		});
836
-		$this->registerDeprecatedAlias('AsyncCommandBus', IBus::class);
837
-		$this->registerAlias(ITrustedDomainHelper::class, TrustedDomainHelper::class);
838
-		$this->registerAlias(IThrottler::class, Throttler::class);
839
-
840
-		$this->registerService(\OC\Security\Bruteforce\Backend\IBackend::class, function ($c) {
841
-			$config = $c->get(\OCP\IConfig::class);
842
-			if (!$config->getSystemValueBool('auth.bruteforce.protection.force.database', false)
843
-				&& ltrim($config->getSystemValueString('memcache.distributed', ''), '\\') === \OC\Memcache\Redis::class) {
844
-				$backend = $c->get(\OC\Security\Bruteforce\Backend\MemoryCacheBackend::class);
845
-			} else {
846
-				$backend = $c->get(\OC\Security\Bruteforce\Backend\DatabaseBackend::class);
847
-			}
848
-
849
-			return $backend;
850
-		});
851
-
852
-		$this->registerDeprecatedAlias('IntegrityCodeChecker', Checker::class);
853
-		$this->registerService(Checker::class, function (ContainerInterface $c) {
854
-			// IConfig requires a working database. This code
855
-			// might however be called when Nextcloud is not yet setup.
856
-			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
857
-				$config = $c->get(\OCP\IConfig::class);
858
-				$appConfig = $c->get(\OCP\IAppConfig::class);
859
-			} else {
860
-				$config = null;
861
-				$appConfig = null;
862
-			}
863
-
864
-			return new Checker(
865
-				$c->get(ServerVersion::class),
866
-				$c->get(EnvironmentHelper::class),
867
-				new FileAccessHelper(),
868
-				new AppLocator(),
869
-				$config,
870
-				$appConfig,
871
-				$c->get(ICacheFactory::class),
872
-				$c->get(IAppManager::class),
873
-				$c->get(IMimeTypeDetector::class)
874
-			);
875
-		});
876
-		$this->registerService(Request::class, function (ContainerInterface $c) {
877
-			if (isset($this['urlParams'])) {
878
-				$urlParams = $this['urlParams'];
879
-			} else {
880
-				$urlParams = [];
881
-			}
882
-
883
-			if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
884
-				&& in_array('fakeinput', stream_get_wrappers())
885
-			) {
886
-				$stream = 'fakeinput://data';
887
-			} else {
888
-				$stream = 'php://input';
889
-			}
890
-
891
-			return new Request(
892
-				[
893
-					'get' => $_GET,
894
-					'post' => $_POST,
895
-					'files' => $_FILES,
896
-					'server' => $_SERVER,
897
-					'env' => $_ENV,
898
-					'cookies' => $_COOKIE,
899
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
900
-						? $_SERVER['REQUEST_METHOD']
901
-						: '',
902
-					'urlParams' => $urlParams,
903
-				],
904
-				$this->get(IRequestId::class),
905
-				$this->get(\OCP\IConfig::class),
906
-				$this->get(CsrfTokenManager::class),
907
-				$stream
908
-			);
909
-		});
910
-		$this->registerAlias(\OCP\IRequest::class, Request::class);
911
-
912
-		$this->registerService(IRequestId::class, function (ContainerInterface $c): IRequestId {
913
-			return new RequestId(
914
-				$_SERVER['UNIQUE_ID'] ?? '',
915
-				$this->get(ISecureRandom::class)
916
-			);
917
-		});
918
-
919
-		$this->registerService(IMailer::class, function (Server $c) {
920
-			return new Mailer(
921
-				$c->get(\OCP\IConfig::class),
922
-				$c->get(LoggerInterface::class),
923
-				$c->get(Defaults::class),
924
-				$c->get(IURLGenerator::class),
925
-				$c->getL10N('lib'),
926
-				$c->get(IEventDispatcher::class),
927
-				$c->get(IFactory::class)
928
-			);
929
-		});
930
-
931
-		/** @since 30.0.0 */
932
-		$this->registerAlias(\OCP\Mail\Provider\IManager::class, \OC\Mail\Provider\Manager::class);
933
-
934
-		$this->registerService(ILDAPProviderFactory::class, function (ContainerInterface $c) {
935
-			$config = $c->get(\OCP\IConfig::class);
936
-			$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
937
-			if (is_null($factoryClass) || !class_exists($factoryClass)) {
938
-				return new NullLDAPProviderFactory($this);
939
-			}
940
-			/** @var \OCP\LDAP\ILDAPProviderFactory $factory */
941
-			return new $factoryClass($this);
942
-		});
943
-		$this->registerService(ILDAPProvider::class, function (ContainerInterface $c) {
944
-			$factory = $c->get(ILDAPProviderFactory::class);
945
-			return $factory->getLDAPProvider();
946
-		});
947
-		$this->registerService(ILockingProvider::class, function (ContainerInterface $c) {
948
-			$ini = $c->get(IniGetWrapper::class);
949
-			$config = $c->get(\OCP\IConfig::class);
950
-			$ttl = $config->getSystemValueInt('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
951
-			if ($config->getSystemValueBool('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
952
-				/** @var \OC\Memcache\Factory $memcacheFactory */
953
-				$memcacheFactory = $c->get(ICacheFactory::class);
954
-				$memcache = $memcacheFactory->createLocking('lock');
955
-				if (!($memcache instanceof \OC\Memcache\NullCache)) {
956
-					$timeFactory = $c->get(ITimeFactory::class);
957
-					return new MemcacheLockingProvider($memcache, $timeFactory, $ttl);
958
-				}
959
-				return new DBLockingProvider(
960
-					$c->get(IDBConnection::class),
961
-					new TimeFactory(),
962
-					$ttl,
963
-					!\OC::$CLI
964
-				);
965
-			}
966
-			return new NoopLockingProvider();
967
-		});
968
-
969
-		$this->registerService(ILockManager::class, function (Server $c): LockManager {
970
-			return new LockManager();
971
-		});
972
-
973
-		$this->registerAlias(ILockdownManager::class, 'LockdownManager');
974
-		$this->registerService(SetupManager::class, function ($c) {
975
-			// create the setupmanager through the mount manager to resolve the cyclic dependency
976
-			return $c->get(\OC\Files\Mount\Manager::class)->getSetupManager();
977
-		});
978
-		$this->registerAlias(IMountManager::class, \OC\Files\Mount\Manager::class);
979
-
980
-		$this->registerService(IMimeTypeDetector::class, function (ContainerInterface $c) {
981
-			return new \OC\Files\Type\Detection(
982
-				$c->get(IURLGenerator::class),
983
-				$c->get(LoggerInterface::class),
984
-				\OC::$configDir,
985
-				\OC::$SERVERROOT . '/resources/config/'
986
-			);
987
-		});
988
-
989
-		$this->registerAlias(IMimeTypeLoader::class, Loader::class);
990
-		$this->registerService(BundleFetcher::class, function () {
991
-			return new BundleFetcher($this->getL10N('lib'));
992
-		});
993
-		$this->registerAlias(\OCP\Notification\IManager::class, Manager::class);
994
-
995
-		$this->registerService(CapabilitiesManager::class, function (ContainerInterface $c) {
996
-			$manager = new CapabilitiesManager($c->get(LoggerInterface::class));
997
-			$manager->registerCapability(function () use ($c) {
998
-				return new \OC\OCS\CoreCapabilities($c->get(\OCP\IConfig::class));
999
-			});
1000
-			$manager->registerCapability(function () use ($c) {
1001
-				return $c->get(\OC\Security\Bruteforce\Capabilities::class);
1002
-			});
1003
-			return $manager;
1004
-		});
1005
-
1006
-		$this->registerService(ICommentsManager::class, function (Server $c) {
1007
-			$config = $c->get(\OCP\IConfig::class);
1008
-			$factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class);
1009
-			/** @var \OCP\Comments\ICommentsManagerFactory $factory */
1010
-			$factory = new $factoryClass($this);
1011
-			$manager = $factory->getManager();
1012
-
1013
-			$manager->registerDisplayNameResolver('user', function ($id) use ($c) {
1014
-				$manager = $c->get(IUserManager::class);
1015
-				$userDisplayName = $manager->getDisplayName($id);
1016
-				if ($userDisplayName === null) {
1017
-					$l = $c->get(IFactory::class)->get('core');
1018
-					return $l->t('Unknown account');
1019
-				}
1020
-				return $userDisplayName;
1021
-			});
1022
-
1023
-			return $manager;
1024
-		});
1025
-
1026
-		$this->registerAlias(\OC_Defaults::class, 'ThemingDefaults');
1027
-		$this->registerService('ThemingDefaults', function (Server $c) {
1028
-			try {
1029
-				$classExists = class_exists('OCA\Theming\ThemingDefaults');
1030
-			} catch (\OCP\AutoloadNotAllowedException $e) {
1031
-				// App disabled or in maintenance mode
1032
-				$classExists = false;
1033
-			}
1034
-
1035
-			if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValueBool('installed', false) && $c->get(IAppManager::class)->isEnabledForAnyone('theming') && $c->get(TrustedDomainHelper::class)->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
1036
-				$backgroundService = new BackgroundService(
1037
-					$c->get(IRootFolder::class),
1038
-					$c->getAppDataDir('theming'),
1039
-					$c->get(IAppConfig::class),
1040
-					$c->get(\OCP\IConfig::class),
1041
-					$c->get(ISession::class)->get('user_id'),
1042
-				);
1043
-				$imageManager = new ImageManager(
1044
-					$c->get(\OCP\IConfig::class),
1045
-					$c->getAppDataDir('theming'),
1046
-					$c->get(IURLGenerator::class),
1047
-					$c->get(ICacheFactory::class),
1048
-					$c->get(LoggerInterface::class),
1049
-					$c->get(ITempManager::class),
1050
-					$backgroundService,
1051
-				);
1052
-				return new ThemingDefaults(
1053
-					$c->get(\OCP\IConfig::class),
1054
-					$c->get(\OCP\IAppConfig::class),
1055
-					$c->getL10N('theming'),
1056
-					$c->get(IUserSession::class),
1057
-					$c->get(IURLGenerator::class),
1058
-					$c->get(ICacheFactory::class),
1059
-					new Util($c->get(ServerVersion::class), $c->get(\OCP\IConfig::class), $this->get(IAppManager::class), $c->getAppDataDir('theming'), $imageManager),
1060
-					$imageManager,
1061
-					$c->get(IAppManager::class),
1062
-					$c->get(INavigationManager::class),
1063
-					$backgroundService,
1064
-				);
1065
-			}
1066
-			return new \OC_Defaults();
1067
-		});
1068
-		$this->registerService(JSCombiner::class, function (Server $c) {
1069
-			return new JSCombiner(
1070
-				$c->getAppDataDir('js'),
1071
-				$c->get(IURLGenerator::class),
1072
-				$this->get(ICacheFactory::class),
1073
-				$c->get(SystemConfig::class),
1074
-				$c->get(LoggerInterface::class)
1075
-			);
1076
-		});
1077
-		$this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class);
1078
-
1079
-		$this->registerService('CryptoWrapper', function (ContainerInterface $c) {
1080
-			// FIXME: Instantiated here due to cyclic dependency
1081
-			$request = new Request(
1082
-				[
1083
-					'get' => $_GET,
1084
-					'post' => $_POST,
1085
-					'files' => $_FILES,
1086
-					'server' => $_SERVER,
1087
-					'env' => $_ENV,
1088
-					'cookies' => $_COOKIE,
1089
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1090
-						? $_SERVER['REQUEST_METHOD']
1091
-						: null,
1092
-				],
1093
-				$c->get(IRequestId::class),
1094
-				$c->get(\OCP\IConfig::class)
1095
-			);
1096
-
1097
-			return new CryptoWrapper(
1098
-				$c->get(ICrypto::class),
1099
-				$c->get(ISecureRandom::class),
1100
-				$request
1101
-			);
1102
-		});
1103
-		$this->registerService(SessionStorage::class, function (ContainerInterface $c) {
1104
-			return new SessionStorage($c->get(ISession::class));
1105
-		});
1106
-		$this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class);
1107
-
1108
-		$this->registerService(IProviderFactory::class, function (ContainerInterface $c) {
1109
-			$config = $c->get(\OCP\IConfig::class);
1110
-			$factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class);
1111
-			/** @var \OCP\Share\IProviderFactory $factory */
1112
-			return $c->get($factoryClass);
1113
-		});
1114
-
1115
-		$this->registerAlias(\OCP\Share\IManager::class, \OC\Share20\Manager::class);
1116
-
1117
-		$this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) {
1118
-			$instance = new Collaboration\Collaborators\Search($c);
1119
-
1120
-			// register default plugins
1121
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]);
1122
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
1123
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
1124
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
1125
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]);
1126
-
1127
-			return $instance;
1128
-		});
1129
-		$this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class);
1130
-
1131
-		$this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
1132
-
1133
-		$this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class);
1134
-		$this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class);
1135
-
1136
-		$this->registerAlias(IReferenceManager::class, ReferenceManager::class);
1137
-		$this->registerAlias(ITeamManager::class, TeamManager::class);
1138
-
1139
-		$this->registerDeprecatedAlias('SettingsManager', \OC\Settings\Manager::class);
1140
-		$this->registerAlias(\OCP\Settings\IManager::class, \OC\Settings\Manager::class);
1141
-		$this->registerService(\OC\Files\AppData\Factory::class, function (ContainerInterface $c) {
1142
-			return new \OC\Files\AppData\Factory(
1143
-				$c->get(IRootFolder::class),
1144
-				$c->get(SystemConfig::class)
1145
-			);
1146
-		});
1147
-
1148
-		$this->registerService('LockdownManager', function (ContainerInterface $c) {
1149
-			return new LockdownManager(function () use ($c) {
1150
-				return $c->get(ISession::class);
1151
-			});
1152
-		});
1153
-
1154
-		$this->registerService(\OCP\OCS\IDiscoveryService::class, function (ContainerInterface $c) {
1155
-			return new DiscoveryService(
1156
-				$c->get(ICacheFactory::class),
1157
-				$c->get(IClientService::class)
1158
-			);
1159
-		});
1160
-		$this->registerAlias(IOCMDiscoveryService::class, OCMDiscoveryService::class);
1161
-
1162
-		$this->registerService(ICloudIdManager::class, function (ContainerInterface $c) {
1163
-			return new CloudIdManager(
1164
-				$c->get(ICacheFactory::class),
1165
-				$c->get(IEventDispatcher::class),
1166
-				$c->get(\OCP\Contacts\IManager::class),
1167
-				$c->get(IURLGenerator::class),
1168
-				$c->get(IUserManager::class),
1169
-			);
1170
-		});
1171
-
1172
-		$this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class);
1173
-		$this->registerAlias(ICloudFederationProviderManager::class, CloudFederationProviderManager::class);
1174
-		$this->registerService(ICloudFederationFactory::class, function (Server $c) {
1175
-			return new CloudFederationFactory();
1176
-		});
251
+    /** @var string */
252
+    private $webRoot;
253
+
254
+    /**
255
+     * @param string $webRoot
256
+     * @param \OC\Config $config
257
+     */
258
+    public function __construct($webRoot, \OC\Config $config) {
259
+        parent::__construct();
260
+        $this->webRoot = $webRoot;
261
+
262
+        // To find out if we are running from CLI or not
263
+        $this->registerParameter('isCLI', \OC::$CLI);
264
+        $this->registerParameter('serverRoot', \OC::$SERVERROOT);
265
+
266
+        $this->registerService(ContainerInterface::class, function (ContainerInterface $c) {
267
+            return $c;
268
+        });
269
+        $this->registerDeprecatedAlias(\OCP\IServerContainer::class, ContainerInterface::class);
270
+
271
+        $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
272
+
273
+        $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class);
274
+
275
+        $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class);
276
+
277
+        $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
278
+
279
+        $this->registerAlias(\OCP\ContextChat\IContentManager::class, \OC\ContextChat\ContentManager::class);
280
+
281
+        $this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class);
282
+        $this->registerAlias(ITemplateManager::class, TemplateManager::class);
283
+        $this->registerAlias(\OCP\Template\ITemplateManager::class, \OC\Template\TemplateManager::class);
284
+
285
+        $this->registerAlias(IActionFactory::class, ActionFactory::class);
286
+
287
+        $this->registerService(View::class, function (Server $c) {
288
+            return new View();
289
+        }, false);
290
+
291
+        $this->registerService(IPreview::class, function (ContainerInterface $c) {
292
+            return new PreviewManager(
293
+                $c->get(\OCP\IConfig::class),
294
+                $c->get(IRootFolder::class),
295
+                new \OC\Preview\Storage\Root(
296
+                    $c->get(IRootFolder::class),
297
+                    $c->get(SystemConfig::class)
298
+                ),
299
+                $c->get(IEventDispatcher::class),
300
+                $c->get(GeneratorHelper::class),
301
+                $c->get(ISession::class)->get('user_id'),
302
+                $c->get(Coordinator::class),
303
+                $c->get(IServerContainer::class),
304
+                $c->get(IBinaryFinder::class),
305
+                $c->get(IMagickSupport::class)
306
+            );
307
+        });
308
+        $this->registerAlias(IMimeIconProvider::class, MimeIconProvider::class);
309
+
310
+        $this->registerService(\OC\Preview\Watcher::class, function (ContainerInterface $c) {
311
+            return new \OC\Preview\Watcher(
312
+                new \OC\Preview\Storage\Root(
313
+                    $c->get(IRootFolder::class),
314
+                    $c->get(SystemConfig::class)
315
+                )
316
+            );
317
+        });
318
+
319
+        $this->registerService(IProfiler::class, function (Server $c) {
320
+            return new Profiler($c->get(SystemConfig::class));
321
+        });
322
+
323
+        $this->registerService(Encryption\Manager::class, function (Server $c): Encryption\Manager {
324
+            $view = new View();
325
+            $util = new Encryption\Util(
326
+                $view,
327
+                $c->get(IUserManager::class),
328
+                $c->get(IGroupManager::class),
329
+                $c->get(\OCP\IConfig::class)
330
+            );
331
+            return new Encryption\Manager(
332
+                $c->get(\OCP\IConfig::class),
333
+                $c->get(LoggerInterface::class),
334
+                $c->getL10N('core'),
335
+                new View(),
336
+                $util,
337
+                new ArrayCache()
338
+            );
339
+        });
340
+        $this->registerAlias(\OCP\Encryption\IManager::class, Encryption\Manager::class);
341
+
342
+        $this->registerService(IFile::class, function (ContainerInterface $c) {
343
+            $util = new Encryption\Util(
344
+                new View(),
345
+                $c->get(IUserManager::class),
346
+                $c->get(IGroupManager::class),
347
+                $c->get(\OCP\IConfig::class)
348
+            );
349
+            return new Encryption\File(
350
+                $util,
351
+                $c->get(IRootFolder::class),
352
+                $c->get(\OCP\Share\IManager::class)
353
+            );
354
+        });
355
+
356
+        $this->registerService(IStorage::class, function (ContainerInterface $c) {
357
+            $view = new View();
358
+            $util = new Encryption\Util(
359
+                $view,
360
+                $c->get(IUserManager::class),
361
+                $c->get(IGroupManager::class),
362
+                $c->get(\OCP\IConfig::class)
363
+            );
364
+
365
+            return new Encryption\Keys\Storage(
366
+                $view,
367
+                $util,
368
+                $c->get(ICrypto::class),
369
+                $c->get(\OCP\IConfig::class)
370
+            );
371
+        });
372
+
373
+        $this->registerAlias(\OCP\ITagManager::class, TagManager::class);
374
+
375
+        $this->registerService('SystemTagManagerFactory', function (ContainerInterface $c) {
376
+            /** @var \OCP\IConfig $config */
377
+            $config = $c->get(\OCP\IConfig::class);
378
+            $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class);
379
+            return new $factoryClass($this);
380
+        });
381
+        $this->registerService(ISystemTagManager::class, function (ContainerInterface $c) {
382
+            return $c->get('SystemTagManagerFactory')->getManager();
383
+        });
384
+        /** @deprecated 19.0.0 */
385
+        $this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class);
386
+
387
+        $this->registerService(ISystemTagObjectMapper::class, function (ContainerInterface $c) {
388
+            return $c->get('SystemTagManagerFactory')->getObjectMapper();
389
+        });
390
+        $this->registerAlias(IFileAccess::class, FileAccess::class);
391
+        $this->registerService('RootFolder', function (ContainerInterface $c) {
392
+            $manager = \OC\Files\Filesystem::getMountManager();
393
+            $view = new View();
394
+            /** @var IUserSession $userSession */
395
+            $userSession = $c->get(IUserSession::class);
396
+            $root = new Root(
397
+                $manager,
398
+                $view,
399
+                $userSession->getUser(),
400
+                $c->get(IUserMountCache::class),
401
+                $this->get(LoggerInterface::class),
402
+                $this->get(IUserManager::class),
403
+                $this->get(IEventDispatcher::class),
404
+                $this->get(ICacheFactory::class),
405
+            );
406
+
407
+            $previewConnector = new \OC\Preview\WatcherConnector(
408
+                $root,
409
+                $c->get(SystemConfig::class),
410
+                $this->get(IEventDispatcher::class)
411
+            );
412
+            $previewConnector->connectWatcher();
413
+
414
+            return $root;
415
+        });
416
+        $this->registerService(HookConnector::class, function (ContainerInterface $c) {
417
+            return new HookConnector(
418
+                $c->get(IRootFolder::class),
419
+                new View(),
420
+                $c->get(IEventDispatcher::class),
421
+                $c->get(LoggerInterface::class)
422
+            );
423
+        });
424
+
425
+        $this->registerService(IRootFolder::class, function (ContainerInterface $c) {
426
+            return new LazyRoot(function () use ($c) {
427
+                return $c->get('RootFolder');
428
+            });
429
+        });
430
+
431
+        $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
432
+
433
+        $this->registerService(DisplayNameCache::class, function (ContainerInterface $c) {
434
+            return $c->get(\OC\User\Manager::class)->getDisplayNameCache();
435
+        });
436
+
437
+        $this->registerService(\OCP\IGroupManager::class, function (ContainerInterface $c) {
438
+            $groupManager = new \OC\Group\Manager(
439
+                $this->get(IUserManager::class),
440
+                $this->get(IEventDispatcher::class),
441
+                $this->get(LoggerInterface::class),
442
+                $this->get(ICacheFactory::class),
443
+                $this->get(IRemoteAddress::class),
444
+            );
445
+            return $groupManager;
446
+        });
447
+
448
+        $this->registerService(Store::class, function (ContainerInterface $c) {
449
+            $session = $c->get(ISession::class);
450
+            if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
451
+                $tokenProvider = $c->get(IProvider::class);
452
+            } else {
453
+                $tokenProvider = null;
454
+            }
455
+            $logger = $c->get(LoggerInterface::class);
456
+            $crypto = $c->get(ICrypto::class);
457
+            return new Store($session, $logger, $crypto, $tokenProvider);
458
+        });
459
+        $this->registerAlias(IStore::class, Store::class);
460
+        $this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
461
+        $this->registerAlias(OCPIProvider::class, Authentication\Token\Manager::class);
462
+
463
+        $this->registerService(\OC\User\Session::class, function (Server $c) {
464
+            $manager = $c->get(IUserManager::class);
465
+            $session = new \OC\Session\Memory();
466
+            $timeFactory = new TimeFactory();
467
+            // Token providers might require a working database. This code
468
+            // might however be called when Nextcloud is not yet setup.
469
+            if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
470
+                $provider = $c->get(IProvider::class);
471
+            } else {
472
+                $provider = null;
473
+            }
474
+
475
+            $userSession = new \OC\User\Session(
476
+                $manager,
477
+                $session,
478
+                $timeFactory,
479
+                $provider,
480
+                $c->get(\OCP\IConfig::class),
481
+                $c->get(ISecureRandom::class),
482
+                $c->get('LockdownManager'),
483
+                $c->get(LoggerInterface::class),
484
+                $c->get(IEventDispatcher::class),
485
+            );
486
+            /** @deprecated 21.0.0 use BeforeUserCreatedEvent event with the IEventDispatcher instead */
487
+            $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
488
+                \OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]);
489
+            });
490
+            /** @deprecated 21.0.0 use UserCreatedEvent event with the IEventDispatcher instead */
491
+            $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
492
+                /** @var \OC\User\User $user */
493
+                \OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]);
494
+            });
495
+            /** @deprecated 21.0.0 use BeforeUserDeletedEvent event with the IEventDispatcher instead */
496
+            $userSession->listen('\OC\User', 'preDelete', function ($user) {
497
+                /** @var \OC\User\User $user */
498
+                \OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]);
499
+            });
500
+            /** @deprecated 21.0.0 use UserDeletedEvent event with the IEventDispatcher instead */
501
+            $userSession->listen('\OC\User', 'postDelete', function ($user) {
502
+                /** @var \OC\User\User $user */
503
+                \OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]);
504
+            });
505
+            $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
506
+                /** @var \OC\User\User $user */
507
+                \OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
508
+            });
509
+            $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
510
+                /** @var \OC\User\User $user */
511
+                \OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
512
+            });
513
+            $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
514
+                \OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]);
515
+
516
+                /** @var IEventDispatcher $dispatcher */
517
+                $dispatcher = $this->get(IEventDispatcher::class);
518
+                $dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password));
519
+            });
520
+            $userSession->listen('\OC\User', 'postLogin', function ($user, $loginName, $password, $isTokenLogin) {
521
+                /** @var \OC\User\User $user */
522
+                \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'loginName' => $loginName, 'password' => $password, 'isTokenLogin' => $isTokenLogin]);
523
+
524
+                /** @var IEventDispatcher $dispatcher */
525
+                $dispatcher = $this->get(IEventDispatcher::class);
526
+                $dispatcher->dispatchTyped(new UserLoggedInEvent($user, $loginName, $password, $isTokenLogin));
527
+            });
528
+            $userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) {
529
+                /** @var IEventDispatcher $dispatcher */
530
+                $dispatcher = $this->get(IEventDispatcher::class);
531
+                $dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid));
532
+            });
533
+            $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
534
+                /** @var \OC\User\User $user */
535
+                \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]);
536
+
537
+                /** @var IEventDispatcher $dispatcher */
538
+                $dispatcher = $this->get(IEventDispatcher::class);
539
+                $dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password));
540
+            });
541
+            $userSession->listen('\OC\User', 'logout', function ($user) {
542
+                \OC_Hook::emit('OC_User', 'logout', []);
543
+
544
+                /** @var IEventDispatcher $dispatcher */
545
+                $dispatcher = $this->get(IEventDispatcher::class);
546
+                $dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user));
547
+            });
548
+            $userSession->listen('\OC\User', 'postLogout', function ($user) {
549
+                /** @var IEventDispatcher $dispatcher */
550
+                $dispatcher = $this->get(IEventDispatcher::class);
551
+                $dispatcher->dispatchTyped(new UserLoggedOutEvent($user));
552
+            });
553
+            $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
554
+                /** @var \OC\User\User $user */
555
+                \OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]);
556
+            });
557
+            return $userSession;
558
+        });
559
+        $this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class);
560
+
561
+        $this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class);
562
+
563
+        $this->registerAlias(INavigationManager::class, \OC\NavigationManager::class);
564
+
565
+        $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
566
+
567
+        $this->registerService(\OC\SystemConfig::class, function ($c) use ($config) {
568
+            return new \OC\SystemConfig($config);
569
+        });
570
+
571
+        $this->registerAlias(IAppConfig::class, \OC\AppConfig::class);
572
+        $this->registerAlias(IUserConfig::class, \OC\Config\UserConfig::class);
573
+        $this->registerAlias(IAppManager::class, AppManager::class);
574
+
575
+        $this->registerService(IFactory::class, function (Server $c) {
576
+            return new \OC\L10N\Factory(
577
+                $c->get(\OCP\IConfig::class),
578
+                $c->getRequest(),
579
+                $c->get(IUserSession::class),
580
+                $c->get(ICacheFactory::class),
581
+                \OC::$SERVERROOT,
582
+                $c->get(IAppManager::class),
583
+            );
584
+        });
585
+
586
+        $this->registerAlias(IURLGenerator::class, URLGenerator::class);
587
+
588
+        $this->registerService(ICache::class, function ($c) {
589
+            return new Cache\File();
590
+        });
591
+
592
+        $this->registerService(Factory::class, function (Server $c) {
593
+            $profiler = $c->get(IProfiler::class);
594
+            $arrayCacheFactory = new \OC\Memcache\Factory(fn () => '', $c->get(LoggerInterface::class),
595
+                $profiler,
596
+                ArrayCache::class,
597
+                ArrayCache::class,
598
+                ArrayCache::class
599
+            );
600
+            /** @var SystemConfig $config */
601
+            $config = $c->get(SystemConfig::class);
602
+            /** @var ServerVersion $serverVersion */
603
+            $serverVersion = $c->get(ServerVersion::class);
604
+
605
+            if ($config->getValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
606
+                $logQuery = $config->getValue('log_query');
607
+                $prefixClosure = function () use ($logQuery, $serverVersion): ?string {
608
+                    if (!$logQuery) {
609
+                        try {
610
+                            $v = \OCP\Server::get(IAppConfig::class)->getAppInstalledVersions(true);
611
+                        } catch (\Doctrine\DBAL\Exception $e) {
612
+                            // Database service probably unavailable
613
+                            // Probably related to https://github.com/nextcloud/server/issues/37424
614
+                            return null;
615
+                        }
616
+                    } else {
617
+                        // If the log_query is enabled, we can not get the app versions
618
+                        // as that does a query, which will be logged and the logging
619
+                        // depends on redis and here we are back again in the same function.
620
+                        $v = [
621
+                            'log_query' => 'enabled',
622
+                        ];
623
+                    }
624
+                    $v['core'] = implode(',', $serverVersion->getVersion());
625
+                    $version = implode(',', array_keys($v)) . implode(',', $v);
626
+                    $instanceId = \OC_Util::getInstanceId();
627
+                    $path = \OC::$SERVERROOT;
628
+                    return md5($instanceId . '-' . $version . '-' . $path);
629
+                };
630
+                return new \OC\Memcache\Factory($prefixClosure,
631
+                    $c->get(LoggerInterface::class),
632
+                    $profiler,
633
+                    /** @psalm-taint-escape callable */
634
+                    $config->getValue('memcache.local', null),
635
+                    /** @psalm-taint-escape callable */
636
+                    $config->getValue('memcache.distributed', null),
637
+                    /** @psalm-taint-escape callable */
638
+                    $config->getValue('memcache.locking', null),
639
+                    /** @psalm-taint-escape callable */
640
+                    $config->getValue('redis_log_file')
641
+                );
642
+            }
643
+            return $arrayCacheFactory;
644
+        });
645
+        $this->registerAlias(ICacheFactory::class, Factory::class);
646
+
647
+        $this->registerService('RedisFactory', function (Server $c) {
648
+            $systemConfig = $c->get(SystemConfig::class);
649
+            return new RedisFactory($systemConfig, $c->get(IEventLogger::class));
650
+        });
651
+
652
+        $this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
653
+            $l10n = $this->get(IFactory::class)->get('lib');
654
+            return new \OC\Activity\Manager(
655
+                $c->getRequest(),
656
+                $c->get(IUserSession::class),
657
+                $c->get(\OCP\IConfig::class),
658
+                $c->get(IValidator::class),
659
+                $c->get(IRichTextFormatter::class),
660
+                $l10n,
661
+                $c->get(ITimeFactory::class),
662
+            );
663
+        });
664
+
665
+        $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
666
+            return new \OC\Activity\EventMerger(
667
+                $c->getL10N('lib')
668
+            );
669
+        });
670
+        $this->registerAlias(IValidator::class, Validator::class);
671
+
672
+        $this->registerService(AvatarManager::class, function (Server $c) {
673
+            return new AvatarManager(
674
+                $c->get(IUserSession::class),
675
+                $c->get(\OC\User\Manager::class),
676
+                $c->getAppDataDir('avatar'),
677
+                $c->getL10N('lib'),
678
+                $c->get(LoggerInterface::class),
679
+                $c->get(\OCP\IConfig::class),
680
+                $c->get(IAccountManager::class),
681
+                $c->get(KnownUserService::class)
682
+            );
683
+        });
684
+
685
+        $this->registerAlias(IAvatarManager::class, AvatarManager::class);
686
+
687
+        $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
688
+        $this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class);
689
+        $this->registerAlias(\OCP\Support\Subscription\IAssertion::class, \OC\Support\Subscription\Assertion::class);
690
+
691
+        /** Only used by the PsrLoggerAdapter should not be used by apps */
692
+        $this->registerService(\OC\Log::class, function (Server $c) {
693
+            $logType = $c->get(AllConfig::class)->getSystemValue('log_type', 'file');
694
+            $factory = new LogFactory($c, $this->get(SystemConfig::class));
695
+            $logger = $factory->get($logType);
696
+            $registry = $c->get(\OCP\Support\CrashReport\IRegistry::class);
697
+
698
+            return new Log($logger, $this->get(SystemConfig::class), crashReporters: $registry);
699
+        });
700
+        // PSR-3 logger
701
+        $this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class);
702
+
703
+        $this->registerService(ILogFactory::class, function (Server $c) {
704
+            return new LogFactory($c, $this->get(SystemConfig::class));
705
+        });
706
+
707
+        $this->registerAlias(IJobList::class, \OC\BackgroundJob\JobList::class);
708
+
709
+        $this->registerService(Router::class, function (Server $c) {
710
+            $cacheFactory = $c->get(ICacheFactory::class);
711
+            if ($cacheFactory->isLocalCacheAvailable()) {
712
+                $router = $c->resolve(CachingRouter::class);
713
+            } else {
714
+                $router = $c->resolve(Router::class);
715
+            }
716
+            return $router;
717
+        });
718
+        $this->registerAlias(IRouter::class, Router::class);
719
+
720
+        $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
721
+            $config = $c->get(\OCP\IConfig::class);
722
+            if (ltrim($config->getSystemValueString('memcache.distributed', ''), '\\') === \OC\Memcache\Redis::class) {
723
+                $backend = new \OC\Security\RateLimiting\Backend\MemoryCacheBackend(
724
+                    $c->get(AllConfig::class),
725
+                    $this->get(ICacheFactory::class),
726
+                    new \OC\AppFramework\Utility\TimeFactory()
727
+                );
728
+            } else {
729
+                $backend = new \OC\Security\RateLimiting\Backend\DatabaseBackend(
730
+                    $c->get(AllConfig::class),
731
+                    $c->get(IDBConnection::class),
732
+                    new \OC\AppFramework\Utility\TimeFactory()
733
+                );
734
+            }
735
+
736
+            return $backend;
737
+        });
738
+
739
+        $this->registerAlias(\OCP\Security\ISecureRandom::class, SecureRandom::class);
740
+        $this->registerAlias(\OCP\Security\IRemoteHostValidator::class, \OC\Security\RemoteHostValidator::class);
741
+        $this->registerAlias(IVerificationToken::class, VerificationToken::class);
742
+
743
+        $this->registerAlias(ICrypto::class, Crypto::class);
744
+
745
+        $this->registerAlias(IHasher::class, Hasher::class);
746
+
747
+        $this->registerAlias(ICredentialsManager::class, CredentialsManager::class);
748
+
749
+        $this->registerAlias(IDBConnection::class, ConnectionAdapter::class);
750
+        $this->registerService(Connection::class, function (Server $c) {
751
+            $systemConfig = $c->get(SystemConfig::class);
752
+            $factory = new \OC\DB\ConnectionFactory($systemConfig, $c->get(ICacheFactory::class));
753
+            $type = $systemConfig->getValue('dbtype', 'sqlite');
754
+            if (!$factory->isValidType($type)) {
755
+                throw new \OC\DatabaseException('Invalid database type');
756
+            }
757
+            $connection = $factory->getConnection($type, []);
758
+            return $connection;
759
+        });
760
+
761
+        $this->registerAlias(ICertificateManager::class, CertificateManager::class);
762
+        $this->registerAlias(IClientService::class, ClientService::class);
763
+        $this->registerService(NegativeDnsCache::class, function (ContainerInterface $c) {
764
+            return new NegativeDnsCache(
765
+                $c->get(ICacheFactory::class),
766
+            );
767
+        });
768
+        $this->registerDeprecatedAlias('HttpClientService', IClientService::class);
769
+        $this->registerService(IEventLogger::class, function (ContainerInterface $c) {
770
+            return new EventLogger($c->get(SystemConfig::class), $c->get(LoggerInterface::class), $c->get(Log::class));
771
+        });
772
+
773
+        $this->registerService(IQueryLogger::class, function (ContainerInterface $c) {
774
+            $queryLogger = new QueryLogger();
775
+            if ($c->get(SystemConfig::class)->getValue('debug', false)) {
776
+                // In debug mode, module is being activated by default
777
+                $queryLogger->activate();
778
+            }
779
+            return $queryLogger;
780
+        });
781
+
782
+        $this->registerAlias(ITempManager::class, TempManager::class);
783
+        $this->registerAlias(IDateTimeZone::class, DateTimeZone::class);
784
+
785
+        $this->registerService(IDateTimeFormatter::class, function (Server $c) {
786
+            $language = $c->get(\OCP\IConfig::class)->getUserValue($c->get(ISession::class)->get('user_id'), 'core', 'lang', null);
787
+
788
+            return new DateTimeFormatter(
789
+                $c->get(IDateTimeZone::class)->getTimeZone(),
790
+                $c->getL10N('lib', $language)
791
+            );
792
+        });
793
+
794
+        $this->registerService(IUserMountCache::class, function (ContainerInterface $c) {
795
+            $mountCache = $c->get(UserMountCache::class);
796
+            $listener = new UserMountCacheListener($mountCache);
797
+            $listener->listen($c->get(IUserManager::class));
798
+            return $mountCache;
799
+        });
800
+
801
+        $this->registerService(IMountProviderCollection::class, function (ContainerInterface $c) {
802
+            $loader = $c->get(IStorageFactory::class);
803
+            $mountCache = $c->get(IUserMountCache::class);
804
+            $eventLogger = $c->get(IEventLogger::class);
805
+            $manager = new MountProviderCollection($loader, $mountCache, $eventLogger);
806
+
807
+            // builtin providers
808
+
809
+            $config = $c->get(\OCP\IConfig::class);
810
+            $logger = $c->get(LoggerInterface::class);
811
+            $objectStoreConfig = $c->get(PrimaryObjectStoreConfig::class);
812
+            $manager->registerProvider(new CacheMountProvider($config));
813
+            $manager->registerHomeProvider(new LocalHomeMountProvider());
814
+            $manager->registerHomeProvider(new ObjectHomeMountProvider($objectStoreConfig));
815
+            $manager->registerRootProvider(new RootMountProvider($objectStoreConfig, $config));
816
+            $manager->registerRootProvider(new ObjectStorePreviewCacheMountProvider($logger, $config));
817
+
818
+            return $manager;
819
+        });
820
+
821
+        $this->registerService(IBus::class, function (ContainerInterface $c) {
822
+            $busClass = $c->get(\OCP\IConfig::class)->getSystemValueString('commandbus');
823
+            if ($busClass) {
824
+                [$app, $class] = explode('::', $busClass, 2);
825
+                if ($c->get(IAppManager::class)->isEnabledForUser($app)) {
826
+                    $c->get(IAppManager::class)->loadApp($app);
827
+                    return $c->get($class);
828
+                } else {
829
+                    throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
830
+                }
831
+            } else {
832
+                $jobList = $c->get(IJobList::class);
833
+                return new CronBus($jobList);
834
+            }
835
+        });
836
+        $this->registerDeprecatedAlias('AsyncCommandBus', IBus::class);
837
+        $this->registerAlias(ITrustedDomainHelper::class, TrustedDomainHelper::class);
838
+        $this->registerAlias(IThrottler::class, Throttler::class);
839
+
840
+        $this->registerService(\OC\Security\Bruteforce\Backend\IBackend::class, function ($c) {
841
+            $config = $c->get(\OCP\IConfig::class);
842
+            if (!$config->getSystemValueBool('auth.bruteforce.protection.force.database', false)
843
+                && ltrim($config->getSystemValueString('memcache.distributed', ''), '\\') === \OC\Memcache\Redis::class) {
844
+                $backend = $c->get(\OC\Security\Bruteforce\Backend\MemoryCacheBackend::class);
845
+            } else {
846
+                $backend = $c->get(\OC\Security\Bruteforce\Backend\DatabaseBackend::class);
847
+            }
848
+
849
+            return $backend;
850
+        });
851
+
852
+        $this->registerDeprecatedAlias('IntegrityCodeChecker', Checker::class);
853
+        $this->registerService(Checker::class, function (ContainerInterface $c) {
854
+            // IConfig requires a working database. This code
855
+            // might however be called when Nextcloud is not yet setup.
856
+            if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
857
+                $config = $c->get(\OCP\IConfig::class);
858
+                $appConfig = $c->get(\OCP\IAppConfig::class);
859
+            } else {
860
+                $config = null;
861
+                $appConfig = null;
862
+            }
863
+
864
+            return new Checker(
865
+                $c->get(ServerVersion::class),
866
+                $c->get(EnvironmentHelper::class),
867
+                new FileAccessHelper(),
868
+                new AppLocator(),
869
+                $config,
870
+                $appConfig,
871
+                $c->get(ICacheFactory::class),
872
+                $c->get(IAppManager::class),
873
+                $c->get(IMimeTypeDetector::class)
874
+            );
875
+        });
876
+        $this->registerService(Request::class, function (ContainerInterface $c) {
877
+            if (isset($this['urlParams'])) {
878
+                $urlParams = $this['urlParams'];
879
+            } else {
880
+                $urlParams = [];
881
+            }
882
+
883
+            if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
884
+                && in_array('fakeinput', stream_get_wrappers())
885
+            ) {
886
+                $stream = 'fakeinput://data';
887
+            } else {
888
+                $stream = 'php://input';
889
+            }
890
+
891
+            return new Request(
892
+                [
893
+                    'get' => $_GET,
894
+                    'post' => $_POST,
895
+                    'files' => $_FILES,
896
+                    'server' => $_SERVER,
897
+                    'env' => $_ENV,
898
+                    'cookies' => $_COOKIE,
899
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
900
+                        ? $_SERVER['REQUEST_METHOD']
901
+                        : '',
902
+                    'urlParams' => $urlParams,
903
+                ],
904
+                $this->get(IRequestId::class),
905
+                $this->get(\OCP\IConfig::class),
906
+                $this->get(CsrfTokenManager::class),
907
+                $stream
908
+            );
909
+        });
910
+        $this->registerAlias(\OCP\IRequest::class, Request::class);
911
+
912
+        $this->registerService(IRequestId::class, function (ContainerInterface $c): IRequestId {
913
+            return new RequestId(
914
+                $_SERVER['UNIQUE_ID'] ?? '',
915
+                $this->get(ISecureRandom::class)
916
+            );
917
+        });
918
+
919
+        $this->registerService(IMailer::class, function (Server $c) {
920
+            return new Mailer(
921
+                $c->get(\OCP\IConfig::class),
922
+                $c->get(LoggerInterface::class),
923
+                $c->get(Defaults::class),
924
+                $c->get(IURLGenerator::class),
925
+                $c->getL10N('lib'),
926
+                $c->get(IEventDispatcher::class),
927
+                $c->get(IFactory::class)
928
+            );
929
+        });
930
+
931
+        /** @since 30.0.0 */
932
+        $this->registerAlias(\OCP\Mail\Provider\IManager::class, \OC\Mail\Provider\Manager::class);
933
+
934
+        $this->registerService(ILDAPProviderFactory::class, function (ContainerInterface $c) {
935
+            $config = $c->get(\OCP\IConfig::class);
936
+            $factoryClass = $config->getSystemValue('ldapProviderFactory', null);
937
+            if (is_null($factoryClass) || !class_exists($factoryClass)) {
938
+                return new NullLDAPProviderFactory($this);
939
+            }
940
+            /** @var \OCP\LDAP\ILDAPProviderFactory $factory */
941
+            return new $factoryClass($this);
942
+        });
943
+        $this->registerService(ILDAPProvider::class, function (ContainerInterface $c) {
944
+            $factory = $c->get(ILDAPProviderFactory::class);
945
+            return $factory->getLDAPProvider();
946
+        });
947
+        $this->registerService(ILockingProvider::class, function (ContainerInterface $c) {
948
+            $ini = $c->get(IniGetWrapper::class);
949
+            $config = $c->get(\OCP\IConfig::class);
950
+            $ttl = $config->getSystemValueInt('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
951
+            if ($config->getSystemValueBool('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
952
+                /** @var \OC\Memcache\Factory $memcacheFactory */
953
+                $memcacheFactory = $c->get(ICacheFactory::class);
954
+                $memcache = $memcacheFactory->createLocking('lock');
955
+                if (!($memcache instanceof \OC\Memcache\NullCache)) {
956
+                    $timeFactory = $c->get(ITimeFactory::class);
957
+                    return new MemcacheLockingProvider($memcache, $timeFactory, $ttl);
958
+                }
959
+                return new DBLockingProvider(
960
+                    $c->get(IDBConnection::class),
961
+                    new TimeFactory(),
962
+                    $ttl,
963
+                    !\OC::$CLI
964
+                );
965
+            }
966
+            return new NoopLockingProvider();
967
+        });
968
+
969
+        $this->registerService(ILockManager::class, function (Server $c): LockManager {
970
+            return new LockManager();
971
+        });
972
+
973
+        $this->registerAlias(ILockdownManager::class, 'LockdownManager');
974
+        $this->registerService(SetupManager::class, function ($c) {
975
+            // create the setupmanager through the mount manager to resolve the cyclic dependency
976
+            return $c->get(\OC\Files\Mount\Manager::class)->getSetupManager();
977
+        });
978
+        $this->registerAlias(IMountManager::class, \OC\Files\Mount\Manager::class);
979
+
980
+        $this->registerService(IMimeTypeDetector::class, function (ContainerInterface $c) {
981
+            return new \OC\Files\Type\Detection(
982
+                $c->get(IURLGenerator::class),
983
+                $c->get(LoggerInterface::class),
984
+                \OC::$configDir,
985
+                \OC::$SERVERROOT . '/resources/config/'
986
+            );
987
+        });
988
+
989
+        $this->registerAlias(IMimeTypeLoader::class, Loader::class);
990
+        $this->registerService(BundleFetcher::class, function () {
991
+            return new BundleFetcher($this->getL10N('lib'));
992
+        });
993
+        $this->registerAlias(\OCP\Notification\IManager::class, Manager::class);
994
+
995
+        $this->registerService(CapabilitiesManager::class, function (ContainerInterface $c) {
996
+            $manager = new CapabilitiesManager($c->get(LoggerInterface::class));
997
+            $manager->registerCapability(function () use ($c) {
998
+                return new \OC\OCS\CoreCapabilities($c->get(\OCP\IConfig::class));
999
+            });
1000
+            $manager->registerCapability(function () use ($c) {
1001
+                return $c->get(\OC\Security\Bruteforce\Capabilities::class);
1002
+            });
1003
+            return $manager;
1004
+        });
1005
+
1006
+        $this->registerService(ICommentsManager::class, function (Server $c) {
1007
+            $config = $c->get(\OCP\IConfig::class);
1008
+            $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class);
1009
+            /** @var \OCP\Comments\ICommentsManagerFactory $factory */
1010
+            $factory = new $factoryClass($this);
1011
+            $manager = $factory->getManager();
1012
+
1013
+            $manager->registerDisplayNameResolver('user', function ($id) use ($c) {
1014
+                $manager = $c->get(IUserManager::class);
1015
+                $userDisplayName = $manager->getDisplayName($id);
1016
+                if ($userDisplayName === null) {
1017
+                    $l = $c->get(IFactory::class)->get('core');
1018
+                    return $l->t('Unknown account');
1019
+                }
1020
+                return $userDisplayName;
1021
+            });
1022
+
1023
+            return $manager;
1024
+        });
1025
+
1026
+        $this->registerAlias(\OC_Defaults::class, 'ThemingDefaults');
1027
+        $this->registerService('ThemingDefaults', function (Server $c) {
1028
+            try {
1029
+                $classExists = class_exists('OCA\Theming\ThemingDefaults');
1030
+            } catch (\OCP\AutoloadNotAllowedException $e) {
1031
+                // App disabled or in maintenance mode
1032
+                $classExists = false;
1033
+            }
1034
+
1035
+            if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValueBool('installed', false) && $c->get(IAppManager::class)->isEnabledForAnyone('theming') && $c->get(TrustedDomainHelper::class)->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
1036
+                $backgroundService = new BackgroundService(
1037
+                    $c->get(IRootFolder::class),
1038
+                    $c->getAppDataDir('theming'),
1039
+                    $c->get(IAppConfig::class),
1040
+                    $c->get(\OCP\IConfig::class),
1041
+                    $c->get(ISession::class)->get('user_id'),
1042
+                );
1043
+                $imageManager = new ImageManager(
1044
+                    $c->get(\OCP\IConfig::class),
1045
+                    $c->getAppDataDir('theming'),
1046
+                    $c->get(IURLGenerator::class),
1047
+                    $c->get(ICacheFactory::class),
1048
+                    $c->get(LoggerInterface::class),
1049
+                    $c->get(ITempManager::class),
1050
+                    $backgroundService,
1051
+                );
1052
+                return new ThemingDefaults(
1053
+                    $c->get(\OCP\IConfig::class),
1054
+                    $c->get(\OCP\IAppConfig::class),
1055
+                    $c->getL10N('theming'),
1056
+                    $c->get(IUserSession::class),
1057
+                    $c->get(IURLGenerator::class),
1058
+                    $c->get(ICacheFactory::class),
1059
+                    new Util($c->get(ServerVersion::class), $c->get(\OCP\IConfig::class), $this->get(IAppManager::class), $c->getAppDataDir('theming'), $imageManager),
1060
+                    $imageManager,
1061
+                    $c->get(IAppManager::class),
1062
+                    $c->get(INavigationManager::class),
1063
+                    $backgroundService,
1064
+                );
1065
+            }
1066
+            return new \OC_Defaults();
1067
+        });
1068
+        $this->registerService(JSCombiner::class, function (Server $c) {
1069
+            return new JSCombiner(
1070
+                $c->getAppDataDir('js'),
1071
+                $c->get(IURLGenerator::class),
1072
+                $this->get(ICacheFactory::class),
1073
+                $c->get(SystemConfig::class),
1074
+                $c->get(LoggerInterface::class)
1075
+            );
1076
+        });
1077
+        $this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class);
1078
+
1079
+        $this->registerService('CryptoWrapper', function (ContainerInterface $c) {
1080
+            // FIXME: Instantiated here due to cyclic dependency
1081
+            $request = new Request(
1082
+                [
1083
+                    'get' => $_GET,
1084
+                    'post' => $_POST,
1085
+                    'files' => $_FILES,
1086
+                    'server' => $_SERVER,
1087
+                    'env' => $_ENV,
1088
+                    'cookies' => $_COOKIE,
1089
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1090
+                        ? $_SERVER['REQUEST_METHOD']
1091
+                        : null,
1092
+                ],
1093
+                $c->get(IRequestId::class),
1094
+                $c->get(\OCP\IConfig::class)
1095
+            );
1096
+
1097
+            return new CryptoWrapper(
1098
+                $c->get(ICrypto::class),
1099
+                $c->get(ISecureRandom::class),
1100
+                $request
1101
+            );
1102
+        });
1103
+        $this->registerService(SessionStorage::class, function (ContainerInterface $c) {
1104
+            return new SessionStorage($c->get(ISession::class));
1105
+        });
1106
+        $this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class);
1107
+
1108
+        $this->registerService(IProviderFactory::class, function (ContainerInterface $c) {
1109
+            $config = $c->get(\OCP\IConfig::class);
1110
+            $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class);
1111
+            /** @var \OCP\Share\IProviderFactory $factory */
1112
+            return $c->get($factoryClass);
1113
+        });
1114
+
1115
+        $this->registerAlias(\OCP\Share\IManager::class, \OC\Share20\Manager::class);
1116
+
1117
+        $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) {
1118
+            $instance = new Collaboration\Collaborators\Search($c);
1119
+
1120
+            // register default plugins
1121
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]);
1122
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
1123
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
1124
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
1125
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]);
1126
+
1127
+            return $instance;
1128
+        });
1129
+        $this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class);
1130
+
1131
+        $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
1132
+
1133
+        $this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class);
1134
+        $this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class);
1135
+
1136
+        $this->registerAlias(IReferenceManager::class, ReferenceManager::class);
1137
+        $this->registerAlias(ITeamManager::class, TeamManager::class);
1138
+
1139
+        $this->registerDeprecatedAlias('SettingsManager', \OC\Settings\Manager::class);
1140
+        $this->registerAlias(\OCP\Settings\IManager::class, \OC\Settings\Manager::class);
1141
+        $this->registerService(\OC\Files\AppData\Factory::class, function (ContainerInterface $c) {
1142
+            return new \OC\Files\AppData\Factory(
1143
+                $c->get(IRootFolder::class),
1144
+                $c->get(SystemConfig::class)
1145
+            );
1146
+        });
1147
+
1148
+        $this->registerService('LockdownManager', function (ContainerInterface $c) {
1149
+            return new LockdownManager(function () use ($c) {
1150
+                return $c->get(ISession::class);
1151
+            });
1152
+        });
1153
+
1154
+        $this->registerService(\OCP\OCS\IDiscoveryService::class, function (ContainerInterface $c) {
1155
+            return new DiscoveryService(
1156
+                $c->get(ICacheFactory::class),
1157
+                $c->get(IClientService::class)
1158
+            );
1159
+        });
1160
+        $this->registerAlias(IOCMDiscoveryService::class, OCMDiscoveryService::class);
1161
+
1162
+        $this->registerService(ICloudIdManager::class, function (ContainerInterface $c) {
1163
+            return new CloudIdManager(
1164
+                $c->get(ICacheFactory::class),
1165
+                $c->get(IEventDispatcher::class),
1166
+                $c->get(\OCP\Contacts\IManager::class),
1167
+                $c->get(IURLGenerator::class),
1168
+                $c->get(IUserManager::class),
1169
+            );
1170
+        });
1171
+
1172
+        $this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class);
1173
+        $this->registerAlias(ICloudFederationProviderManager::class, CloudFederationProviderManager::class);
1174
+        $this->registerService(ICloudFederationFactory::class, function (Server $c) {
1175
+            return new CloudFederationFactory();
1176
+        });
1177 1177
 
1178
-		$this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1178
+        $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1179 1179
 
1180
-		$this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1181
-		$this->registerAlias(\Psr\Clock\ClockInterface::class, \OCP\AppFramework\Utility\ITimeFactory::class);
1180
+        $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1181
+        $this->registerAlias(\Psr\Clock\ClockInterface::class, \OCP\AppFramework\Utility\ITimeFactory::class);
1182 1182
 
1183
-		$this->registerService(Defaults::class, function (Server $c) {
1184
-			return new Defaults(
1185
-				$c->get('ThemingDefaults')
1186
-			);
1187
-		});
1183
+        $this->registerService(Defaults::class, function (Server $c) {
1184
+            return new Defaults(
1185
+                $c->get('ThemingDefaults')
1186
+            );
1187
+        });
1188 1188
 
1189
-		$this->registerService(\OCP\ISession::class, function (ContainerInterface $c) {
1190
-			return $c->get(\OCP\IUserSession::class)->getSession();
1191
-		}, false);
1189
+        $this->registerService(\OCP\ISession::class, function (ContainerInterface $c) {
1190
+            return $c->get(\OCP\IUserSession::class)->getSession();
1191
+        }, false);
1192 1192
 
1193
-		$this->registerService(IShareHelper::class, function (ContainerInterface $c) {
1194
-			return new ShareHelper(
1195
-				$c->get(\OCP\Share\IManager::class)
1196
-			);
1197
-		});
1193
+        $this->registerService(IShareHelper::class, function (ContainerInterface $c) {
1194
+            return new ShareHelper(
1195
+                $c->get(\OCP\Share\IManager::class)
1196
+            );
1197
+        });
1198 1198
 
1199
-		$this->registerService(Installer::class, function (ContainerInterface $c) {
1200
-			return new Installer(
1201
-				$c->get(AppFetcher::class),
1202
-				$c->get(IClientService::class),
1203
-				$c->get(ITempManager::class),
1204
-				$c->get(LoggerInterface::class),
1205
-				$c->get(\OCP\IConfig::class),
1206
-				\OC::$CLI
1207
-			);
1208
-		});
1199
+        $this->registerService(Installer::class, function (ContainerInterface $c) {
1200
+            return new Installer(
1201
+                $c->get(AppFetcher::class),
1202
+                $c->get(IClientService::class),
1203
+                $c->get(ITempManager::class),
1204
+                $c->get(LoggerInterface::class),
1205
+                $c->get(\OCP\IConfig::class),
1206
+                \OC::$CLI
1207
+            );
1208
+        });
1209 1209
 
1210
-		$this->registerService(IApiFactory::class, function (ContainerInterface $c) {
1211
-			return new ApiFactory($c->get(IClientService::class));
1212
-		});
1210
+        $this->registerService(IApiFactory::class, function (ContainerInterface $c) {
1211
+            return new ApiFactory($c->get(IClientService::class));
1212
+        });
1213 1213
 
1214
-		$this->registerService(IInstanceFactory::class, function (ContainerInterface $c) {
1215
-			$memcacheFactory = $c->get(ICacheFactory::class);
1216
-			return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->get(IClientService::class));
1217
-		});
1214
+        $this->registerService(IInstanceFactory::class, function (ContainerInterface $c) {
1215
+            $memcacheFactory = $c->get(ICacheFactory::class);
1216
+            return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->get(IClientService::class));
1217
+        });
1218 1218
 
1219
-		$this->registerAlias(IContactsStore::class, ContactsStore::class);
1220
-		$this->registerAlias(IAccountManager::class, AccountManager::class);
1219
+        $this->registerAlias(IContactsStore::class, ContactsStore::class);
1220
+        $this->registerAlias(IAccountManager::class, AccountManager::class);
1221 1221
 
1222
-		$this->registerAlias(IStorageFactory::class, StorageFactory::class);
1222
+        $this->registerAlias(IStorageFactory::class, StorageFactory::class);
1223 1223
 
1224
-		$this->registerAlias(\OCP\Dashboard\IManager::class, \OC\Dashboard\Manager::class);
1224
+        $this->registerAlias(\OCP\Dashboard\IManager::class, \OC\Dashboard\Manager::class);
1225 1225
 
1226
-		$this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class);
1227
-		$this->registerAlias(IFilesMetadataManager::class, FilesMetadataManager::class);
1226
+        $this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class);
1227
+        $this->registerAlias(IFilesMetadataManager::class, FilesMetadataManager::class);
1228 1228
 
1229
-		$this->registerAlias(ISubAdmin::class, SubAdmin::class);
1229
+        $this->registerAlias(ISubAdmin::class, SubAdmin::class);
1230 1230
 
1231
-		$this->registerAlias(IInitialStateService::class, InitialStateService::class);
1231
+        $this->registerAlias(IInitialStateService::class, InitialStateService::class);
1232 1232
 
1233
-		$this->registerAlias(\OCP\IEmojiHelper::class, \OC\EmojiHelper::class);
1233
+        $this->registerAlias(\OCP\IEmojiHelper::class, \OC\EmojiHelper::class);
1234 1234
 
1235
-		$this->registerAlias(\OCP\UserStatus\IManager::class, \OC\UserStatus\Manager::class);
1235
+        $this->registerAlias(\OCP\UserStatus\IManager::class, \OC\UserStatus\Manager::class);
1236 1236
 
1237
-		$this->registerAlias(IBroker::class, Broker::class);
1237
+        $this->registerAlias(IBroker::class, Broker::class);
1238 1238
 
1239
-		$this->registerAlias(\OCP\Files\AppData\IAppDataFactory::class, \OC\Files\AppData\Factory::class);
1239
+        $this->registerAlias(\OCP\Files\AppData\IAppDataFactory::class, \OC\Files\AppData\Factory::class);
1240 1240
 
1241
-		$this->registerAlias(\OCP\Files\IFilenameValidator::class, \OC\Files\FilenameValidator::class);
1241
+        $this->registerAlias(\OCP\Files\IFilenameValidator::class, \OC\Files\FilenameValidator::class);
1242 1242
 
1243
-		$this->registerAlias(IBinaryFinder::class, BinaryFinder::class);
1243
+        $this->registerAlias(IBinaryFinder::class, BinaryFinder::class);
1244 1244
 
1245
-		$this->registerAlias(\OCP\Share\IPublicShareTemplateFactory::class, \OC\Share20\PublicShareTemplateFactory::class);
1245
+        $this->registerAlias(\OCP\Share\IPublicShareTemplateFactory::class, \OC\Share20\PublicShareTemplateFactory::class);
1246 1246
 
1247
-		$this->registerAlias(ITranslationManager::class, TranslationManager::class);
1247
+        $this->registerAlias(ITranslationManager::class, TranslationManager::class);
1248 1248
 
1249
-		$this->registerAlias(IConversionManager::class, ConversionManager::class);
1249
+        $this->registerAlias(IConversionManager::class, ConversionManager::class);
1250 1250
 
1251
-		$this->registerAlias(ISpeechToTextManager::class, SpeechToTextManager::class);
1251
+        $this->registerAlias(ISpeechToTextManager::class, SpeechToTextManager::class);
1252 1252
 
1253
-		$this->registerAlias(IEventSourceFactory::class, EventSourceFactory::class);
1253
+        $this->registerAlias(IEventSourceFactory::class, EventSourceFactory::class);
1254 1254
 
1255
-		$this->registerAlias(\OCP\TextProcessing\IManager::class, \OC\TextProcessing\Manager::class);
1255
+        $this->registerAlias(\OCP\TextProcessing\IManager::class, \OC\TextProcessing\Manager::class);
1256 1256
 
1257
-		$this->registerAlias(\OCP\TextToImage\IManager::class, \OC\TextToImage\Manager::class);
1257
+        $this->registerAlias(\OCP\TextToImage\IManager::class, \OC\TextToImage\Manager::class);
1258 1258
 
1259
-		$this->registerAlias(ILimiter::class, Limiter::class);
1259
+        $this->registerAlias(ILimiter::class, Limiter::class);
1260 1260
 
1261
-		$this->registerAlias(IPhoneNumberUtil::class, PhoneNumberUtil::class);
1261
+        $this->registerAlias(IPhoneNumberUtil::class, PhoneNumberUtil::class);
1262 1262
 
1263
-		$this->registerAlias(ICapabilityAwareOCMProvider::class, OCMProvider::class);
1264
-		$this->registerDeprecatedAlias(IOCMProvider::class, OCMProvider::class);
1263
+        $this->registerAlias(ICapabilityAwareOCMProvider::class, OCMProvider::class);
1264
+        $this->registerDeprecatedAlias(IOCMProvider::class, OCMProvider::class);
1265 1265
 
1266
-		$this->registerAlias(ISetupCheckManager::class, SetupCheckManager::class);
1266
+        $this->registerAlias(ISetupCheckManager::class, SetupCheckManager::class);
1267 1267
 
1268
-		$this->registerAlias(IProfileManager::class, ProfileManager::class);
1268
+        $this->registerAlias(IProfileManager::class, ProfileManager::class);
1269 1269
 
1270
-		$this->registerAlias(IAvailabilityCoordinator::class, AvailabilityCoordinator::class);
1270
+        $this->registerAlias(IAvailabilityCoordinator::class, AvailabilityCoordinator::class);
1271 1271
 
1272
-		$this->registerAlias(IDeclarativeManager::class, DeclarativeManager::class);
1272
+        $this->registerAlias(IDeclarativeManager::class, DeclarativeManager::class);
1273 1273
 
1274
-		$this->registerAlias(\OCP\TaskProcessing\IManager::class, \OC\TaskProcessing\Manager::class);
1274
+        $this->registerAlias(\OCP\TaskProcessing\IManager::class, \OC\TaskProcessing\Manager::class);
1275 1275
 
1276
-		$this->registerAlias(IRemoteAddress::class, RemoteAddress::class);
1276
+        $this->registerAlias(IRemoteAddress::class, RemoteAddress::class);
1277 1277
 
1278
-		$this->registerAlias(\OCP\Security\Ip\IFactory::class, \OC\Security\Ip\Factory::class);
1279
-
1280
-		$this->registerAlias(IRichTextFormatter::class, \OC\RichObjectStrings\RichTextFormatter::class);
1281
-
1282
-		$this->registerAlias(ISignatureManager::class, SignatureManager::class);
1283
-
1284
-		$this->connectDispatcher();
1285
-	}
1286
-
1287
-	public function boot() {
1288
-		/** @var HookConnector $hookConnector */
1289
-		$hookConnector = $this->get(HookConnector::class);
1290
-		$hookConnector->viewToNode();
1291
-	}
1292
-
1293
-	private function connectDispatcher(): void {
1294
-		/** @var IEventDispatcher $eventDispatcher */
1295
-		$eventDispatcher = $this->get(IEventDispatcher::class);
1296
-		$eventDispatcher->addServiceListener(LoginFailed::class, LoginFailedListener::class);
1297
-		$eventDispatcher->addServiceListener(PostLoginEvent::class, UserLoggedInListener::class);
1298
-		$eventDispatcher->addServiceListener(UserChangedEvent::class, UserChangedListener::class);
1299
-		$eventDispatcher->addServiceListener(BeforeUserDeletedEvent::class, BeforeUserDeletedListener::class);
1300
-
1301
-		FilesMetadataManager::loadListeners($eventDispatcher);
1302
-		GenerateBlurhashMetadata::loadListeners($eventDispatcher);
1303
-	}
1304
-
1305
-	/**
1306
-	 * @return \OCP\Contacts\IManager
1307
-	 * @deprecated 20.0.0
1308
-	 */
1309
-	public function getContactsManager() {
1310
-		return $this->get(\OCP\Contacts\IManager::class);
1311
-	}
1312
-
1313
-	/**
1314
-	 * @return \OC\Encryption\Manager
1315
-	 * @deprecated 20.0.0
1316
-	 */
1317
-	public function getEncryptionManager() {
1318
-		return $this->get(\OCP\Encryption\IManager::class);
1319
-	}
1320
-
1321
-	/**
1322
-	 * @return \OC\Encryption\File
1323
-	 * @deprecated 20.0.0
1324
-	 */
1325
-	public function getEncryptionFilesHelper() {
1326
-		return $this->get(IFile::class);
1327
-	}
1328
-
1329
-	/**
1330
-	 * The current request object holding all information about the request
1331
-	 * currently being processed is returned from this method.
1332
-	 * In case the current execution was not initiated by a web request null is returned
1333
-	 *
1334
-	 * @return \OCP\IRequest
1335
-	 * @deprecated 20.0.0
1336
-	 */
1337
-	public function getRequest() {
1338
-		return $this->get(IRequest::class);
1339
-	}
1340
-
1341
-	/**
1342
-	 * Returns the root folder of ownCloud's data directory
1343
-	 *
1344
-	 * @return IRootFolder
1345
-	 * @deprecated 20.0.0
1346
-	 */
1347
-	public function getRootFolder() {
1348
-		return $this->get(IRootFolder::class);
1349
-	}
1350
-
1351
-	/**
1352
-	 * Returns the root folder of ownCloud's data directory
1353
-	 * This is the lazy variant so this gets only initialized once it
1354
-	 * is actually used.
1355
-	 *
1356
-	 * @return IRootFolder
1357
-	 * @deprecated 20.0.0
1358
-	 */
1359
-	public function getLazyRootFolder() {
1360
-		return $this->get(IRootFolder::class);
1361
-	}
1362
-
1363
-	/**
1364
-	 * Returns a view to ownCloud's files folder
1365
-	 *
1366
-	 * @param string $userId user ID
1367
-	 * @return \OCP\Files\Folder|null
1368
-	 * @deprecated 20.0.0
1369
-	 */
1370
-	public function getUserFolder($userId = null) {
1371
-		if ($userId === null) {
1372
-			$user = $this->get(IUserSession::class)->getUser();
1373
-			if (!$user) {
1374
-				return null;
1375
-			}
1376
-			$userId = $user->getUID();
1377
-		}
1378
-		$root = $this->get(IRootFolder::class);
1379
-		return $root->getUserFolder($userId);
1380
-	}
1381
-
1382
-	/**
1383
-	 * @return \OC\User\Manager
1384
-	 * @deprecated 20.0.0
1385
-	 */
1386
-	public function getUserManager() {
1387
-		return $this->get(IUserManager::class);
1388
-	}
1389
-
1390
-	/**
1391
-	 * @return \OC\Group\Manager
1392
-	 * @deprecated 20.0.0
1393
-	 */
1394
-	public function getGroupManager() {
1395
-		return $this->get(IGroupManager::class);
1396
-	}
1397
-
1398
-	/**
1399
-	 * @return \OC\User\Session
1400
-	 * @deprecated 20.0.0
1401
-	 */
1402
-	public function getUserSession() {
1403
-		return $this->get(IUserSession::class);
1404
-	}
1405
-
1406
-	/**
1407
-	 * @return \OCP\ISession
1408
-	 * @deprecated 20.0.0
1409
-	 */
1410
-	public function getSession() {
1411
-		return $this->get(Session::class)->getSession();
1412
-	}
1413
-
1414
-	/**
1415
-	 * @param \OCP\ISession $session
1416
-	 * @return void
1417
-	 */
1418
-	public function setSession(\OCP\ISession $session) {
1419
-		$this->get(SessionStorage::class)->setSession($session);
1420
-		$this->get(Session::class)->setSession($session);
1421
-		$this->get(Store::class)->setSession($session);
1422
-	}
1423
-
1424
-	/**
1425
-	 * @return \OCP\IConfig
1426
-	 * @deprecated 20.0.0
1427
-	 */
1428
-	public function getConfig() {
1429
-		return $this->get(AllConfig::class);
1430
-	}
1431
-
1432
-	/**
1433
-	 * @return \OC\SystemConfig
1434
-	 * @deprecated 20.0.0
1435
-	 */
1436
-	public function getSystemConfig() {
1437
-		return $this->get(SystemConfig::class);
1438
-	}
1439
-
1440
-	/**
1441
-	 * @return IFactory
1442
-	 * @deprecated 20.0.0
1443
-	 */
1444
-	public function getL10NFactory() {
1445
-		return $this->get(IFactory::class);
1446
-	}
1447
-
1448
-	/**
1449
-	 * get an L10N instance
1450
-	 *
1451
-	 * @param string $app appid
1452
-	 * @param string $lang
1453
-	 * @return IL10N
1454
-	 * @deprecated 20.0.0 use DI of {@see IL10N} or {@see IFactory} instead, or {@see \OCP\Util::getL10N()} as a last resort
1455
-	 */
1456
-	public function getL10N($app, $lang = null) {
1457
-		return $this->get(IFactory::class)->get($app, $lang);
1458
-	}
1459
-
1460
-	/**
1461
-	 * @return IURLGenerator
1462
-	 * @deprecated 20.0.0
1463
-	 */
1464
-	public function getURLGenerator() {
1465
-		return $this->get(IURLGenerator::class);
1466
-	}
1467
-
1468
-	/**
1469
-	 * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1470
-	 * getMemCacheFactory() instead.
1471
-	 *
1472
-	 * @return ICache
1473
-	 * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1474
-	 */
1475
-	public function getCache() {
1476
-		return $this->get(ICache::class);
1477
-	}
1478
-
1479
-	/**
1480
-	 * Returns an \OCP\CacheFactory instance
1481
-	 *
1482
-	 * @return \OCP\ICacheFactory
1483
-	 * @deprecated 20.0.0
1484
-	 */
1485
-	public function getMemCacheFactory() {
1486
-		return $this->get(ICacheFactory::class);
1487
-	}
1488
-
1489
-	/**
1490
-	 * Returns the current session
1491
-	 *
1492
-	 * @return \OCP\IDBConnection
1493
-	 * @deprecated 20.0.0
1494
-	 */
1495
-	public function getDatabaseConnection() {
1496
-		return $this->get(IDBConnection::class);
1497
-	}
1498
-
1499
-	/**
1500
-	 * Returns the activity manager
1501
-	 *
1502
-	 * @return \OCP\Activity\IManager
1503
-	 * @deprecated 20.0.0
1504
-	 */
1505
-	public function getActivityManager() {
1506
-		return $this->get(\OCP\Activity\IManager::class);
1507
-	}
1508
-
1509
-	/**
1510
-	 * Returns an job list for controlling background jobs
1511
-	 *
1512
-	 * @return IJobList
1513
-	 * @deprecated 20.0.0
1514
-	 */
1515
-	public function getJobList() {
1516
-		return $this->get(IJobList::class);
1517
-	}
1518
-
1519
-	/**
1520
-	 * Returns a SecureRandom instance
1521
-	 *
1522
-	 * @return \OCP\Security\ISecureRandom
1523
-	 * @deprecated 20.0.0
1524
-	 */
1525
-	public function getSecureRandom() {
1526
-		return $this->get(ISecureRandom::class);
1527
-	}
1528
-
1529
-	/**
1530
-	 * Returns a Crypto instance
1531
-	 *
1532
-	 * @return ICrypto
1533
-	 * @deprecated 20.0.0
1534
-	 */
1535
-	public function getCrypto() {
1536
-		return $this->get(ICrypto::class);
1537
-	}
1538
-
1539
-	/**
1540
-	 * Returns a Hasher instance
1541
-	 *
1542
-	 * @return IHasher
1543
-	 * @deprecated 20.0.0
1544
-	 */
1545
-	public function getHasher() {
1546
-		return $this->get(IHasher::class);
1547
-	}
1548
-
1549
-	/**
1550
-	 * Get the certificate manager
1551
-	 *
1552
-	 * @return \OCP\ICertificateManager
1553
-	 */
1554
-	public function getCertificateManager() {
1555
-		return $this->get(ICertificateManager::class);
1556
-	}
1557
-
1558
-	/**
1559
-	 * Get the manager for temporary files and folders
1560
-	 *
1561
-	 * @return \OCP\ITempManager
1562
-	 * @deprecated 20.0.0
1563
-	 */
1564
-	public function getTempManager() {
1565
-		return $this->get(ITempManager::class);
1566
-	}
1567
-
1568
-	/**
1569
-	 * Get the app manager
1570
-	 *
1571
-	 * @return \OCP\App\IAppManager
1572
-	 * @deprecated 20.0.0
1573
-	 */
1574
-	public function getAppManager() {
1575
-		return $this->get(IAppManager::class);
1576
-	}
1577
-
1578
-	/**
1579
-	 * Creates a new mailer
1580
-	 *
1581
-	 * @return IMailer
1582
-	 * @deprecated 20.0.0
1583
-	 */
1584
-	public function getMailer() {
1585
-		return $this->get(IMailer::class);
1586
-	}
1587
-
1588
-	/**
1589
-	 * Get the webroot
1590
-	 *
1591
-	 * @return string
1592
-	 * @deprecated 20.0.0
1593
-	 */
1594
-	public function getWebRoot() {
1595
-		return $this->webRoot;
1596
-	}
1597
-
1598
-	/**
1599
-	 * Get the locking provider
1600
-	 *
1601
-	 * @return ILockingProvider
1602
-	 * @since 8.1.0
1603
-	 * @deprecated 20.0.0
1604
-	 */
1605
-	public function getLockingProvider() {
1606
-		return $this->get(ILockingProvider::class);
1607
-	}
1608
-
1609
-	/**
1610
-	 * Get the MimeTypeDetector
1611
-	 *
1612
-	 * @return IMimeTypeDetector
1613
-	 * @deprecated 20.0.0
1614
-	 */
1615
-	public function getMimeTypeDetector() {
1616
-		return $this->get(IMimeTypeDetector::class);
1617
-	}
1618
-
1619
-	/**
1620
-	 * Get the MimeTypeLoader
1621
-	 *
1622
-	 * @return IMimeTypeLoader
1623
-	 * @deprecated 20.0.0
1624
-	 */
1625
-	public function getMimeTypeLoader() {
1626
-		return $this->get(IMimeTypeLoader::class);
1627
-	}
1628
-
1629
-	/**
1630
-	 * Get the Notification Manager
1631
-	 *
1632
-	 * @return \OCP\Notification\IManager
1633
-	 * @since 8.2.0
1634
-	 * @deprecated 20.0.0
1635
-	 */
1636
-	public function getNotificationManager() {
1637
-		return $this->get(\OCP\Notification\IManager::class);
1638
-	}
1639
-
1640
-	/**
1641
-	 * @return \OCA\Theming\ThemingDefaults
1642
-	 * @deprecated 20.0.0
1643
-	 */
1644
-	public function getThemingDefaults() {
1645
-		return $this->get('ThemingDefaults');
1646
-	}
1647
-
1648
-	/**
1649
-	 * @return \OC\IntegrityCheck\Checker
1650
-	 * @deprecated 20.0.0
1651
-	 */
1652
-	public function getIntegrityCodeChecker() {
1653
-		return $this->get('IntegrityCodeChecker');
1654
-	}
1655
-
1656
-	/**
1657
-	 * @return CsrfTokenManager
1658
-	 * @deprecated 20.0.0
1659
-	 */
1660
-	public function getCsrfTokenManager() {
1661
-		return $this->get(CsrfTokenManager::class);
1662
-	}
1663
-
1664
-	/**
1665
-	 * @return ContentSecurityPolicyNonceManager
1666
-	 * @deprecated 20.0.0
1667
-	 */
1668
-	public function getContentSecurityPolicyNonceManager() {
1669
-		return $this->get(ContentSecurityPolicyNonceManager::class);
1670
-	}
1671
-
1672
-	/**
1673
-	 * @return \OCP\Settings\IManager
1674
-	 * @deprecated 20.0.0
1675
-	 */
1676
-	public function getSettingsManager() {
1677
-		return $this->get(\OC\Settings\Manager::class);
1678
-	}
1679
-
1680
-	/**
1681
-	 * @return \OCP\Files\IAppData
1682
-	 * @deprecated 20.0.0 Use get(\OCP\Files\AppData\IAppDataFactory::class)->get($app) instead
1683
-	 */
1684
-	public function getAppDataDir($app) {
1685
-		$factory = $this->get(\OC\Files\AppData\Factory::class);
1686
-		return $factory->get($app);
1687
-	}
1688
-
1689
-	/**
1690
-	 * @return \OCP\Federation\ICloudIdManager
1691
-	 * @deprecated 20.0.0
1692
-	 */
1693
-	public function getCloudIdManager() {
1694
-		return $this->get(ICloudIdManager::class);
1695
-	}
1278
+        $this->registerAlias(\OCP\Security\Ip\IFactory::class, \OC\Security\Ip\Factory::class);
1279
+
1280
+        $this->registerAlias(IRichTextFormatter::class, \OC\RichObjectStrings\RichTextFormatter::class);
1281
+
1282
+        $this->registerAlias(ISignatureManager::class, SignatureManager::class);
1283
+
1284
+        $this->connectDispatcher();
1285
+    }
1286
+
1287
+    public function boot() {
1288
+        /** @var HookConnector $hookConnector */
1289
+        $hookConnector = $this->get(HookConnector::class);
1290
+        $hookConnector->viewToNode();
1291
+    }
1292
+
1293
+    private function connectDispatcher(): void {
1294
+        /** @var IEventDispatcher $eventDispatcher */
1295
+        $eventDispatcher = $this->get(IEventDispatcher::class);
1296
+        $eventDispatcher->addServiceListener(LoginFailed::class, LoginFailedListener::class);
1297
+        $eventDispatcher->addServiceListener(PostLoginEvent::class, UserLoggedInListener::class);
1298
+        $eventDispatcher->addServiceListener(UserChangedEvent::class, UserChangedListener::class);
1299
+        $eventDispatcher->addServiceListener(BeforeUserDeletedEvent::class, BeforeUserDeletedListener::class);
1300
+
1301
+        FilesMetadataManager::loadListeners($eventDispatcher);
1302
+        GenerateBlurhashMetadata::loadListeners($eventDispatcher);
1303
+    }
1304
+
1305
+    /**
1306
+     * @return \OCP\Contacts\IManager
1307
+     * @deprecated 20.0.0
1308
+     */
1309
+    public function getContactsManager() {
1310
+        return $this->get(\OCP\Contacts\IManager::class);
1311
+    }
1312
+
1313
+    /**
1314
+     * @return \OC\Encryption\Manager
1315
+     * @deprecated 20.0.0
1316
+     */
1317
+    public function getEncryptionManager() {
1318
+        return $this->get(\OCP\Encryption\IManager::class);
1319
+    }
1320
+
1321
+    /**
1322
+     * @return \OC\Encryption\File
1323
+     * @deprecated 20.0.0
1324
+     */
1325
+    public function getEncryptionFilesHelper() {
1326
+        return $this->get(IFile::class);
1327
+    }
1328
+
1329
+    /**
1330
+     * The current request object holding all information about the request
1331
+     * currently being processed is returned from this method.
1332
+     * In case the current execution was not initiated by a web request null is returned
1333
+     *
1334
+     * @return \OCP\IRequest
1335
+     * @deprecated 20.0.0
1336
+     */
1337
+    public function getRequest() {
1338
+        return $this->get(IRequest::class);
1339
+    }
1340
+
1341
+    /**
1342
+     * Returns the root folder of ownCloud's data directory
1343
+     *
1344
+     * @return IRootFolder
1345
+     * @deprecated 20.0.0
1346
+     */
1347
+    public function getRootFolder() {
1348
+        return $this->get(IRootFolder::class);
1349
+    }
1350
+
1351
+    /**
1352
+     * Returns the root folder of ownCloud's data directory
1353
+     * This is the lazy variant so this gets only initialized once it
1354
+     * is actually used.
1355
+     *
1356
+     * @return IRootFolder
1357
+     * @deprecated 20.0.0
1358
+     */
1359
+    public function getLazyRootFolder() {
1360
+        return $this->get(IRootFolder::class);
1361
+    }
1362
+
1363
+    /**
1364
+     * Returns a view to ownCloud's files folder
1365
+     *
1366
+     * @param string $userId user ID
1367
+     * @return \OCP\Files\Folder|null
1368
+     * @deprecated 20.0.0
1369
+     */
1370
+    public function getUserFolder($userId = null) {
1371
+        if ($userId === null) {
1372
+            $user = $this->get(IUserSession::class)->getUser();
1373
+            if (!$user) {
1374
+                return null;
1375
+            }
1376
+            $userId = $user->getUID();
1377
+        }
1378
+        $root = $this->get(IRootFolder::class);
1379
+        return $root->getUserFolder($userId);
1380
+    }
1381
+
1382
+    /**
1383
+     * @return \OC\User\Manager
1384
+     * @deprecated 20.0.0
1385
+     */
1386
+    public function getUserManager() {
1387
+        return $this->get(IUserManager::class);
1388
+    }
1389
+
1390
+    /**
1391
+     * @return \OC\Group\Manager
1392
+     * @deprecated 20.0.0
1393
+     */
1394
+    public function getGroupManager() {
1395
+        return $this->get(IGroupManager::class);
1396
+    }
1397
+
1398
+    /**
1399
+     * @return \OC\User\Session
1400
+     * @deprecated 20.0.0
1401
+     */
1402
+    public function getUserSession() {
1403
+        return $this->get(IUserSession::class);
1404
+    }
1405
+
1406
+    /**
1407
+     * @return \OCP\ISession
1408
+     * @deprecated 20.0.0
1409
+     */
1410
+    public function getSession() {
1411
+        return $this->get(Session::class)->getSession();
1412
+    }
1413
+
1414
+    /**
1415
+     * @param \OCP\ISession $session
1416
+     * @return void
1417
+     */
1418
+    public function setSession(\OCP\ISession $session) {
1419
+        $this->get(SessionStorage::class)->setSession($session);
1420
+        $this->get(Session::class)->setSession($session);
1421
+        $this->get(Store::class)->setSession($session);
1422
+    }
1423
+
1424
+    /**
1425
+     * @return \OCP\IConfig
1426
+     * @deprecated 20.0.0
1427
+     */
1428
+    public function getConfig() {
1429
+        return $this->get(AllConfig::class);
1430
+    }
1431
+
1432
+    /**
1433
+     * @return \OC\SystemConfig
1434
+     * @deprecated 20.0.0
1435
+     */
1436
+    public function getSystemConfig() {
1437
+        return $this->get(SystemConfig::class);
1438
+    }
1439
+
1440
+    /**
1441
+     * @return IFactory
1442
+     * @deprecated 20.0.0
1443
+     */
1444
+    public function getL10NFactory() {
1445
+        return $this->get(IFactory::class);
1446
+    }
1447
+
1448
+    /**
1449
+     * get an L10N instance
1450
+     *
1451
+     * @param string $app appid
1452
+     * @param string $lang
1453
+     * @return IL10N
1454
+     * @deprecated 20.0.0 use DI of {@see IL10N} or {@see IFactory} instead, or {@see \OCP\Util::getL10N()} as a last resort
1455
+     */
1456
+    public function getL10N($app, $lang = null) {
1457
+        return $this->get(IFactory::class)->get($app, $lang);
1458
+    }
1459
+
1460
+    /**
1461
+     * @return IURLGenerator
1462
+     * @deprecated 20.0.0
1463
+     */
1464
+    public function getURLGenerator() {
1465
+        return $this->get(IURLGenerator::class);
1466
+    }
1467
+
1468
+    /**
1469
+     * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1470
+     * getMemCacheFactory() instead.
1471
+     *
1472
+     * @return ICache
1473
+     * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1474
+     */
1475
+    public function getCache() {
1476
+        return $this->get(ICache::class);
1477
+    }
1478
+
1479
+    /**
1480
+     * Returns an \OCP\CacheFactory instance
1481
+     *
1482
+     * @return \OCP\ICacheFactory
1483
+     * @deprecated 20.0.0
1484
+     */
1485
+    public function getMemCacheFactory() {
1486
+        return $this->get(ICacheFactory::class);
1487
+    }
1488
+
1489
+    /**
1490
+     * Returns the current session
1491
+     *
1492
+     * @return \OCP\IDBConnection
1493
+     * @deprecated 20.0.0
1494
+     */
1495
+    public function getDatabaseConnection() {
1496
+        return $this->get(IDBConnection::class);
1497
+    }
1498
+
1499
+    /**
1500
+     * Returns the activity manager
1501
+     *
1502
+     * @return \OCP\Activity\IManager
1503
+     * @deprecated 20.0.0
1504
+     */
1505
+    public function getActivityManager() {
1506
+        return $this->get(\OCP\Activity\IManager::class);
1507
+    }
1508
+
1509
+    /**
1510
+     * Returns an job list for controlling background jobs
1511
+     *
1512
+     * @return IJobList
1513
+     * @deprecated 20.0.0
1514
+     */
1515
+    public function getJobList() {
1516
+        return $this->get(IJobList::class);
1517
+    }
1518
+
1519
+    /**
1520
+     * Returns a SecureRandom instance
1521
+     *
1522
+     * @return \OCP\Security\ISecureRandom
1523
+     * @deprecated 20.0.0
1524
+     */
1525
+    public function getSecureRandom() {
1526
+        return $this->get(ISecureRandom::class);
1527
+    }
1528
+
1529
+    /**
1530
+     * Returns a Crypto instance
1531
+     *
1532
+     * @return ICrypto
1533
+     * @deprecated 20.0.0
1534
+     */
1535
+    public function getCrypto() {
1536
+        return $this->get(ICrypto::class);
1537
+    }
1538
+
1539
+    /**
1540
+     * Returns a Hasher instance
1541
+     *
1542
+     * @return IHasher
1543
+     * @deprecated 20.0.0
1544
+     */
1545
+    public function getHasher() {
1546
+        return $this->get(IHasher::class);
1547
+    }
1548
+
1549
+    /**
1550
+     * Get the certificate manager
1551
+     *
1552
+     * @return \OCP\ICertificateManager
1553
+     */
1554
+    public function getCertificateManager() {
1555
+        return $this->get(ICertificateManager::class);
1556
+    }
1557
+
1558
+    /**
1559
+     * Get the manager for temporary files and folders
1560
+     *
1561
+     * @return \OCP\ITempManager
1562
+     * @deprecated 20.0.0
1563
+     */
1564
+    public function getTempManager() {
1565
+        return $this->get(ITempManager::class);
1566
+    }
1567
+
1568
+    /**
1569
+     * Get the app manager
1570
+     *
1571
+     * @return \OCP\App\IAppManager
1572
+     * @deprecated 20.0.0
1573
+     */
1574
+    public function getAppManager() {
1575
+        return $this->get(IAppManager::class);
1576
+    }
1577
+
1578
+    /**
1579
+     * Creates a new mailer
1580
+     *
1581
+     * @return IMailer
1582
+     * @deprecated 20.0.0
1583
+     */
1584
+    public function getMailer() {
1585
+        return $this->get(IMailer::class);
1586
+    }
1587
+
1588
+    /**
1589
+     * Get the webroot
1590
+     *
1591
+     * @return string
1592
+     * @deprecated 20.0.0
1593
+     */
1594
+    public function getWebRoot() {
1595
+        return $this->webRoot;
1596
+    }
1597
+
1598
+    /**
1599
+     * Get the locking provider
1600
+     *
1601
+     * @return ILockingProvider
1602
+     * @since 8.1.0
1603
+     * @deprecated 20.0.0
1604
+     */
1605
+    public function getLockingProvider() {
1606
+        return $this->get(ILockingProvider::class);
1607
+    }
1608
+
1609
+    /**
1610
+     * Get the MimeTypeDetector
1611
+     *
1612
+     * @return IMimeTypeDetector
1613
+     * @deprecated 20.0.0
1614
+     */
1615
+    public function getMimeTypeDetector() {
1616
+        return $this->get(IMimeTypeDetector::class);
1617
+    }
1618
+
1619
+    /**
1620
+     * Get the MimeTypeLoader
1621
+     *
1622
+     * @return IMimeTypeLoader
1623
+     * @deprecated 20.0.0
1624
+     */
1625
+    public function getMimeTypeLoader() {
1626
+        return $this->get(IMimeTypeLoader::class);
1627
+    }
1628
+
1629
+    /**
1630
+     * Get the Notification Manager
1631
+     *
1632
+     * @return \OCP\Notification\IManager
1633
+     * @since 8.2.0
1634
+     * @deprecated 20.0.0
1635
+     */
1636
+    public function getNotificationManager() {
1637
+        return $this->get(\OCP\Notification\IManager::class);
1638
+    }
1639
+
1640
+    /**
1641
+     * @return \OCA\Theming\ThemingDefaults
1642
+     * @deprecated 20.0.0
1643
+     */
1644
+    public function getThemingDefaults() {
1645
+        return $this->get('ThemingDefaults');
1646
+    }
1647
+
1648
+    /**
1649
+     * @return \OC\IntegrityCheck\Checker
1650
+     * @deprecated 20.0.0
1651
+     */
1652
+    public function getIntegrityCodeChecker() {
1653
+        return $this->get('IntegrityCodeChecker');
1654
+    }
1655
+
1656
+    /**
1657
+     * @return CsrfTokenManager
1658
+     * @deprecated 20.0.0
1659
+     */
1660
+    public function getCsrfTokenManager() {
1661
+        return $this->get(CsrfTokenManager::class);
1662
+    }
1663
+
1664
+    /**
1665
+     * @return ContentSecurityPolicyNonceManager
1666
+     * @deprecated 20.0.0
1667
+     */
1668
+    public function getContentSecurityPolicyNonceManager() {
1669
+        return $this->get(ContentSecurityPolicyNonceManager::class);
1670
+    }
1671
+
1672
+    /**
1673
+     * @return \OCP\Settings\IManager
1674
+     * @deprecated 20.0.0
1675
+     */
1676
+    public function getSettingsManager() {
1677
+        return $this->get(\OC\Settings\Manager::class);
1678
+    }
1679
+
1680
+    /**
1681
+     * @return \OCP\Files\IAppData
1682
+     * @deprecated 20.0.0 Use get(\OCP\Files\AppData\IAppDataFactory::class)->get($app) instead
1683
+     */
1684
+    public function getAppDataDir($app) {
1685
+        $factory = $this->get(\OC\Files\AppData\Factory::class);
1686
+        return $factory->get($app);
1687
+    }
1688
+
1689
+    /**
1690
+     * @return \OCP\Federation\ICloudIdManager
1691
+     * @deprecated 20.0.0
1692
+     */
1693
+    public function getCloudIdManager() {
1694
+        return $this->get(ICloudIdManager::class);
1695
+    }
1696 1696
 }
Please login to merge, or discard this patch.
lib/private/Activity/Manager.php 1 patch
Indentation   +350 added lines, -350 removed lines patch added patch discarded remove patch
@@ -29,354 +29,354 @@
 block discarded – undo
29 29
 
30 30
 class Manager implements IManager {
31 31
 
32
-	/** @var string */
33
-	protected $formattingObjectType;
34
-
35
-	/** @var int */
36
-	protected $formattingObjectId;
37
-
38
-	/** @var bool */
39
-	protected $requirePNG = false;
40
-
41
-	/** @var string */
42
-	protected $currentUserId;
43
-
44
-	public function __construct(
45
-		protected IRequest $request,
46
-		protected IUserSession $session,
47
-		protected IConfig $config,
48
-		protected IValidator $validator,
49
-		protected IRichTextFormatter $richTextFormatter,
50
-		protected IL10N $l10n,
51
-		protected ITimeFactory $timeFactory,
52
-	) {
53
-	}
54
-
55
-	/** @var \Closure[] */
56
-	private $consumersClosures = [];
57
-
58
-	/** @var IConsumer[] */
59
-	private $consumers = [];
60
-
61
-	/**
62
-	 * @return \OCP\Activity\IConsumer[]
63
-	 */
64
-	protected function getConsumers(): array {
65
-		if (!empty($this->consumers)) {
66
-			return $this->consumers;
67
-		}
68
-
69
-		$this->consumers = [];
70
-		foreach ($this->consumersClosures as $consumer) {
71
-			$c = $consumer();
72
-			if ($c instanceof IConsumer) {
73
-				$this->consumers[] = $c;
74
-			} else {
75
-				throw new \InvalidArgumentException('The given consumer does not implement the \OCP\Activity\IConsumer interface');
76
-			}
77
-		}
78
-
79
-		return $this->consumers;
80
-	}
81
-
82
-	/**
83
-	 * Generates a new IEvent object
84
-	 *
85
-	 * Make sure to call at least the following methods before sending it to the
86
-	 * app with via the publish() method:
87
-	 *  - setApp()
88
-	 *  - setType()
89
-	 *  - setAffectedUser()
90
-	 *  - setSubject()
91
-	 *
92
-	 * @return IEvent
93
-	 */
94
-	public function generateEvent(): IEvent {
95
-		return new Event($this->validator, $this->richTextFormatter);
96
-	}
97
-
98
-	/**
99
-	 * {@inheritDoc}
100
-	 */
101
-	public function publish(IEvent $event): void {
102
-		if ($event->getAuthor() === '' && $this->session->getUser() instanceof IUser) {
103
-			$event->setAuthor($this->session->getUser()->getUID());
104
-		}
105
-
106
-		if (!$event->getTimestamp()) {
107
-			$event->setTimestamp($this->timeFactory->getTime());
108
-		}
109
-
110
-		if ($event->getAffectedUser() === '' || !$event->isValid()) {
111
-			throw new IncompleteActivityException('The given event is invalid');
112
-		}
113
-
114
-		foreach ($this->getConsumers() as $c) {
115
-			$c->receive($event);
116
-		}
117
-	}
118
-
119
-	/**
120
-	 * {@inheritDoc}
121
-	 */
122
-	public function bulkPublish(IEvent $event, array $affectedUserIds, ISetting $setting): void {
123
-		if (empty($affectedUserIds)) {
124
-			throw new IncompleteActivityException('The given event is invalid');
125
-		}
126
-
127
-		if ($event->getAuthor() === '') {
128
-			if ($this->session->getUser() instanceof IUser) {
129
-				$event->setAuthor($this->session->getUser()->getUID());
130
-			}
131
-		}
132
-
133
-		if (!$event->getTimestamp()) {
134
-			$event->setTimestamp($this->timeFactory->getTime());
135
-		}
136
-
137
-		if (!$event->isValid()) {
138
-			throw new IncompleteActivityException('The given event is invalid');
139
-		}
140
-
141
-		foreach ($this->getConsumers() as $c) {
142
-			if ($c instanceof IBulkConsumer) {
143
-				$c->bulkReceive($event, $affectedUserIds, $setting);
144
-			}
145
-			foreach ($affectedUserIds as $affectedUserId) {
146
-				$event->setAffectedUser($affectedUserId);
147
-				$c->receive($event);
148
-			}
149
-		}
150
-	}
151
-
152
-
153
-	/**
154
-	 * In order to improve lazy loading a closure can be registered which will be called in case
155
-	 * activity consumers are actually requested
156
-	 *
157
-	 * $callable has to return an instance of OCA\Activity\IConsumer
158
-	 *
159
-	 * @param \Closure $callable
160
-	 */
161
-	public function registerConsumer(\Closure $callable): void {
162
-		$this->consumersClosures[] = $callable;
163
-		$this->consumers = [];
164
-	}
165
-
166
-	/** @var string[] */
167
-	protected $filterClasses = [];
168
-
169
-	/** @var IFilter[] */
170
-	protected $filters = [];
171
-
172
-	/**
173
-	 * @param string $filter Class must implement OCA\Activity\IFilter
174
-	 * @return void
175
-	 */
176
-	public function registerFilter(string $filter): void {
177
-		$this->filterClasses[$filter] = false;
178
-	}
179
-
180
-	/**
181
-	 * @return IFilter[]
182
-	 * @throws \InvalidArgumentException
183
-	 */
184
-	public function getFilters(): array {
185
-		foreach ($this->filterClasses as $class => $false) {
186
-			/** @var IFilter $filter */
187
-			$filter = \OCP\Server::get($class);
188
-
189
-			if (!$filter instanceof IFilter) {
190
-				throw new \InvalidArgumentException('Invalid activity filter registered');
191
-			}
192
-
193
-			$this->filters[$filter->getIdentifier()] = $filter;
194
-
195
-			unset($this->filterClasses[$class]);
196
-		}
197
-		return $this->filters;
198
-	}
199
-
200
-	/**
201
-	 * {@inheritDoc}
202
-	 */
203
-	public function getFilterById(string $id): IFilter {
204
-		$filters = $this->getFilters();
205
-
206
-		if (isset($filters[$id])) {
207
-			return $filters[$id];
208
-		}
209
-
210
-		throw new FilterNotFoundException($id);
211
-	}
212
-
213
-	/** @var string[] */
214
-	protected $providerClasses = [];
215
-
216
-	/** @var IProvider[] */
217
-	protected $providers = [];
218
-
219
-	/**
220
-	 * @param string $provider Class must implement OCA\Activity\IProvider
221
-	 * @return void
222
-	 */
223
-	public function registerProvider(string $provider): void {
224
-		$this->providerClasses[$provider] = false;
225
-	}
226
-
227
-	/**
228
-	 * @return IProvider[]
229
-	 * @throws \InvalidArgumentException
230
-	 */
231
-	public function getProviders(): array {
232
-		foreach ($this->providerClasses as $class => $false) {
233
-			/** @var IProvider $provider */
234
-			$provider = \OCP\Server::get($class);
235
-
236
-			if (!$provider instanceof IProvider) {
237
-				throw new \InvalidArgumentException('Invalid activity provider registered');
238
-			}
239
-
240
-			$this->providers[] = $provider;
241
-
242
-			unset($this->providerClasses[$class]);
243
-		}
244
-		return $this->providers;
245
-	}
246
-
247
-	/** @var string[] */
248
-	protected $settingsClasses = [];
249
-
250
-	/** @var ISetting[] */
251
-	protected $settings = [];
252
-
253
-	/**
254
-	 * @param string $setting Class must implement OCA\Activity\ISetting
255
-	 * @return void
256
-	 */
257
-	public function registerSetting(string $setting): void {
258
-		$this->settingsClasses[$setting] = false;
259
-	}
260
-
261
-	/**
262
-	 * @return ActivitySettings[]
263
-	 * @throws \InvalidArgumentException
264
-	 */
265
-	public function getSettings(): array {
266
-		foreach ($this->settingsClasses as $class => $false) {
267
-			/** @var ISetting $setting */
268
-			$setting = \OCP\Server::get($class);
269
-
270
-			if ($setting instanceof ISetting) {
271
-				if (!$setting instanceof ActivitySettings) {
272
-					$setting = new ActivitySettingsAdapter($setting, $this->l10n);
273
-				}
274
-			} else {
275
-				throw new \InvalidArgumentException('Invalid activity filter registered');
276
-			}
277
-
278
-			$this->settings[$setting->getIdentifier()] = $setting;
279
-
280
-			unset($this->settingsClasses[$class]);
281
-		}
282
-		return $this->settings;
283
-	}
284
-
285
-	/**
286
-	 * {@inheritDoc}
287
-	 */
288
-	public function getSettingById(string $id): ActivitySettings {
289
-		$settings = $this->getSettings();
290
-
291
-		if (isset($settings[$id])) {
292
-			return $settings[$id];
293
-		}
294
-
295
-		throw new SettingNotFoundException($id);
296
-	}
297
-
298
-
299
-	/**
300
-	 * @param string $type
301
-	 * @param int $id
302
-	 */
303
-	public function setFormattingObject(string $type, int $id): void {
304
-		$this->formattingObjectType = $type;
305
-		$this->formattingObjectId = $id;
306
-	}
307
-
308
-	/**
309
-	 * @return bool
310
-	 */
311
-	public function isFormattingFilteredObject(): bool {
312
-		return $this->formattingObjectType !== null && $this->formattingObjectId !== null
313
-			&& $this->formattingObjectType === $this->request->getParam('object_type')
314
-			&& $this->formattingObjectId === (int)$this->request->getParam('object_id');
315
-	}
316
-
317
-	/**
318
-	 * @param bool $status Set to true, when parsing events should not use SVG icons
319
-	 */
320
-	public function setRequirePNG(bool $status): void {
321
-		$this->requirePNG = $status;
322
-	}
323
-
324
-	/**
325
-	 * @return bool
326
-	 */
327
-	public function getRequirePNG(): bool {
328
-		return $this->requirePNG;
329
-	}
330
-
331
-	/**
332
-	 * Set the user we need to use
333
-	 *
334
-	 * @param string|null $currentUserId
335
-	 */
336
-	public function setCurrentUserId(?string $currentUserId = null): void {
337
-		$this->currentUserId = $currentUserId;
338
-	}
339
-
340
-	/**
341
-	 * Get the user we need to use
342
-	 *
343
-	 * Either the user is logged in, or we try to get it from the token
344
-	 *
345
-	 * @return string
346
-	 * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique
347
-	 */
348
-	public function getCurrentUserId(): string {
349
-		if ($this->currentUserId !== null) {
350
-			return $this->currentUserId;
351
-		}
352
-
353
-		if (!$this->session->isLoggedIn()) {
354
-			return $this->getUserFromToken();
355
-		}
356
-
357
-		return $this->session->getUser()->getUID();
358
-	}
359
-
360
-	/**
361
-	 * Get the user for the token
362
-	 *
363
-	 * @return string
364
-	 * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique
365
-	 */
366
-	protected function getUserFromToken(): string {
367
-		$token = (string)$this->request->getParam('token', '');
368
-		if (strlen($token) !== 30) {
369
-			throw new \UnexpectedValueException('The token is invalid');
370
-		}
371
-
372
-		$users = $this->config->getUsersForUserValue('activity', 'rsstoken', $token);
373
-
374
-		if (count($users) !== 1) {
375
-			// No unique user found
376
-			throw new \UnexpectedValueException('The token is invalid');
377
-		}
378
-
379
-		// Token found login as that user
380
-		return array_shift($users);
381
-	}
32
+    /** @var string */
33
+    protected $formattingObjectType;
34
+
35
+    /** @var int */
36
+    protected $formattingObjectId;
37
+
38
+    /** @var bool */
39
+    protected $requirePNG = false;
40
+
41
+    /** @var string */
42
+    protected $currentUserId;
43
+
44
+    public function __construct(
45
+        protected IRequest $request,
46
+        protected IUserSession $session,
47
+        protected IConfig $config,
48
+        protected IValidator $validator,
49
+        protected IRichTextFormatter $richTextFormatter,
50
+        protected IL10N $l10n,
51
+        protected ITimeFactory $timeFactory,
52
+    ) {
53
+    }
54
+
55
+    /** @var \Closure[] */
56
+    private $consumersClosures = [];
57
+
58
+    /** @var IConsumer[] */
59
+    private $consumers = [];
60
+
61
+    /**
62
+     * @return \OCP\Activity\IConsumer[]
63
+     */
64
+    protected function getConsumers(): array {
65
+        if (!empty($this->consumers)) {
66
+            return $this->consumers;
67
+        }
68
+
69
+        $this->consumers = [];
70
+        foreach ($this->consumersClosures as $consumer) {
71
+            $c = $consumer();
72
+            if ($c instanceof IConsumer) {
73
+                $this->consumers[] = $c;
74
+            } else {
75
+                throw new \InvalidArgumentException('The given consumer does not implement the \OCP\Activity\IConsumer interface');
76
+            }
77
+        }
78
+
79
+        return $this->consumers;
80
+    }
81
+
82
+    /**
83
+     * Generates a new IEvent object
84
+     *
85
+     * Make sure to call at least the following methods before sending it to the
86
+     * app with via the publish() method:
87
+     *  - setApp()
88
+     *  - setType()
89
+     *  - setAffectedUser()
90
+     *  - setSubject()
91
+     *
92
+     * @return IEvent
93
+     */
94
+    public function generateEvent(): IEvent {
95
+        return new Event($this->validator, $this->richTextFormatter);
96
+    }
97
+
98
+    /**
99
+     * {@inheritDoc}
100
+     */
101
+    public function publish(IEvent $event): void {
102
+        if ($event->getAuthor() === '' && $this->session->getUser() instanceof IUser) {
103
+            $event->setAuthor($this->session->getUser()->getUID());
104
+        }
105
+
106
+        if (!$event->getTimestamp()) {
107
+            $event->setTimestamp($this->timeFactory->getTime());
108
+        }
109
+
110
+        if ($event->getAffectedUser() === '' || !$event->isValid()) {
111
+            throw new IncompleteActivityException('The given event is invalid');
112
+        }
113
+
114
+        foreach ($this->getConsumers() as $c) {
115
+            $c->receive($event);
116
+        }
117
+    }
118
+
119
+    /**
120
+     * {@inheritDoc}
121
+     */
122
+    public function bulkPublish(IEvent $event, array $affectedUserIds, ISetting $setting): void {
123
+        if (empty($affectedUserIds)) {
124
+            throw new IncompleteActivityException('The given event is invalid');
125
+        }
126
+
127
+        if ($event->getAuthor() === '') {
128
+            if ($this->session->getUser() instanceof IUser) {
129
+                $event->setAuthor($this->session->getUser()->getUID());
130
+            }
131
+        }
132
+
133
+        if (!$event->getTimestamp()) {
134
+            $event->setTimestamp($this->timeFactory->getTime());
135
+        }
136
+
137
+        if (!$event->isValid()) {
138
+            throw new IncompleteActivityException('The given event is invalid');
139
+        }
140
+
141
+        foreach ($this->getConsumers() as $c) {
142
+            if ($c instanceof IBulkConsumer) {
143
+                $c->bulkReceive($event, $affectedUserIds, $setting);
144
+            }
145
+            foreach ($affectedUserIds as $affectedUserId) {
146
+                $event->setAffectedUser($affectedUserId);
147
+                $c->receive($event);
148
+            }
149
+        }
150
+    }
151
+
152
+
153
+    /**
154
+     * In order to improve lazy loading a closure can be registered which will be called in case
155
+     * activity consumers are actually requested
156
+     *
157
+     * $callable has to return an instance of OCA\Activity\IConsumer
158
+     *
159
+     * @param \Closure $callable
160
+     */
161
+    public function registerConsumer(\Closure $callable): void {
162
+        $this->consumersClosures[] = $callable;
163
+        $this->consumers = [];
164
+    }
165
+
166
+    /** @var string[] */
167
+    protected $filterClasses = [];
168
+
169
+    /** @var IFilter[] */
170
+    protected $filters = [];
171
+
172
+    /**
173
+     * @param string $filter Class must implement OCA\Activity\IFilter
174
+     * @return void
175
+     */
176
+    public function registerFilter(string $filter): void {
177
+        $this->filterClasses[$filter] = false;
178
+    }
179
+
180
+    /**
181
+     * @return IFilter[]
182
+     * @throws \InvalidArgumentException
183
+     */
184
+    public function getFilters(): array {
185
+        foreach ($this->filterClasses as $class => $false) {
186
+            /** @var IFilter $filter */
187
+            $filter = \OCP\Server::get($class);
188
+
189
+            if (!$filter instanceof IFilter) {
190
+                throw new \InvalidArgumentException('Invalid activity filter registered');
191
+            }
192
+
193
+            $this->filters[$filter->getIdentifier()] = $filter;
194
+
195
+            unset($this->filterClasses[$class]);
196
+        }
197
+        return $this->filters;
198
+    }
199
+
200
+    /**
201
+     * {@inheritDoc}
202
+     */
203
+    public function getFilterById(string $id): IFilter {
204
+        $filters = $this->getFilters();
205
+
206
+        if (isset($filters[$id])) {
207
+            return $filters[$id];
208
+        }
209
+
210
+        throw new FilterNotFoundException($id);
211
+    }
212
+
213
+    /** @var string[] */
214
+    protected $providerClasses = [];
215
+
216
+    /** @var IProvider[] */
217
+    protected $providers = [];
218
+
219
+    /**
220
+     * @param string $provider Class must implement OCA\Activity\IProvider
221
+     * @return void
222
+     */
223
+    public function registerProvider(string $provider): void {
224
+        $this->providerClasses[$provider] = false;
225
+    }
226
+
227
+    /**
228
+     * @return IProvider[]
229
+     * @throws \InvalidArgumentException
230
+     */
231
+    public function getProviders(): array {
232
+        foreach ($this->providerClasses as $class => $false) {
233
+            /** @var IProvider $provider */
234
+            $provider = \OCP\Server::get($class);
235
+
236
+            if (!$provider instanceof IProvider) {
237
+                throw new \InvalidArgumentException('Invalid activity provider registered');
238
+            }
239
+
240
+            $this->providers[] = $provider;
241
+
242
+            unset($this->providerClasses[$class]);
243
+        }
244
+        return $this->providers;
245
+    }
246
+
247
+    /** @var string[] */
248
+    protected $settingsClasses = [];
249
+
250
+    /** @var ISetting[] */
251
+    protected $settings = [];
252
+
253
+    /**
254
+     * @param string $setting Class must implement OCA\Activity\ISetting
255
+     * @return void
256
+     */
257
+    public function registerSetting(string $setting): void {
258
+        $this->settingsClasses[$setting] = false;
259
+    }
260
+
261
+    /**
262
+     * @return ActivitySettings[]
263
+     * @throws \InvalidArgumentException
264
+     */
265
+    public function getSettings(): array {
266
+        foreach ($this->settingsClasses as $class => $false) {
267
+            /** @var ISetting $setting */
268
+            $setting = \OCP\Server::get($class);
269
+
270
+            if ($setting instanceof ISetting) {
271
+                if (!$setting instanceof ActivitySettings) {
272
+                    $setting = new ActivitySettingsAdapter($setting, $this->l10n);
273
+                }
274
+            } else {
275
+                throw new \InvalidArgumentException('Invalid activity filter registered');
276
+            }
277
+
278
+            $this->settings[$setting->getIdentifier()] = $setting;
279
+
280
+            unset($this->settingsClasses[$class]);
281
+        }
282
+        return $this->settings;
283
+    }
284
+
285
+    /**
286
+     * {@inheritDoc}
287
+     */
288
+    public function getSettingById(string $id): ActivitySettings {
289
+        $settings = $this->getSettings();
290
+
291
+        if (isset($settings[$id])) {
292
+            return $settings[$id];
293
+        }
294
+
295
+        throw new SettingNotFoundException($id);
296
+    }
297
+
298
+
299
+    /**
300
+     * @param string $type
301
+     * @param int $id
302
+     */
303
+    public function setFormattingObject(string $type, int $id): void {
304
+        $this->formattingObjectType = $type;
305
+        $this->formattingObjectId = $id;
306
+    }
307
+
308
+    /**
309
+     * @return bool
310
+     */
311
+    public function isFormattingFilteredObject(): bool {
312
+        return $this->formattingObjectType !== null && $this->formattingObjectId !== null
313
+            && $this->formattingObjectType === $this->request->getParam('object_type')
314
+            && $this->formattingObjectId === (int)$this->request->getParam('object_id');
315
+    }
316
+
317
+    /**
318
+     * @param bool $status Set to true, when parsing events should not use SVG icons
319
+     */
320
+    public function setRequirePNG(bool $status): void {
321
+        $this->requirePNG = $status;
322
+    }
323
+
324
+    /**
325
+     * @return bool
326
+     */
327
+    public function getRequirePNG(): bool {
328
+        return $this->requirePNG;
329
+    }
330
+
331
+    /**
332
+     * Set the user we need to use
333
+     *
334
+     * @param string|null $currentUserId
335
+     */
336
+    public function setCurrentUserId(?string $currentUserId = null): void {
337
+        $this->currentUserId = $currentUserId;
338
+    }
339
+
340
+    /**
341
+     * Get the user we need to use
342
+     *
343
+     * Either the user is logged in, or we try to get it from the token
344
+     *
345
+     * @return string
346
+     * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique
347
+     */
348
+    public function getCurrentUserId(): string {
349
+        if ($this->currentUserId !== null) {
350
+            return $this->currentUserId;
351
+        }
352
+
353
+        if (!$this->session->isLoggedIn()) {
354
+            return $this->getUserFromToken();
355
+        }
356
+
357
+        return $this->session->getUser()->getUID();
358
+    }
359
+
360
+    /**
361
+     * Get the user for the token
362
+     *
363
+     * @return string
364
+     * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique
365
+     */
366
+    protected function getUserFromToken(): string {
367
+        $token = (string)$this->request->getParam('token', '');
368
+        if (strlen($token) !== 30) {
369
+            throw new \UnexpectedValueException('The token is invalid');
370
+        }
371
+
372
+        $users = $this->config->getUsersForUserValue('activity', 'rsstoken', $token);
373
+
374
+        if (count($users) !== 1) {
375
+            // No unique user found
376
+            throw new \UnexpectedValueException('The token is invalid');
377
+        }
378
+
379
+        // Token found login as that user
380
+        return array_shift($users);
381
+    }
382 382
 }
Please login to merge, or discard this patch.
lib/private/Activity/Event.php 1 patch
Indentation   +453 added lines, -453 removed lines patch added patch discarded remove patch
@@ -16,457 +16,457 @@
 block discarded – undo
16 16
 use OCP\RichObjectStrings\IValidator;
17 17
 
18 18
 class Event implements IEvent {
19
-	/** @var string */
20
-	protected $app = '';
21
-	/** @var string */
22
-	protected $type = '';
23
-	/** @var string */
24
-	protected $affectedUser = '';
25
-	/** @var string */
26
-	protected $author = '';
27
-	/** @var int */
28
-	protected $timestamp = 0;
29
-	/** @var string */
30
-	protected $subject = '';
31
-	/** @var array */
32
-	protected $subjectParameters = [];
33
-	/** @var string */
34
-	protected $subjectParsed = '';
35
-	/** @var string */
36
-	protected $subjectRich = '';
37
-	/** @var array<string, array<string, string>> */
38
-	protected $subjectRichParameters = [];
39
-	/** @var string */
40
-	protected $message = '';
41
-	/** @var array */
42
-	protected $messageParameters = [];
43
-	/** @var string */
44
-	protected $messageParsed = '';
45
-	/** @var string */
46
-	protected $messageRich = '';
47
-	/** @var array<string, array<string, string>> */
48
-	protected $messageRichParameters = [];
49
-	/** @var string */
50
-	protected $objectType = '';
51
-	/** @var int */
52
-	protected $objectId = 0;
53
-	/** @var string */
54
-	protected $objectName = '';
55
-	/** @var string */
56
-	protected $link = '';
57
-	/** @var string */
58
-	protected $icon = '';
59
-	/** @var bool */
60
-	protected $generateNotification = true;
61
-
62
-	/** @var IEvent|null */
63
-	protected $child;
64
-
65
-	public function __construct(
66
-		protected IValidator $richValidator,
67
-		protected IRichTextFormatter $richTextFormatter,
68
-	) {
69
-	}
70
-
71
-	/**
72
-	 * {@inheritDoc}
73
-	 */
74
-	public function setApp(string $app): IEvent {
75
-		if ($app === '' || isset($app[32])) {
76
-			throw new InvalidValueException('app');
77
-		}
78
-		$this->app = $app;
79
-		return $this;
80
-	}
81
-
82
-	/**
83
-	 * @return string
84
-	 */
85
-	public function getApp(): string {
86
-		return $this->app;
87
-	}
88
-
89
-	/**
90
-	 * {@inheritDoc}
91
-	 */
92
-	public function setType(string $type): IEvent {
93
-		if ($type === '' || isset($type[255])) {
94
-			throw new InvalidValueException('type');
95
-		}
96
-		$this->type = $type;
97
-		return $this;
98
-	}
99
-
100
-	/**
101
-	 * @return string
102
-	 */
103
-	public function getType(): string {
104
-		return $this->type;
105
-	}
106
-
107
-	/**
108
-	 *  {@inheritDoc}
109
-	 */
110
-	public function setAffectedUser(string $affectedUser): IEvent {
111
-		if ($affectedUser === '' || isset($affectedUser[64])) {
112
-			throw new InvalidValueException('affectedUser');
113
-		}
114
-		$this->affectedUser = $affectedUser;
115
-		return $this;
116
-	}
117
-
118
-	/**
119
-	 * @return string
120
-	 */
121
-	public function getAffectedUser(): string {
122
-		return $this->affectedUser;
123
-	}
124
-
125
-	/**
126
-	 * {@inheritDoc}
127
-	 */
128
-	public function setAuthor(string $author): IEvent {
129
-		if (isset($author[64])) {
130
-			throw new InvalidValueException('author');
131
-		}
132
-		$this->author = $author;
133
-		return $this;
134
-	}
135
-
136
-	/**
137
-	 * @return string
138
-	 */
139
-	public function getAuthor(): string {
140
-		return $this->author;
141
-	}
142
-
143
-	/**
144
-	 * {@inheritDoc}
145
-	 */
146
-	public function setTimestamp(int $timestamp): IEvent {
147
-		if ($timestamp < 0) {
148
-			throw new InvalidValueException('timestamp');
149
-		}
150
-		$this->timestamp = $timestamp;
151
-		return $this;
152
-	}
153
-
154
-	/**
155
-	 * @return int
156
-	 */
157
-	public function getTimestamp(): int {
158
-		return $this->timestamp;
159
-	}
160
-
161
-	/**
162
-	 * {@inheritDoc}
163
-	 */
164
-	public function setSubject(string $subject, array $parameters = []): IEvent {
165
-		if (isset($subject[255])) {
166
-			throw new InvalidValueException('subject');
167
-		}
168
-		$this->subject = $subject;
169
-		$this->subjectParameters = $parameters;
170
-		return $this;
171
-	}
172
-
173
-	/**
174
-	 * @return string
175
-	 */
176
-	public function getSubject(): string {
177
-		return $this->subject;
178
-	}
179
-
180
-	/**
181
-	 * @return array
182
-	 */
183
-	public function getSubjectParameters(): array {
184
-		return $this->subjectParameters;
185
-	}
186
-
187
-	/**
188
-	 * {@inheritDoc}
189
-	 */
190
-	public function setParsedSubject(string $subject): IEvent {
191
-		if ($subject === '') {
192
-			throw new InvalidValueException('parsedSubject');
193
-		}
194
-		$this->subjectParsed = $subject;
195
-		return $this;
196
-	}
197
-
198
-	/**
199
-	 * @return string
200
-	 * @since 11.0.0
201
-	 */
202
-	public function getParsedSubject(): string {
203
-		return $this->subjectParsed;
204
-	}
205
-
206
-	/**
207
-	 * {@inheritDoc}
208
-	 */
209
-	public function setRichSubject(string $subject, array $parameters = []): IEvent {
210
-		if ($subject === '') {
211
-			throw new InvalidValueException('richSubject');
212
-		}
213
-		$this->subjectRich = $subject;
214
-		$this->subjectRichParameters = $parameters;
215
-
216
-		if ($this->subjectParsed === '') {
217
-			try {
218
-				$this->subjectParsed = $this->richTextFormatter->richToParsed($subject, $parameters);
219
-			} catch (\InvalidArgumentException $e) {
220
-				throw new InvalidValueException('richSubjectParameters', $e);
221
-			}
222
-		}
223
-
224
-		return $this;
225
-	}
226
-
227
-	/**
228
-	 * @return string
229
-	 * @since 11.0.0
230
-	 */
231
-	public function getRichSubject(): string {
232
-		return $this->subjectRich;
233
-	}
234
-
235
-	/**
236
-	 * @return array<string, array<string, string>>
237
-	 * @since 11.0.0
238
-	 */
239
-	public function getRichSubjectParameters(): array {
240
-		return $this->subjectRichParameters;
241
-	}
242
-
243
-	/**
244
-	 * {@inheritDoc}
245
-	 */
246
-	public function setMessage(string $message, array $parameters = []): IEvent {
247
-		if (isset($message[255])) {
248
-			throw new InvalidValueException('message');
249
-		}
250
-		$this->message = $message;
251
-		$this->messageParameters = $parameters;
252
-		return $this;
253
-	}
254
-
255
-	/**
256
-	 * @return string
257
-	 */
258
-	public function getMessage(): string {
259
-		return $this->message;
260
-	}
261
-
262
-	/**
263
-	 * @return array
264
-	 */
265
-	public function getMessageParameters(): array {
266
-		return $this->messageParameters;
267
-	}
268
-
269
-	/**
270
-	 * {@inheritDoc}
271
-	 */
272
-	public function setParsedMessage(string $message): IEvent {
273
-		$this->messageParsed = $message;
274
-		return $this;
275
-	}
276
-
277
-	/**
278
-	 * @return string
279
-	 * @since 11.0.0
280
-	 */
281
-	public function getParsedMessage(): string {
282
-		return $this->messageParsed;
283
-	}
284
-
285
-	/**
286
-	 * {@inheritDoc}
287
-	 */
288
-	public function setRichMessage(string $message, array $parameters = []): IEvent {
289
-		$this->messageRich = $message;
290
-		$this->messageRichParameters = $parameters;
291
-
292
-		if ($this->messageParsed === '') {
293
-			try {
294
-				$this->messageParsed = $this->richTextFormatter->richToParsed($message, $parameters);
295
-			} catch (\InvalidArgumentException $e) {
296
-				throw new InvalidValueException('richMessageParameters', $e);
297
-			}
298
-		}
299
-
300
-		return $this;
301
-	}
302
-
303
-	/**
304
-	 * @return string
305
-	 * @since 11.0.0
306
-	 */
307
-	public function getRichMessage(): string {
308
-		return $this->messageRich;
309
-	}
310
-
311
-	/**
312
-	 * @return array<string, array<string, string>>
313
-	 * @since 11.0.0
314
-	 */
315
-	public function getRichMessageParameters(): array {
316
-		return $this->messageRichParameters;
317
-	}
318
-
319
-	/**
320
-	 * {@inheritDoc}
321
-	 */
322
-	public function setObject(string $objectType, int $objectId, string $objectName = ''): IEvent {
323
-		if (isset($objectType[255])) {
324
-			throw new InvalidValueException('objectType');
325
-		}
326
-		if (isset($objectName[4000])) {
327
-			throw new InvalidValueException('objectName');
328
-		}
329
-		$this->objectType = $objectType;
330
-		$this->objectId = $objectId;
331
-		$this->objectName = $objectName;
332
-		return $this;
333
-	}
334
-
335
-	/**
336
-	 * @return string
337
-	 */
338
-	public function getObjectType(): string {
339
-		return $this->objectType;
340
-	}
341
-
342
-	/**
343
-	 * @return int
344
-	 */
345
-	public function getObjectId(): int {
346
-		return $this->objectId;
347
-	}
348
-
349
-	/**
350
-	 * @return string
351
-	 */
352
-	public function getObjectName(): string {
353
-		return $this->objectName;
354
-	}
355
-
356
-	/**
357
-	 * {@inheritDoc}
358
-	 */
359
-	public function setLink(string $link): IEvent {
360
-		if (isset($link[4000])) {
361
-			throw new InvalidValueException('link');
362
-		}
363
-		$this->link = $link;
364
-		return $this;
365
-	}
366
-
367
-	/**
368
-	 * @return string
369
-	 */
370
-	public function getLink(): string {
371
-		return $this->link;
372
-	}
373
-
374
-	/**
375
-	 * {@inheritDoc}
376
-	 */
377
-	public function setIcon(string $icon): IEvent {
378
-		if (isset($icon[4000])) {
379
-			throw new InvalidValueException('icon');
380
-		}
381
-		$this->icon = $icon;
382
-		return $this;
383
-	}
384
-
385
-	/**
386
-	 * @return string
387
-	 * @since 11.0.0
388
-	 */
389
-	public function getIcon(): string {
390
-		return $this->icon;
391
-	}
392
-
393
-	/**
394
-	 * @param IEvent $child
395
-	 * @return $this
396
-	 * @since 11.0.0 - Since 15.0.0 returns $this
397
-	 */
398
-	public function setChildEvent(IEvent $child): IEvent {
399
-		$this->child = $child;
400
-		return $this;
401
-	}
402
-
403
-	/**
404
-	 * @return IEvent|null
405
-	 * @since 11.0.0
406
-	 */
407
-	public function getChildEvent() {
408
-		return $this->child;
409
-	}
410
-
411
-	/**
412
-	 * @return bool
413
-	 * @since 8.2.0
414
-	 */
415
-	public function isValid(): bool {
416
-		return
417
-			$this->isValidCommon()
418
-			&& $this->getSubject() !== ''
419
-		;
420
-	}
421
-
422
-	/**
423
-	 * @return bool
424
-	 * @since 8.2.0
425
-	 */
426
-	public function isValidParsed(): bool {
427
-		if ($this->getRichSubject() !== '' || !empty($this->getRichSubjectParameters())) {
428
-			try {
429
-				$this->richValidator->validate($this->getRichSubject(), $this->getRichSubjectParameters());
430
-			} catch (InvalidObjectExeption $e) {
431
-				return false;
432
-			}
433
-		}
434
-
435
-		if ($this->getRichMessage() !== '' || !empty($this->getRichMessageParameters())) {
436
-			try {
437
-				$this->richValidator->validate($this->getRichMessage(), $this->getRichMessageParameters());
438
-			} catch (InvalidObjectExeption $e) {
439
-				return false;
440
-			}
441
-		}
442
-
443
-		return
444
-			$this->isValidCommon()
445
-			&& $this->getParsedSubject() !== ''
446
-		;
447
-	}
448
-
449
-	protected function isValidCommon(): bool {
450
-		return
451
-			$this->getApp() !== ''
452
-			&& $this->getType() !== ''
453
-			&& $this->getTimestamp() !== 0
454
-			/**
455
-			 * Disabled for BC with old activities
456
-			 * &&
457
-			 * $this->getObjectType() !== ''
458
-			 * &&
459
-			 * $this->getObjectId() !== 0
460
-			 */
461
-		;
462
-	}
463
-
464
-	public function setGenerateNotification(bool $generate): IEvent {
465
-		$this->generateNotification = $generate;
466
-		return $this;
467
-	}
468
-
469
-	public function getGenerateNotification(): bool {
470
-		return $this->generateNotification;
471
-	}
19
+    /** @var string */
20
+    protected $app = '';
21
+    /** @var string */
22
+    protected $type = '';
23
+    /** @var string */
24
+    protected $affectedUser = '';
25
+    /** @var string */
26
+    protected $author = '';
27
+    /** @var int */
28
+    protected $timestamp = 0;
29
+    /** @var string */
30
+    protected $subject = '';
31
+    /** @var array */
32
+    protected $subjectParameters = [];
33
+    /** @var string */
34
+    protected $subjectParsed = '';
35
+    /** @var string */
36
+    protected $subjectRich = '';
37
+    /** @var array<string, array<string, string>> */
38
+    protected $subjectRichParameters = [];
39
+    /** @var string */
40
+    protected $message = '';
41
+    /** @var array */
42
+    protected $messageParameters = [];
43
+    /** @var string */
44
+    protected $messageParsed = '';
45
+    /** @var string */
46
+    protected $messageRich = '';
47
+    /** @var array<string, array<string, string>> */
48
+    protected $messageRichParameters = [];
49
+    /** @var string */
50
+    protected $objectType = '';
51
+    /** @var int */
52
+    protected $objectId = 0;
53
+    /** @var string */
54
+    protected $objectName = '';
55
+    /** @var string */
56
+    protected $link = '';
57
+    /** @var string */
58
+    protected $icon = '';
59
+    /** @var bool */
60
+    protected $generateNotification = true;
61
+
62
+    /** @var IEvent|null */
63
+    protected $child;
64
+
65
+    public function __construct(
66
+        protected IValidator $richValidator,
67
+        protected IRichTextFormatter $richTextFormatter,
68
+    ) {
69
+    }
70
+
71
+    /**
72
+     * {@inheritDoc}
73
+     */
74
+    public function setApp(string $app): IEvent {
75
+        if ($app === '' || isset($app[32])) {
76
+            throw new InvalidValueException('app');
77
+        }
78
+        $this->app = $app;
79
+        return $this;
80
+    }
81
+
82
+    /**
83
+     * @return string
84
+     */
85
+    public function getApp(): string {
86
+        return $this->app;
87
+    }
88
+
89
+    /**
90
+     * {@inheritDoc}
91
+     */
92
+    public function setType(string $type): IEvent {
93
+        if ($type === '' || isset($type[255])) {
94
+            throw new InvalidValueException('type');
95
+        }
96
+        $this->type = $type;
97
+        return $this;
98
+    }
99
+
100
+    /**
101
+     * @return string
102
+     */
103
+    public function getType(): string {
104
+        return $this->type;
105
+    }
106
+
107
+    /**
108
+     *  {@inheritDoc}
109
+     */
110
+    public function setAffectedUser(string $affectedUser): IEvent {
111
+        if ($affectedUser === '' || isset($affectedUser[64])) {
112
+            throw new InvalidValueException('affectedUser');
113
+        }
114
+        $this->affectedUser = $affectedUser;
115
+        return $this;
116
+    }
117
+
118
+    /**
119
+     * @return string
120
+     */
121
+    public function getAffectedUser(): string {
122
+        return $this->affectedUser;
123
+    }
124
+
125
+    /**
126
+     * {@inheritDoc}
127
+     */
128
+    public function setAuthor(string $author): IEvent {
129
+        if (isset($author[64])) {
130
+            throw new InvalidValueException('author');
131
+        }
132
+        $this->author = $author;
133
+        return $this;
134
+    }
135
+
136
+    /**
137
+     * @return string
138
+     */
139
+    public function getAuthor(): string {
140
+        return $this->author;
141
+    }
142
+
143
+    /**
144
+     * {@inheritDoc}
145
+     */
146
+    public function setTimestamp(int $timestamp): IEvent {
147
+        if ($timestamp < 0) {
148
+            throw new InvalidValueException('timestamp');
149
+        }
150
+        $this->timestamp = $timestamp;
151
+        return $this;
152
+    }
153
+
154
+    /**
155
+     * @return int
156
+     */
157
+    public function getTimestamp(): int {
158
+        return $this->timestamp;
159
+    }
160
+
161
+    /**
162
+     * {@inheritDoc}
163
+     */
164
+    public function setSubject(string $subject, array $parameters = []): IEvent {
165
+        if (isset($subject[255])) {
166
+            throw new InvalidValueException('subject');
167
+        }
168
+        $this->subject = $subject;
169
+        $this->subjectParameters = $parameters;
170
+        return $this;
171
+    }
172
+
173
+    /**
174
+     * @return string
175
+     */
176
+    public function getSubject(): string {
177
+        return $this->subject;
178
+    }
179
+
180
+    /**
181
+     * @return array
182
+     */
183
+    public function getSubjectParameters(): array {
184
+        return $this->subjectParameters;
185
+    }
186
+
187
+    /**
188
+     * {@inheritDoc}
189
+     */
190
+    public function setParsedSubject(string $subject): IEvent {
191
+        if ($subject === '') {
192
+            throw new InvalidValueException('parsedSubject');
193
+        }
194
+        $this->subjectParsed = $subject;
195
+        return $this;
196
+    }
197
+
198
+    /**
199
+     * @return string
200
+     * @since 11.0.0
201
+     */
202
+    public function getParsedSubject(): string {
203
+        return $this->subjectParsed;
204
+    }
205
+
206
+    /**
207
+     * {@inheritDoc}
208
+     */
209
+    public function setRichSubject(string $subject, array $parameters = []): IEvent {
210
+        if ($subject === '') {
211
+            throw new InvalidValueException('richSubject');
212
+        }
213
+        $this->subjectRich = $subject;
214
+        $this->subjectRichParameters = $parameters;
215
+
216
+        if ($this->subjectParsed === '') {
217
+            try {
218
+                $this->subjectParsed = $this->richTextFormatter->richToParsed($subject, $parameters);
219
+            } catch (\InvalidArgumentException $e) {
220
+                throw new InvalidValueException('richSubjectParameters', $e);
221
+            }
222
+        }
223
+
224
+        return $this;
225
+    }
226
+
227
+    /**
228
+     * @return string
229
+     * @since 11.0.0
230
+     */
231
+    public function getRichSubject(): string {
232
+        return $this->subjectRich;
233
+    }
234
+
235
+    /**
236
+     * @return array<string, array<string, string>>
237
+     * @since 11.0.0
238
+     */
239
+    public function getRichSubjectParameters(): array {
240
+        return $this->subjectRichParameters;
241
+    }
242
+
243
+    /**
244
+     * {@inheritDoc}
245
+     */
246
+    public function setMessage(string $message, array $parameters = []): IEvent {
247
+        if (isset($message[255])) {
248
+            throw new InvalidValueException('message');
249
+        }
250
+        $this->message = $message;
251
+        $this->messageParameters = $parameters;
252
+        return $this;
253
+    }
254
+
255
+    /**
256
+     * @return string
257
+     */
258
+    public function getMessage(): string {
259
+        return $this->message;
260
+    }
261
+
262
+    /**
263
+     * @return array
264
+     */
265
+    public function getMessageParameters(): array {
266
+        return $this->messageParameters;
267
+    }
268
+
269
+    /**
270
+     * {@inheritDoc}
271
+     */
272
+    public function setParsedMessage(string $message): IEvent {
273
+        $this->messageParsed = $message;
274
+        return $this;
275
+    }
276
+
277
+    /**
278
+     * @return string
279
+     * @since 11.0.0
280
+     */
281
+    public function getParsedMessage(): string {
282
+        return $this->messageParsed;
283
+    }
284
+
285
+    /**
286
+     * {@inheritDoc}
287
+     */
288
+    public function setRichMessage(string $message, array $parameters = []): IEvent {
289
+        $this->messageRich = $message;
290
+        $this->messageRichParameters = $parameters;
291
+
292
+        if ($this->messageParsed === '') {
293
+            try {
294
+                $this->messageParsed = $this->richTextFormatter->richToParsed($message, $parameters);
295
+            } catch (\InvalidArgumentException $e) {
296
+                throw new InvalidValueException('richMessageParameters', $e);
297
+            }
298
+        }
299
+
300
+        return $this;
301
+    }
302
+
303
+    /**
304
+     * @return string
305
+     * @since 11.0.0
306
+     */
307
+    public function getRichMessage(): string {
308
+        return $this->messageRich;
309
+    }
310
+
311
+    /**
312
+     * @return array<string, array<string, string>>
313
+     * @since 11.0.0
314
+     */
315
+    public function getRichMessageParameters(): array {
316
+        return $this->messageRichParameters;
317
+    }
318
+
319
+    /**
320
+     * {@inheritDoc}
321
+     */
322
+    public function setObject(string $objectType, int $objectId, string $objectName = ''): IEvent {
323
+        if (isset($objectType[255])) {
324
+            throw new InvalidValueException('objectType');
325
+        }
326
+        if (isset($objectName[4000])) {
327
+            throw new InvalidValueException('objectName');
328
+        }
329
+        $this->objectType = $objectType;
330
+        $this->objectId = $objectId;
331
+        $this->objectName = $objectName;
332
+        return $this;
333
+    }
334
+
335
+    /**
336
+     * @return string
337
+     */
338
+    public function getObjectType(): string {
339
+        return $this->objectType;
340
+    }
341
+
342
+    /**
343
+     * @return int
344
+     */
345
+    public function getObjectId(): int {
346
+        return $this->objectId;
347
+    }
348
+
349
+    /**
350
+     * @return string
351
+     */
352
+    public function getObjectName(): string {
353
+        return $this->objectName;
354
+    }
355
+
356
+    /**
357
+     * {@inheritDoc}
358
+     */
359
+    public function setLink(string $link): IEvent {
360
+        if (isset($link[4000])) {
361
+            throw new InvalidValueException('link');
362
+        }
363
+        $this->link = $link;
364
+        return $this;
365
+    }
366
+
367
+    /**
368
+     * @return string
369
+     */
370
+    public function getLink(): string {
371
+        return $this->link;
372
+    }
373
+
374
+    /**
375
+     * {@inheritDoc}
376
+     */
377
+    public function setIcon(string $icon): IEvent {
378
+        if (isset($icon[4000])) {
379
+            throw new InvalidValueException('icon');
380
+        }
381
+        $this->icon = $icon;
382
+        return $this;
383
+    }
384
+
385
+    /**
386
+     * @return string
387
+     * @since 11.0.0
388
+     */
389
+    public function getIcon(): string {
390
+        return $this->icon;
391
+    }
392
+
393
+    /**
394
+     * @param IEvent $child
395
+     * @return $this
396
+     * @since 11.0.0 - Since 15.0.0 returns $this
397
+     */
398
+    public function setChildEvent(IEvent $child): IEvent {
399
+        $this->child = $child;
400
+        return $this;
401
+    }
402
+
403
+    /**
404
+     * @return IEvent|null
405
+     * @since 11.0.0
406
+     */
407
+    public function getChildEvent() {
408
+        return $this->child;
409
+    }
410
+
411
+    /**
412
+     * @return bool
413
+     * @since 8.2.0
414
+     */
415
+    public function isValid(): bool {
416
+        return
417
+            $this->isValidCommon()
418
+            && $this->getSubject() !== ''
419
+        ;
420
+    }
421
+
422
+    /**
423
+     * @return bool
424
+     * @since 8.2.0
425
+     */
426
+    public function isValidParsed(): bool {
427
+        if ($this->getRichSubject() !== '' || !empty($this->getRichSubjectParameters())) {
428
+            try {
429
+                $this->richValidator->validate($this->getRichSubject(), $this->getRichSubjectParameters());
430
+            } catch (InvalidObjectExeption $e) {
431
+                return false;
432
+            }
433
+        }
434
+
435
+        if ($this->getRichMessage() !== '' || !empty($this->getRichMessageParameters())) {
436
+            try {
437
+                $this->richValidator->validate($this->getRichMessage(), $this->getRichMessageParameters());
438
+            } catch (InvalidObjectExeption $e) {
439
+                return false;
440
+            }
441
+        }
442
+
443
+        return
444
+            $this->isValidCommon()
445
+            && $this->getParsedSubject() !== ''
446
+        ;
447
+    }
448
+
449
+    protected function isValidCommon(): bool {
450
+        return
451
+            $this->getApp() !== ''
452
+            && $this->getType() !== ''
453
+            && $this->getTimestamp() !== 0
454
+            /**
455
+             * Disabled for BC with old activities
456
+             * &&
457
+             * $this->getObjectType() !== ''
458
+             * &&
459
+             * $this->getObjectId() !== 0
460
+             */
461
+        ;
462
+    }
463
+
464
+    public function setGenerateNotification(bool $generate): IEvent {
465
+        $this->generateNotification = $generate;
466
+        return $this;
467
+    }
468
+
469
+    public function getGenerateNotification(): bool {
470
+        return $this->generateNotification;
471
+    }
472 472
 }
Please login to merge, or discard this patch.
lib/public/Activity/IManager.php 1 patch
Indentation   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -18,159 +18,159 @@
 block discarded – undo
18 18
  * @since 6.0.0
19 19
  */
20 20
 interface IManager {
21
-	/**
22
-	 * Generates a new IEvent object
23
-	 *
24
-	 * Make sure to call at least the following methods before sending it to the
25
-	 * app with via the publish() method:
26
-	 *  - setApp()
27
-	 *  - setType()
28
-	 *  - setAffectedUser()
29
-	 *  - setSubject()
30
-	 *  - setObject()
31
-	 *
32
-	 * @return IEvent
33
-	 * @since 8.2.0
34
-	 */
35
-	public function generateEvent(): IEvent;
36
-
37
-	/**
38
-	 * Publish an event to the activity consumers
39
-	 *
40
-	 * Make sure to call at least the following methods before sending an Event:
41
-	 *  - setApp()
42
-	 *  - setType()
43
-	 *  - setAffectedUser()
44
-	 *  - setSubject()
45
-	 *  - setObject()
46
-	 *
47
-	 * @param IEvent $event
48
-	 * @throws IncompleteActivityException if required values have not been set
49
-	 * @since 8.2.0
50
-	 * @since 30.0.0 throws {@see IncompleteActivityException} instead of \BadMethodCallException
51
-	 */
52
-	public function publish(IEvent $event): void;
53
-
54
-	/**
55
-	 * Bulk publish an event for multiple users
56
-	 * taking into account the app specific activity settings
57
-	 *
58
-	 * Make sure to call at least the following methods before sending an Event:
59
-	 *  - setApp()
60
-	 *  - setType()
61
-	 *
62
-	 * @param IEvent $event
63
-	 * @throws IncompleteActivityException if required values have not been set
64
-	 * @since 32.0.0
65
-	 */
66
-	public function bulkPublish(IEvent $event, array $affectedUserIds, ISetting $setting): void;
67
-
68
-	/**
69
-	 * In order to improve lazy loading a closure can be registered which will be called in case
70
-	 * activity consumers are actually requested
71
-	 *
72
-	 * $callable has to return an instance of \OCP\Activity\IConsumer
73
-	 *
74
-	 * @param \Closure $callable
75
-	 * @since 6.0.0
76
-	 */
77
-	public function registerConsumer(\Closure $callable): void;
78
-
79
-	/**
80
-	 * @param string $filter Class must implement OCA\Activity\IFilter
81
-	 * @since 11.0.0
82
-	 */
83
-	public function registerFilter(string $filter): void;
84
-
85
-	/**
86
-	 * @return IFilter[]
87
-	 * @since 11.0.0
88
-	 */
89
-	public function getFilters(): array;
90
-
91
-	/**
92
-	 * @param string $id
93
-	 * @return IFilter
94
-	 * @throws FilterNotFoundException when the filter was not found
95
-	 * @since 11.0.0
96
-	 * @since 30.0.0 throws {@see FilterNotFoundException} instead of \InvalidArgumentException
97
-	 */
98
-	public function getFilterById(string $id): IFilter;
99
-
100
-	/**
101
-	 * @param string $setting Class must implement OCA\Activity\ISetting
102
-	 * @since 11.0.0
103
-	 */
104
-	public function registerSetting(string $setting): void;
105
-
106
-	/**
107
-	 * @return ActivitySettings[]
108
-	 * @since 11.0.0
109
-	 */
110
-	public function getSettings(): array;
111
-
112
-	/**
113
-	 * @param string $provider Class must implement OCA\Activity\IProvider
114
-	 * @since 11.0.0
115
-	 */
116
-	public function registerProvider(string $provider): void;
117
-
118
-	/**
119
-	 * @return IProvider[]
120
-	 * @since 11.0.0
121
-	 */
122
-	public function getProviders(): array;
123
-
124
-	/**
125
-	 * @param string $id
126
-	 * @return ActivitySettings
127
-	 * @throws SettingNotFoundException when the setting was not found
128
-	 * @since 11.0.0
129
-	 * @since 30.0.0 throws {@see SettingNotFoundException} instead of \InvalidArgumentException
130
-	 */
131
-	public function getSettingById(string $id): ActivitySettings;
132
-
133
-	/**
134
-	 * @param string $type
135
-	 * @param int $id
136
-	 * @since 8.2.0
137
-	 */
138
-	public function setFormattingObject(string $type, int $id): void;
139
-
140
-	/**
141
-	 * @return bool
142
-	 * @since 8.2.0
143
-	 */
144
-	public function isFormattingFilteredObject(): bool;
145
-
146
-	/**
147
-	 * @param bool $status Set to true, when parsing events should not use SVG icons
148
-	 * @since 12.0.1
149
-	 */
150
-	public function setRequirePNG(bool $status): void;
151
-
152
-	/**
153
-	 * @return bool
154
-	 * @since 12.0.1
155
-	 */
156
-	public function getRequirePNG(): bool;
157
-
158
-	/**
159
-	 * Set the user we need to use
160
-	 *
161
-	 * @param string|null $currentUserId
162
-	 * @since 9.0.1
163
-	 */
164
-	public function setCurrentUserId(?string $currentUserId = null): void;
165
-
166
-	/**
167
-	 * Get the user we need to use
168
-	 *
169
-	 * Either the user is logged in, or we try to get it from the token
170
-	 *
171
-	 * @return string
172
-	 * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique
173
-	 * @since 8.1.0
174
-	 */
175
-	public function getCurrentUserId(): string;
21
+    /**
22
+     * Generates a new IEvent object
23
+     *
24
+     * Make sure to call at least the following methods before sending it to the
25
+     * app with via the publish() method:
26
+     *  - setApp()
27
+     *  - setType()
28
+     *  - setAffectedUser()
29
+     *  - setSubject()
30
+     *  - setObject()
31
+     *
32
+     * @return IEvent
33
+     * @since 8.2.0
34
+     */
35
+    public function generateEvent(): IEvent;
36
+
37
+    /**
38
+     * Publish an event to the activity consumers
39
+     *
40
+     * Make sure to call at least the following methods before sending an Event:
41
+     *  - setApp()
42
+     *  - setType()
43
+     *  - setAffectedUser()
44
+     *  - setSubject()
45
+     *  - setObject()
46
+     *
47
+     * @param IEvent $event
48
+     * @throws IncompleteActivityException if required values have not been set
49
+     * @since 8.2.0
50
+     * @since 30.0.0 throws {@see IncompleteActivityException} instead of \BadMethodCallException
51
+     */
52
+    public function publish(IEvent $event): void;
53
+
54
+    /**
55
+     * Bulk publish an event for multiple users
56
+     * taking into account the app specific activity settings
57
+     *
58
+     * Make sure to call at least the following methods before sending an Event:
59
+     *  - setApp()
60
+     *  - setType()
61
+     *
62
+     * @param IEvent $event
63
+     * @throws IncompleteActivityException if required values have not been set
64
+     * @since 32.0.0
65
+     */
66
+    public function bulkPublish(IEvent $event, array $affectedUserIds, ISetting $setting): void;
67
+
68
+    /**
69
+     * In order to improve lazy loading a closure can be registered which will be called in case
70
+     * activity consumers are actually requested
71
+     *
72
+     * $callable has to return an instance of \OCP\Activity\IConsumer
73
+     *
74
+     * @param \Closure $callable
75
+     * @since 6.0.0
76
+     */
77
+    public function registerConsumer(\Closure $callable): void;
78
+
79
+    /**
80
+     * @param string $filter Class must implement OCA\Activity\IFilter
81
+     * @since 11.0.0
82
+     */
83
+    public function registerFilter(string $filter): void;
84
+
85
+    /**
86
+     * @return IFilter[]
87
+     * @since 11.0.0
88
+     */
89
+    public function getFilters(): array;
90
+
91
+    /**
92
+     * @param string $id
93
+     * @return IFilter
94
+     * @throws FilterNotFoundException when the filter was not found
95
+     * @since 11.0.0
96
+     * @since 30.0.0 throws {@see FilterNotFoundException} instead of \InvalidArgumentException
97
+     */
98
+    public function getFilterById(string $id): IFilter;
99
+
100
+    /**
101
+     * @param string $setting Class must implement OCA\Activity\ISetting
102
+     * @since 11.0.0
103
+     */
104
+    public function registerSetting(string $setting): void;
105
+
106
+    /**
107
+     * @return ActivitySettings[]
108
+     * @since 11.0.0
109
+     */
110
+    public function getSettings(): array;
111
+
112
+    /**
113
+     * @param string $provider Class must implement OCA\Activity\IProvider
114
+     * @since 11.0.0
115
+     */
116
+    public function registerProvider(string $provider): void;
117
+
118
+    /**
119
+     * @return IProvider[]
120
+     * @since 11.0.0
121
+     */
122
+    public function getProviders(): array;
123
+
124
+    /**
125
+     * @param string $id
126
+     * @return ActivitySettings
127
+     * @throws SettingNotFoundException when the setting was not found
128
+     * @since 11.0.0
129
+     * @since 30.0.0 throws {@see SettingNotFoundException} instead of \InvalidArgumentException
130
+     */
131
+    public function getSettingById(string $id): ActivitySettings;
132
+
133
+    /**
134
+     * @param string $type
135
+     * @param int $id
136
+     * @since 8.2.0
137
+     */
138
+    public function setFormattingObject(string $type, int $id): void;
139
+
140
+    /**
141
+     * @return bool
142
+     * @since 8.2.0
143
+     */
144
+    public function isFormattingFilteredObject(): bool;
145
+
146
+    /**
147
+     * @param bool $status Set to true, when parsing events should not use SVG icons
148
+     * @since 12.0.1
149
+     */
150
+    public function setRequirePNG(bool $status): void;
151
+
152
+    /**
153
+     * @return bool
154
+     * @since 12.0.1
155
+     */
156
+    public function getRequirePNG(): bool;
157
+
158
+    /**
159
+     * Set the user we need to use
160
+     *
161
+     * @param string|null $currentUserId
162
+     * @since 9.0.1
163
+     */
164
+    public function setCurrentUserId(?string $currentUserId = null): void;
165
+
166
+    /**
167
+     * Get the user we need to use
168
+     *
169
+     * Either the user is logged in, or we try to get it from the token
170
+     *
171
+     * @return string
172
+     * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique
173
+     * @since 8.1.0
174
+     */
175
+    public function getCurrentUserId(): string;
176 176
 }
Please login to merge, or discard this patch.
lib/public/Activity/IBulkConsumer.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -13,12 +13,12 @@
 block discarded – undo
13 13
  * @since 32.0.0
14 14
  */
15 15
 interface IBulkConsumer extends IConsumer {
16
-	/**
17
-	 * @param IEvent $event
18
-	 * @param array $affectedUserIds
19
-	 * @param ISetting $setting
20
-	 * @return void
21
-	 * @since 32.0.0
22
-	 */
23
-	public function bulkReceive(IEvent $event, array $affectedUserIds, ISetting $setting): void;
16
+    /**
17
+     * @param IEvent $event
18
+     * @param array $affectedUserIds
19
+     * @param ISetting $setting
20
+     * @return void
21
+     * @since 32.0.0
22
+     */
23
+    public function bulkReceive(IEvent $event, array $affectedUserIds, ISetting $setting): void;
24 24
 }
Please login to merge, or discard this patch.