Passed
Push — master ( 0a5481...ad00a1 )
by Christoph
18:06 queued 13s
created
lib/public/AppFramework/Bootstrap/IRegistrationContext.php 1 patch
Indentation   +258 added lines, -258 removed lines patch added patch discarded remove patch
@@ -47,285 +47,285 @@
 block discarded – undo
47 47
  * @see IBootstrap::register()
48 48
  */
49 49
 interface IRegistrationContext {
50
-	/**
51
-	 * @param string $capability
52
-	 * @psalm-param class-string<ICapability> $capability
53
-	 * @see IAppContainer::registerCapability
54
-	 *
55
-	 * @since 20.0.0
56
-	 */
57
-	public function registerCapability(string $capability): void;
50
+    /**
51
+     * @param string $capability
52
+     * @psalm-param class-string<ICapability> $capability
53
+     * @see IAppContainer::registerCapability
54
+     *
55
+     * @since 20.0.0
56
+     */
57
+    public function registerCapability(string $capability): void;
58 58
 
59
-	/**
60
-	 * Register an implementation of \OCP\Support\CrashReport\IReporter that
61
-	 * will receive unhandled exceptions and throwables
62
-	 *
63
-	 * @param string $reporterClass
64
-	 * @psalm-param class-string<\OCP\Support\CrashReport\IReporter> $reporterClass
65
-	 * @return void
66
-	 * @since 20.0.0
67
-	 */
68
-	public function registerCrashReporter(string $reporterClass): void;
59
+    /**
60
+     * Register an implementation of \OCP\Support\CrashReport\IReporter that
61
+     * will receive unhandled exceptions and throwables
62
+     *
63
+     * @param string $reporterClass
64
+     * @psalm-param class-string<\OCP\Support\CrashReport\IReporter> $reporterClass
65
+     * @return void
66
+     * @since 20.0.0
67
+     */
68
+    public function registerCrashReporter(string $reporterClass): void;
69 69
 
70
-	/**
71
-	 * Register an implementation of \OCP\Dashboard\IWidget that
72
-	 * will handle the implementation of a dashboard widget
73
-	 *
74
-	 * @param string $widgetClass
75
-	 * @psalm-param class-string<\OCP\Dashboard\IWidget> $widgetClass
76
-	 * @return void
77
-	 * @since 20.0.0
78
-	 */
79
-	public function registerDashboardWidget(string $widgetClass): void;
70
+    /**
71
+     * Register an implementation of \OCP\Dashboard\IWidget that
72
+     * will handle the implementation of a dashboard widget
73
+     *
74
+     * @param string $widgetClass
75
+     * @psalm-param class-string<\OCP\Dashboard\IWidget> $widgetClass
76
+     * @return void
77
+     * @since 20.0.0
78
+     */
79
+    public function registerDashboardWidget(string $widgetClass): void;
80 80
 
81
-	/**
82
-	 * Register a service
83
-	 *
84
-	 * @param string $name
85
-	 * @param callable $factory
86
-	 * @psalm-param callable(\Psr\Container\ContainerInterface): mixed $factory
87
-	 * @param bool $shared
88
-	 *
89
-	 * @return void
90
-	 * @see IContainer::registerService()
91
-	 *
92
-	 * @since 20.0.0
93
-	 */
94
-	public function registerService(string $name, callable $factory, bool $shared = true): void;
81
+    /**
82
+     * Register a service
83
+     *
84
+     * @param string $name
85
+     * @param callable $factory
86
+     * @psalm-param callable(\Psr\Container\ContainerInterface): mixed $factory
87
+     * @param bool $shared
88
+     *
89
+     * @return void
90
+     * @see IContainer::registerService()
91
+     *
92
+     * @since 20.0.0
93
+     */
94
+    public function registerService(string $name, callable $factory, bool $shared = true): void;
95 95
 
96
-	/**
97
-	 * @param string $alias
98
-	 * @psalm-param string|class-string $alias
99
-	 * @param string $target
100
-	 * @psalm-param string|class-string $target
101
-	 *
102
-	 * @return void
103
-	 * @see IContainer::registerAlias()
104
-	 *
105
-	 * @since 20.0.0
106
-	 */
107
-	public function registerServiceAlias(string $alias, string $target): void;
96
+    /**
97
+     * @param string $alias
98
+     * @psalm-param string|class-string $alias
99
+     * @param string $target
100
+     * @psalm-param string|class-string $target
101
+     *
102
+     * @return void
103
+     * @see IContainer::registerAlias()
104
+     *
105
+     * @since 20.0.0
106
+     */
107
+    public function registerServiceAlias(string $alias, string $target): void;
108 108
 
109
-	/**
110
-	 * @param string $name
111
-	 * @param mixed $value
112
-	 *
113
-	 * @return void
114
-	 * @see IContainer::registerParameter()
115
-	 *
116
-	 * @since 20.0.0
117
-	 */
118
-	public function registerParameter(string $name, $value): void;
109
+    /**
110
+     * @param string $name
111
+     * @param mixed $value
112
+     *
113
+     * @return void
114
+     * @see IContainer::registerParameter()
115
+     *
116
+     * @since 20.0.0
117
+     */
118
+    public function registerParameter(string $name, $value): void;
119 119
 
120
-	/**
121
-	 * Register a service listener
122
-	 *
123
-	 * This is equivalent to calling IEventDispatcher::addServiceListener
124
-	 *
125
-	 * @psalm-template T of \OCP\EventDispatcher\Event
126
-	 * @param string $event preferably the fully-qualified class name of the Event sub class to listen for
127
-	 * @psalm-param string|class-string<T> $event preferably the fully-qualified class name of the Event sub class to listen for
128
-	 * @param string $listener fully qualified class name (or ::class notation) of a \OCP\EventDispatcher\IEventListener that can be built by the DI container
129
-	 * @psalm-param class-string<\OCP\EventDispatcher\IEventListener> $listener fully qualified class name that can be built by the DI container
130
-	 * @param int $priority The higher this value, the earlier an event
131
-	 *                      listener will be triggered in the chain (defaults to 0)
132
-	 *
133
-	 * @see IEventDispatcher::addServiceListener()
134
-	 *
135
-	 * @since 20.0.0
136
-	 */
137
-	public function registerEventListener(string $event, string $listener, int $priority = 0): void;
120
+    /**
121
+     * Register a service listener
122
+     *
123
+     * This is equivalent to calling IEventDispatcher::addServiceListener
124
+     *
125
+     * @psalm-template T of \OCP\EventDispatcher\Event
126
+     * @param string $event preferably the fully-qualified class name of the Event sub class to listen for
127
+     * @psalm-param string|class-string<T> $event preferably the fully-qualified class name of the Event sub class to listen for
128
+     * @param string $listener fully qualified class name (or ::class notation) of a \OCP\EventDispatcher\IEventListener that can be built by the DI container
129
+     * @psalm-param class-string<\OCP\EventDispatcher\IEventListener> $listener fully qualified class name that can be built by the DI container
130
+     * @param int $priority The higher this value, the earlier an event
131
+     *                      listener will be triggered in the chain (defaults to 0)
132
+     *
133
+     * @see IEventDispatcher::addServiceListener()
134
+     *
135
+     * @since 20.0.0
136
+     */
137
+    public function registerEventListener(string $event, string $listener, int $priority = 0): void;
138 138
 
139
-	/**
140
-	 * @param string $class
141
-	 * @param bool $global load this middleware also for requests of other apps? Added in Nextcloud 26
142
-	 * @psalm-param class-string<\OCP\AppFramework\Middleware> $class
143
-	 *
144
-	 * @return void
145
-	 * @see IAppContainer::registerMiddleWare()
146
-	 *
147
-	 * @since 20.0.0
148
-	 * @since 26.0.0 Added optional argument $global
149
-	 */
150
-	public function registerMiddleware(string $class, bool $global = false): void;
139
+    /**
140
+     * @param string $class
141
+     * @param bool $global load this middleware also for requests of other apps? Added in Nextcloud 26
142
+     * @psalm-param class-string<\OCP\AppFramework\Middleware> $class
143
+     *
144
+     * @return void
145
+     * @see IAppContainer::registerMiddleWare()
146
+     *
147
+     * @since 20.0.0
148
+     * @since 26.0.0 Added optional argument $global
149
+     */
150
+    public function registerMiddleware(string $class, bool $global = false): void;
151 151
 
152
-	/**
153
-	 * Register a search provider for the unified search
154
-	 *
155
-	 * It is allowed to register more than one provider per app as the search
156
-	 * results can go into distinct sections, e.g. "Files" and "Files shared
157
-	 * with you" in the Files app.
158
-	 *
159
-	 * @param string $class
160
-	 * @psalm-param class-string<\OCP\Search\IProvider> $class
161
-	 *
162
-	 * @return void
163
-	 *
164
-	 * @since 20.0.0
165
-	 */
166
-	public function registerSearchProvider(string $class): void;
152
+    /**
153
+     * Register a search provider for the unified search
154
+     *
155
+     * It is allowed to register more than one provider per app as the search
156
+     * results can go into distinct sections, e.g. "Files" and "Files shared
157
+     * with you" in the Files app.
158
+     *
159
+     * @param string $class
160
+     * @psalm-param class-string<\OCP\Search\IProvider> $class
161
+     *
162
+     * @return void
163
+     *
164
+     * @since 20.0.0
165
+     */
166
+    public function registerSearchProvider(string $class): void;
167 167
 
168
-	/**
169
-	 * Register an alternative login option
170
-	 *
171
-	 * It is allowed to register more than one option per app.
172
-	 *
173
-	 * @param string $class
174
-	 * @psalm-param class-string<\OCP\Authentication\IAlternativeLogin> $class
175
-	 *
176
-	 * @return void
177
-	 *
178
-	 * @since 20.0.0
179
-	 */
180
-	public function registerAlternativeLogin(string $class): void;
168
+    /**
169
+     * Register an alternative login option
170
+     *
171
+     * It is allowed to register more than one option per app.
172
+     *
173
+     * @param string $class
174
+     * @psalm-param class-string<\OCP\Authentication\IAlternativeLogin> $class
175
+     *
176
+     * @return void
177
+     *
178
+     * @since 20.0.0
179
+     */
180
+    public function registerAlternativeLogin(string $class): void;
181 181
 
182
-	/**
183
-	 * Register an initialstate provider
184
-	 *
185
-	 * It is allowed to register more than one provider per app.
186
-	 *
187
-	 * @param string $class
188
-	 * @psalm-param class-string<\OCP\AppFramework\Services\InitialStateProvider> $class
189
-	 *
190
-	 * @return void
191
-	 *
192
-	 * @since 21.0.0
193
-	 */
194
-	public function registerInitialStateProvider(string $class): void;
182
+    /**
183
+     * Register an initialstate provider
184
+     *
185
+     * It is allowed to register more than one provider per app.
186
+     *
187
+     * @param string $class
188
+     * @psalm-param class-string<\OCP\AppFramework\Services\InitialStateProvider> $class
189
+     *
190
+     * @return void
191
+     *
192
+     * @since 21.0.0
193
+     */
194
+    public function registerInitialStateProvider(string $class): void;
195 195
 
196
-	/**
197
-	 * Register a well known protocol handler
198
-	 *
199
-	 * It is allowed to register more than one handler per app.
200
-	 *
201
-	 * @param string $class
202
-	 * @psalm-param class-string<\OCP\Http\WellKnown\IHandler> $class
203
-	 *
204
-	 * @return void
205
-	 *
206
-	 * @since 21.0.0
207
-	 */
208
-	public function registerWellKnownHandler(string $class): void;
196
+    /**
197
+     * Register a well known protocol handler
198
+     *
199
+     * It is allowed to register more than one handler per app.
200
+     *
201
+     * @param string $class
202
+     * @psalm-param class-string<\OCP\Http\WellKnown\IHandler> $class
203
+     *
204
+     * @return void
205
+     *
206
+     * @since 21.0.0
207
+     */
208
+    public function registerWellKnownHandler(string $class): void;
209 209
 
210
-	/**
211
-	 * Register a custom template provider class that is able to inject custom templates
212
-	 * in addition to the user defined ones
213
-	 *
214
-	 * @param string $providerClass
215
-	 * @psalm-param class-string<ICustomTemplateProvider> $providerClass
216
-	 * @since 21.0.0
217
-	 */
218
-	public function registerTemplateProvider(string $providerClass): void;
210
+    /**
211
+     * Register a custom template provider class that is able to inject custom templates
212
+     * in addition to the user defined ones
213
+     *
214
+     * @param string $providerClass
215
+     * @psalm-param class-string<ICustomTemplateProvider> $providerClass
216
+     * @since 21.0.0
217
+     */
218
+    public function registerTemplateProvider(string $providerClass): void;
219 219
 
220
-	/**
221
-	 * Register an INotifier class
222
-	 *
223
-	 * @param string $notifierClass
224
-	 * @psalm-param class-string<INotifier> $notifierClass
225
-	 * @since 22.0.0
226
-	 */
227
-	public function registerNotifierService(string $notifierClass): void;
220
+    /**
221
+     * Register an INotifier class
222
+     *
223
+     * @param string $notifierClass
224
+     * @psalm-param class-string<INotifier> $notifierClass
225
+     * @since 22.0.0
226
+     */
227
+    public function registerNotifierService(string $notifierClass): void;
228 228
 
229
-	/**
230
-	 * Register a two-factor provider
231
-	 *
232
-	 * @param string $twoFactorProviderClass
233
-	 * @psalm-param class-string<IProvider> $twoFactorProviderClass
234
-	 * @since 22.0.0
235
-	 */
236
-	public function registerTwoFactorProvider(string $twoFactorProviderClass): void;
229
+    /**
230
+     * Register a two-factor provider
231
+     *
232
+     * @param string $twoFactorProviderClass
233
+     * @psalm-param class-string<IProvider> $twoFactorProviderClass
234
+     * @since 22.0.0
235
+     */
236
+    public function registerTwoFactorProvider(string $twoFactorProviderClass): void;
237 237
 
238
-	/**
239
-	 * Register a preview provider
240
-	 *
241
-	 * It is allowed to register more than one provider per app.
242
-	 *
243
-	 * @param string $previewProviderClass
244
-	 * @param string $mimeTypeRegex
245
-	 * @psalm-param class-string<IProviderV2> $previewProviderClass
246
-	 * @since 23.0.0
247
-	 */
248
-	public function registerPreviewProvider(string $previewProviderClass, string $mimeTypeRegex): void;
238
+    /**
239
+     * Register a preview provider
240
+     *
241
+     * It is allowed to register more than one provider per app.
242
+     *
243
+     * @param string $previewProviderClass
244
+     * @param string $mimeTypeRegex
245
+     * @psalm-param class-string<IProviderV2> $previewProviderClass
246
+     * @since 23.0.0
247
+     */
248
+    public function registerPreviewProvider(string $previewProviderClass, string $mimeTypeRegex): void;
249 249
 
250
-	/**
251
-	 * Register a calendar provider
252
-	 *
253
-	 * @param string $class
254
-	 * @psalm-param class-string<ICalendarProvider> $class
255
-	 * @since 23.0.0
256
-	 */
257
-	public function registerCalendarProvider(string $class): void;
250
+    /**
251
+     * Register a calendar provider
252
+     *
253
+     * @param string $class
254
+     * @psalm-param class-string<ICalendarProvider> $class
255
+     * @since 23.0.0
256
+     */
257
+    public function registerCalendarProvider(string $class): void;
258 258
 
259
-	/**
260
-	 * Register a reference provider
261
-	 *
262
-	 * @param string $class
263
-	 * @psalm-param class-string<IReferenceProvider> $class
264
-	 * @since 25.0.0
265
-	 */
266
-	public function registerReferenceProvider(string $class): void;
259
+    /**
260
+     * Register a reference provider
261
+     *
262
+     * @param string $class
263
+     * @psalm-param class-string<IReferenceProvider> $class
264
+     * @since 25.0.0
265
+     */
266
+    public function registerReferenceProvider(string $class): void;
267 267
 
268
-	/**
269
-	 * Register an implementation of \OCP\Profile\ILinkAction that
270
-	 * will handle the implementation of a profile link action
271
-	 *
272
-	 * @param string $actionClass
273
-	 * @psalm-param class-string<\OCP\Profile\ILinkAction> $actionClass
274
-	 * @return void
275
-	 * @since 23.0.0
276
-	 */
277
-	public function registerProfileLinkAction(string $actionClass): void;
268
+    /**
269
+     * Register an implementation of \OCP\Profile\ILinkAction that
270
+     * will handle the implementation of a profile link action
271
+     *
272
+     * @param string $actionClass
273
+     * @psalm-param class-string<\OCP\Profile\ILinkAction> $actionClass
274
+     * @return void
275
+     * @since 23.0.0
276
+     */
277
+    public function registerProfileLinkAction(string $actionClass): void;
278 278
 
279
-	/**
280
-	 * Register the backend of the Talk app
281
-	 *
282
-	 * This service must only be used by the Talk app
283
-	 *
284
-	 * @param string $backend
285
-	 * @return void
286
-	 * @since 24.0.0
287
-	 */
288
-	public function registerTalkBackend(string $backend): void;
279
+    /**
280
+     * Register the backend of the Talk app
281
+     *
282
+     * This service must only be used by the Talk app
283
+     *
284
+     * @param string $backend
285
+     * @return void
286
+     * @since 24.0.0
287
+     */
288
+    public function registerTalkBackend(string $backend): void;
289 289
 
290
-	/**
291
-	 * Register a resource backend for the DAV server
292
-	 *
293
-	 * @param string $actionClass
294
-	 * @psalm-param class-string<\OCP\Calendar\Resource\IBackend> $actionClass
295
-	 * @return void
296
-	 * @since 24.0.0
297
-	 */
298
-	public function registerCalendarResourceBackend(string $class): void;
290
+    /**
291
+     * Register a resource backend for the DAV server
292
+     *
293
+     * @param string $actionClass
294
+     * @psalm-param class-string<\OCP\Calendar\Resource\IBackend> $actionClass
295
+     * @return void
296
+     * @since 24.0.0
297
+     */
298
+    public function registerCalendarResourceBackend(string $class): void;
299 299
 
300
-	/**
301
-	 * Register a room backend for the DAV server
302
-	 *
303
-	 * @param string $actionClass
304
-	 * @psalm-param class-string<\OCP\Calendar\Room\IBackend> $actionClass
305
-	 * @return void
306
-	 * @since 24.0.0
307
-	 */
308
-	public function registerCalendarRoomBackend(string $class): void;
300
+    /**
301
+     * Register a room backend for the DAV server
302
+     *
303
+     * @param string $actionClass
304
+     * @psalm-param class-string<\OCP\Calendar\Room\IBackend> $actionClass
305
+     * @return void
306
+     * @since 24.0.0
307
+     */
308
+    public function registerCalendarRoomBackend(string $class): void;
309 309
 
310
-	/**
311
-	 * Register an implementation of \OCP\UserMigration\IMigrator that
312
-	 * will handle the implementation of a migrator
313
-	 *
314
-	 * @param string $migratorClass
315
-	 * @psalm-param class-string<\OCP\UserMigration\IMigrator> $migratorClass
316
-	 * @return void
317
-	 * @since 24.0.0
318
-	 */
319
-	public function registerUserMigrator(string $migratorClass): void;
310
+    /**
311
+     * Register an implementation of \OCP\UserMigration\IMigrator that
312
+     * will handle the implementation of a migrator
313
+     *
314
+     * @param string $migratorClass
315
+     * @psalm-param class-string<\OCP\UserMigration\IMigrator> $migratorClass
316
+     * @return void
317
+     * @since 24.0.0
318
+     */
319
+    public function registerUserMigrator(string $migratorClass): void;
320 320
 
321
-	/**
322
-	 * Announce methods of classes that may contain sensitive values, which
323
-	 * should be obfuscated before being logged.
324
-	 *
325
-	 * @param string $class
326
-	 * @param string[] $methods
327
-	 * @return void
328
-	 * @since 25.0.0
329
-	 */
330
-	public function registerSensitiveMethods(string $class, array $methods): void;
321
+    /**
322
+     * Announce methods of classes that may contain sensitive values, which
323
+     * should be obfuscated before being logged.
324
+     *
325
+     * @param string $class
326
+     * @param string[] $methods
327
+     * @return void
328
+     * @since 25.0.0
329
+     */
330
+    public function registerSensitiveMethods(string $class, array $methods): void;
331 331
 }
Please login to merge, or discard this patch.
lib/private/AppFramework/Bootstrap/MiddlewareRegistration.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -32,14 +32,14 @@
 block discarded – undo
32 32
  * @template-extends ServiceRegistration<Middleware>
33 33
  */
34 34
 class MiddlewareRegistration extends ServiceRegistration {
35
-	private bool $global;
35
+    private bool $global;
36 36
 
37
-	public function __construct(string $appId, string $service, bool $global) {
38
-		parent::__construct($appId, $service);
39
-		$this->global = $global;
40
-	}
37
+    public function __construct(string $appId, string $service, bool $global) {
38
+        parent::__construct($appId, $service);
39
+        $this->global = $global;
40
+    }
41 41
 
42
-	public function isGlobal(): bool {
43
-		return $this->global;
44
-	}
42
+    public function isGlobal(): bool {
43
+        return $this->global;
44
+    }
45 45
 }
Please login to merge, or discard this patch.
lib/private/AppFramework/Bootstrap/RegistrationContext.php 1 patch
Indentation   +666 added lines, -666 removed lines patch added patch discarded remove patch
@@ -58,684 +58,684 @@
 block discarded – undo
58 58
 use Throwable;
59 59
 
60 60
 class RegistrationContext {
61
-	/** @var ServiceRegistration<ICapability>[] */
62
-	private $capabilities = [];
61
+    /** @var ServiceRegistration<ICapability>[] */
62
+    private $capabilities = [];
63 63
 
64
-	/** @var ServiceRegistration<IReporter>[] */
65
-	private $crashReporters = [];
64
+    /** @var ServiceRegistration<IReporter>[] */
65
+    private $crashReporters = [];
66 66
 
67
-	/** @var ServiceRegistration<IWidget>[] */
68
-	private $dashboardPanels = [];
67
+    /** @var ServiceRegistration<IWidget>[] */
68
+    private $dashboardPanels = [];
69 69
 
70
-	/** @var ServiceRegistration<ILinkAction>[] */
71
-	private $profileLinkActions = [];
70
+    /** @var ServiceRegistration<ILinkAction>[] */
71
+    private $profileLinkActions = [];
72 72
 
73
-	/** @var null|ServiceRegistration<ITalkBackend> */
74
-	private $talkBackendRegistration = null;
73
+    /** @var null|ServiceRegistration<ITalkBackend> */
74
+    private $talkBackendRegistration = null;
75 75
 
76
-	/** @var ServiceRegistration<IResourceBackend>[] */
77
-	private $calendarResourceBackendRegistrations = [];
76
+    /** @var ServiceRegistration<IResourceBackend>[] */
77
+    private $calendarResourceBackendRegistrations = [];
78 78
 
79
-	/** @var ServiceRegistration<IRoomBackend>[] */
80
-	private $calendarRoomBackendRegistrations = [];
79
+    /** @var ServiceRegistration<IRoomBackend>[] */
80
+    private $calendarRoomBackendRegistrations = [];
81 81
 
82
-	/** @var ServiceRegistration<IUserMigrator>[] */
83
-	private $userMigrators = [];
82
+    /** @var ServiceRegistration<IUserMigrator>[] */
83
+    private $userMigrators = [];
84 84
 
85
-	/** @var ServiceFactoryRegistration[] */
86
-	private $services = [];
85
+    /** @var ServiceFactoryRegistration[] */
86
+    private $services = [];
87 87
 
88
-	/** @var ServiceAliasRegistration[] */
89
-	private $aliases = [];
88
+    /** @var ServiceAliasRegistration[] */
89
+    private $aliases = [];
90 90
 
91
-	/** @var ParameterRegistration[] */
92
-	private $parameters = [];
91
+    /** @var ParameterRegistration[] */
92
+    private $parameters = [];
93 93
 
94
-	/** @var EventListenerRegistration[] */
95
-	private $eventListeners = [];
94
+    /** @var EventListenerRegistration[] */
95
+    private $eventListeners = [];
96 96
 
97
-	/** @var MiddlewareRegistration[] */
98
-	private $middlewares = [];
97
+    /** @var MiddlewareRegistration[] */
98
+    private $middlewares = [];
99 99
 
100
-	/** @var ServiceRegistration<IProvider>[] */
101
-	private $searchProviders = [];
100
+    /** @var ServiceRegistration<IProvider>[] */
101
+    private $searchProviders = [];
102 102
 
103
-	/** @var ServiceRegistration<IAlternativeLogin>[] */
104
-	private $alternativeLogins = [];
105
-
106
-	/** @var ServiceRegistration<InitialStateProvider>[] */
107
-	private $initialStates = [];
108
-
109
-	/** @var ServiceRegistration<IHandler>[] */
110
-	private $wellKnownHandlers = [];
111
-
112
-	/** @var ServiceRegistration<ICustomTemplateProvider>[] */
113
-	private $templateProviders = [];
114
-
115
-	/** @var ServiceRegistration<INotifier>[] */
116
-	private $notifierServices = [];
117
-
118
-	/** @var ServiceRegistration<\OCP\Authentication\TwoFactorAuth\IProvider>[] */
119
-	private $twoFactorProviders = [];
120
-
121
-	/** @var ServiceRegistration<ICalendarProvider>[] */
122
-	private $calendarProviders = [];
123
-
124
-	/** @var ServiceRegistration<IReferenceProvider>[] */
125
-	private array $referenceProviders = [];
126
-
127
-	/** @var ParameterRegistration[] */
128
-	private $sensitiveMethods = [];
129
-
130
-	/** @var LoggerInterface */
131
-	private $logger;
132
-
133
-	/** @var PreviewProviderRegistration[] */
134
-	private $previewProviders = [];
135
-
136
-	public function __construct(LoggerInterface $logger) {
137
-		$this->logger = $logger;
138
-	}
139
-
140
-	public function for(string $appId): IRegistrationContext {
141
-		return new class($appId, $this) implements IRegistrationContext {
142
-			/** @var string */
143
-			private $appId;
144
-
145
-			/** @var RegistrationContext */
146
-			private $context;
147
-
148
-			public function __construct(string $appId, RegistrationContext $context) {
149
-				$this->appId = $appId;
150
-				$this->context = $context;
151
-			}
152
-
153
-			public function registerCapability(string $capability): void {
154
-				$this->context->registerCapability(
155
-					$this->appId,
156
-					$capability
157
-				);
158
-			}
159
-
160
-			public function registerCrashReporter(string $reporterClass): void {
161
-				$this->context->registerCrashReporter(
162
-					$this->appId,
163
-					$reporterClass
164
-				);
165
-			}
166
-
167
-			public function registerDashboardWidget(string $widgetClass): void {
168
-				$this->context->registerDashboardPanel(
169
-					$this->appId,
170
-					$widgetClass
171
-				);
172
-			}
173
-
174
-			public function registerService(string $name, callable $factory, bool $shared = true): void {
175
-				$this->context->registerService(
176
-					$this->appId,
177
-					$name,
178
-					$factory,
179
-					$shared
180
-				);
181
-			}
182
-
183
-			public function registerServiceAlias(string $alias, string $target): void {
184
-				$this->context->registerServiceAlias(
185
-					$this->appId,
186
-					$alias,
187
-					$target
188
-				);
189
-			}
190
-
191
-			public function registerParameter(string $name, $value): void {
192
-				$this->context->registerParameter(
193
-					$this->appId,
194
-					$name,
195
-					$value
196
-				);
197
-			}
198
-
199
-			public function registerEventListener(string $event, string $listener, int $priority = 0): void {
200
-				$this->context->registerEventListener(
201
-					$this->appId,
202
-					$event,
203
-					$listener,
204
-					$priority
205
-				);
206
-			}
207
-
208
-			public function registerMiddleware(string $class, bool $global = false): void {
209
-				$this->context->registerMiddleware(
210
-					$this->appId,
211
-					$class,
212
-					$global,
213
-				);
214
-			}
215
-
216
-			public function registerSearchProvider(string $class): void {
217
-				$this->context->registerSearchProvider(
218
-					$this->appId,
219
-					$class
220
-				);
221
-			}
222
-
223
-			public function registerAlternativeLogin(string $class): void {
224
-				$this->context->registerAlternativeLogin(
225
-					$this->appId,
226
-					$class
227
-				);
228
-			}
229
-
230
-			public function registerInitialStateProvider(string $class): void {
231
-				$this->context->registerInitialState(
232
-					$this->appId,
233
-					$class
234
-				);
235
-			}
236
-
237
-			public function registerWellKnownHandler(string $class): void {
238
-				$this->context->registerWellKnown(
239
-					$this->appId,
240
-					$class
241
-				);
242
-			}
243
-
244
-			public function registerTemplateProvider(string $providerClass): void {
245
-				$this->context->registerTemplateProvider(
246
-					$this->appId,
247
-					$providerClass
248
-				);
249
-			}
250
-
251
-			public function registerNotifierService(string $notifierClass): void {
252
-				$this->context->registerNotifierService(
253
-					$this->appId,
254
-					$notifierClass
255
-				);
256
-			}
257
-
258
-			public function registerTwoFactorProvider(string $twoFactorProviderClass): void {
259
-				$this->context->registerTwoFactorProvider(
260
-					$this->appId,
261
-					$twoFactorProviderClass
262
-				);
263
-			}
264
-
265
-			public function registerPreviewProvider(string $previewProviderClass, string $mimeTypeRegex): void {
266
-				$this->context->registerPreviewProvider(
267
-					$this->appId,
268
-					$previewProviderClass,
269
-					$mimeTypeRegex
270
-				);
271
-			}
272
-
273
-			public function registerCalendarProvider(string $class): void {
274
-				$this->context->registerCalendarProvider(
275
-					$this->appId,
276
-					$class
277
-				);
278
-			}
279
-
280
-			public function registerReferenceProvider(string $class): void {
281
-				$this->context->registerReferenceProvider(
282
-					$this->appId,
283
-					$class
284
-				);
285
-			}
286
-
287
-			public function registerProfileLinkAction(string $actionClass): void {
288
-				$this->context->registerProfileLinkAction(
289
-					$this->appId,
290
-					$actionClass
291
-				);
292
-			}
293
-
294
-			public function registerTalkBackend(string $backend): void {
295
-				$this->context->registerTalkBackend(
296
-					$this->appId,
297
-					$backend
298
-				);
299
-			}
300
-
301
-			public function registerCalendarResourceBackend(string $class): void {
302
-				$this->context->registerCalendarResourceBackend(
303
-					$this->appId,
304
-					$class
305
-				);
306
-			}
307
-
308
-			public function registerCalendarRoomBackend(string $class): void {
309
-				$this->context->registerCalendarRoomBackend(
310
-					$this->appId,
311
-					$class
312
-				);
313
-			}
314
-
315
-			public function registerUserMigrator(string $migratorClass): void {
316
-				$this->context->registerUserMigrator(
317
-					$this->appId,
318
-					$migratorClass
319
-				);
320
-			}
321
-
322
-			public function registerSensitiveMethods(string $class, array $methods): void {
323
-				$this->context->registerSensitiveMethods(
324
-					$this->appId,
325
-					$class,
326
-					$methods
327
-				);
328
-			}
329
-		};
330
-	}
331
-
332
-	/**
333
-	 * @psalm-param class-string<ICapability> $capability
334
-	 */
335
-	public function registerCapability(string $appId, string $capability): void {
336
-		$this->capabilities[] = new ServiceRegistration($appId, $capability);
337
-	}
338
-
339
-	/**
340
-	 * @psalm-param class-string<IReporter> $capability
341
-	 */
342
-	public function registerCrashReporter(string $appId, string $reporterClass): void {
343
-		$this->crashReporters[] = new ServiceRegistration($appId, $reporterClass);
344
-	}
345
-
346
-	/**
347
-	 * @psalm-param class-string<IWidget> $capability
348
-	 */
349
-	public function registerDashboardPanel(string $appId, string $panelClass): void {
350
-		$this->dashboardPanels[] = new ServiceRegistration($appId, $panelClass);
351
-	}
352
-
353
-	public function registerService(string $appId, string $name, callable $factory, bool $shared = true): void {
354
-		$this->services[] = new ServiceFactoryRegistration($appId, $name, $factory, $shared);
355
-	}
356
-
357
-	public function registerServiceAlias(string $appId, string $alias, string $target): void {
358
-		$this->aliases[] = new ServiceAliasRegistration($appId, $alias, $target);
359
-	}
360
-
361
-	public function registerParameter(string $appId, string $name, $value): void {
362
-		$this->parameters[] = new ParameterRegistration($appId, $name, $value);
363
-	}
364
-
365
-	public function registerEventListener(string $appId, string $event, string $listener, int $priority = 0): void {
366
-		$this->eventListeners[] = new EventListenerRegistration($appId, $event, $listener, $priority);
367
-	}
368
-
369
-	/**
370
-	 * @psalm-param class-string<Middleware> $class
371
-	 */
372
-	public function registerMiddleware(string $appId, string $class, bool $global): void {
373
-		$this->middlewares[] = new MiddlewareRegistration($appId, $class, $global);
374
-	}
375
-
376
-	public function registerSearchProvider(string $appId, string $class) {
377
-		$this->searchProviders[] = new ServiceRegistration($appId, $class);
378
-	}
379
-
380
-	public function registerAlternativeLogin(string $appId, string $class): void {
381
-		$this->alternativeLogins[] = new ServiceRegistration($appId, $class);
382
-	}
383
-
384
-	public function registerInitialState(string $appId, string $class): void {
385
-		$this->initialStates[] = new ServiceRegistration($appId, $class);
386
-	}
387
-
388
-	public function registerWellKnown(string $appId, string $class): void {
389
-		$this->wellKnownHandlers[] = new ServiceRegistration($appId, $class);
390
-	}
391
-
392
-	public function registerTemplateProvider(string $appId, string $class): void {
393
-		$this->templateProviders[] = new ServiceRegistration($appId, $class);
394
-	}
395
-
396
-	public function registerNotifierService(string $appId, string $class): void {
397
-		$this->notifierServices[] = new ServiceRegistration($appId, $class);
398
-	}
399
-
400
-	public function registerTwoFactorProvider(string $appId, string $class): void {
401
-		$this->twoFactorProviders[] = new ServiceRegistration($appId, $class);
402
-	}
403
-
404
-	public function registerPreviewProvider(string $appId, string $class, string $mimeTypeRegex): void {
405
-		$this->previewProviders[] = new PreviewProviderRegistration($appId, $class, $mimeTypeRegex);
406
-	}
407
-
408
-	public function registerCalendarProvider(string $appId, string $class): void {
409
-		$this->calendarProviders[] = new ServiceRegistration($appId, $class);
410
-	}
411
-
412
-	public function registerReferenceProvider(string $appId, string $class): void {
413
-		$this->referenceProviders[] = new ServiceRegistration($appId, $class);
414
-	}
415
-
416
-	/**
417
-	 * @psalm-param class-string<ILinkAction> $actionClass
418
-	 */
419
-	public function registerProfileLinkAction(string $appId, string $actionClass): void {
420
-		$this->profileLinkActions[] = new ServiceRegistration($appId, $actionClass);
421
-	}
422
-
423
-	/**
424
-	 * @psalm-param class-string<ITalkBackend> $backend
425
-	 */
426
-	public function registerTalkBackend(string $appId, string $backend) {
427
-		// Some safeguards for invalid registrations
428
-		if ($appId !== 'spreed') {
429
-			throw new RuntimeException("Only the Talk app is allowed to register a Talk backend");
430
-		}
431
-		if ($this->talkBackendRegistration !== null) {
432
-			throw new RuntimeException("There can only be one Talk backend");
433
-		}
434
-
435
-		$this->talkBackendRegistration = new ServiceRegistration($appId, $backend);
436
-	}
437
-
438
-	public function registerCalendarResourceBackend(string $appId, string $class) {
439
-		$this->calendarResourceBackendRegistrations[] = new ServiceRegistration(
440
-			$appId,
441
-			$class,
442
-		);
443
-	}
444
-
445
-	public function registerCalendarRoomBackend(string $appId, string $class) {
446
-		$this->calendarRoomBackendRegistrations[] = new ServiceRegistration(
447
-			$appId,
448
-			$class,
449
-		);
450
-	}
451
-
452
-	/**
453
-	 * @psalm-param class-string<IUserMigrator> $migratorClass
454
-	 */
455
-	public function registerUserMigrator(string $appId, string $migratorClass): void {
456
-		$this->userMigrators[] = new ServiceRegistration($appId, $migratorClass);
457
-	}
458
-
459
-	public function registerSensitiveMethods(string $appId, string $class, array $methods): void {
460
-		$methods = array_filter($methods, 'is_string');
461
-		$this->sensitiveMethods[] = new ParameterRegistration($appId, $class, $methods);
462
-	}
463
-
464
-	/**
465
-	 * @param App[] $apps
466
-	 */
467
-	public function delegateCapabilityRegistrations(array $apps): void {
468
-		while (($registration = array_shift($this->capabilities)) !== null) {
469
-			$appId = $registration->getAppId();
470
-			if (!isset($apps[$appId])) {
471
-				// If we land here something really isn't right. But at least we caught the
472
-				// notice that is otherwise emitted for the undefined index
473
-				$this->logger->error("App $appId not loaded for the capability registration");
474
-
475
-				continue;
476
-			}
477
-
478
-			try {
479
-				$apps[$appId]
480
-					->getContainer()
481
-					->registerCapability($registration->getService());
482
-			} catch (Throwable $e) {
483
-				$this->logger->error("Error during capability registration of $appId: " . $e->getMessage(), [
484
-					'exception' => $e,
485
-				]);
486
-			}
487
-		}
488
-	}
489
-
490
-	/**
491
-	 * @param App[] $apps
492
-	 */
493
-	public function delegateCrashReporterRegistrations(array $apps, Registry $registry): void {
494
-		while (($registration = array_shift($this->crashReporters)) !== null) {
495
-			try {
496
-				$registry->registerLazy($registration->getService());
497
-			} catch (Throwable $e) {
498
-				$appId = $registration->getAppId();
499
-				$this->logger->error("Error during crash reporter registration of $appId: " . $e->getMessage(), [
500
-					'exception' => $e,
501
-				]);
502
-			}
503
-		}
504
-	}
505
-
506
-	/**
507
-	 * @param App[] $apps
508
-	 */
509
-	public function delegateDashboardPanelRegistrations(IManager $dashboardManager): void {
510
-		while (($panel = array_shift($this->dashboardPanels)) !== null) {
511
-			try {
512
-				$dashboardManager->lazyRegisterWidget($panel->getService(), $panel->getAppId());
513
-			} catch (Throwable $e) {
514
-				$appId = $panel->getAppId();
515
-				$this->logger->error("Error during dashboard registration of $appId: " . $e->getMessage(), [
516
-					'exception' => $e,
517
-				]);
518
-			}
519
-		}
520
-	}
521
-
522
-	public function delegateEventListenerRegistrations(IEventDispatcher $eventDispatcher): void {
523
-		while (($registration = array_shift($this->eventListeners)) !== null) {
524
-			try {
525
-				$eventDispatcher->addServiceListener(
526
-					$registration->getEvent(),
527
-					$registration->getService(),
528
-					$registration->getPriority()
529
-				);
530
-			} catch (Throwable $e) {
531
-				$appId = $registration->getAppId();
532
-				$this->logger->error("Error during event listener registration of $appId: " . $e->getMessage(), [
533
-					'exception' => $e,
534
-				]);
535
-			}
536
-		}
537
-	}
538
-
539
-	/**
540
-	 * @param App[] $apps
541
-	 */
542
-	public function delegateContainerRegistrations(array $apps): void {
543
-		while (($registration = array_shift($this->services)) !== null) {
544
-			$appId = $registration->getAppId();
545
-			if (!isset($apps[$appId])) {
546
-				// If we land here something really isn't right. But at least we caught the
547
-				// notice that is otherwise emitted for the undefined index
548
-				$this->logger->error("App $appId not loaded for the container service registration");
549
-
550
-				continue;
551
-			}
552
-
553
-			try {
554
-				/**
555
-				 * Register the service and convert the callable into a \Closure if necessary
556
-				 */
557
-				$apps[$appId]
558
-					->getContainer()
559
-					->registerService(
560
-						$registration->getName(),
561
-						Closure::fromCallable($registration->getFactory()),
562
-						$registration->isShared()
563
-					);
564
-			} catch (Throwable $e) {
565
-				$this->logger->error("Error during service registration of $appId: " . $e->getMessage(), [
566
-					'exception' => $e,
567
-				]);
568
-			}
569
-		}
570
-
571
-		while (($registration = array_shift($this->aliases)) !== null) {
572
-			$appId = $registration->getAppId();
573
-			if (!isset($apps[$appId])) {
574
-				// If we land here something really isn't right. But at least we caught the
575
-				// notice that is otherwise emitted for the undefined index
576
-				$this->logger->error("App $appId not loaded for the container alias registration");
577
-
578
-				continue;
579
-			}
580
-
581
-			try {
582
-				$apps[$appId]
583
-					->getContainer()
584
-					->registerAlias(
585
-						$registration->getAlias(),
586
-						$registration->getTarget()
587
-					);
588
-			} catch (Throwable $e) {
589
-				$this->logger->error("Error during service alias registration of $appId: " . $e->getMessage(), [
590
-					'exception' => $e,
591
-				]);
592
-			}
593
-		}
594
-
595
-		while (($registration = array_shift($this->parameters)) !== null) {
596
-			$appId = $registration->getAppId();
597
-			if (!isset($apps[$appId])) {
598
-				// If we land here something really isn't right. But at least we caught the
599
-				// notice that is otherwise emitted for the undefined index
600
-				$this->logger->error("App $appId not loaded for the container parameter registration");
601
-
602
-				continue;
603
-			}
604
-
605
-			try {
606
-				$apps[$appId]
607
-					->getContainer()
608
-					->registerParameter(
609
-						$registration->getName(),
610
-						$registration->getValue()
611
-					);
612
-			} catch (Throwable $e) {
613
-				$this->logger->error("Error during service parameter registration of $appId: " . $e->getMessage(), [
614
-					'exception' => $e,
615
-				]);
616
-			}
617
-		}
618
-	}
619
-
620
-	/**
621
-	 * @return MiddlewareRegistration[]
622
-	 */
623
-	public function getMiddlewareRegistrations(): array {
624
-		return $this->middlewares;
625
-	}
626
-
627
-	/**
628
-	 * @return ServiceRegistration<IProvider>[]
629
-	 */
630
-	public function getSearchProviders(): array {
631
-		return $this->searchProviders;
632
-	}
633
-
634
-	/**
635
-	 * @return ServiceRegistration<IAlternativeLogin>[]
636
-	 */
637
-	public function getAlternativeLogins(): array {
638
-		return $this->alternativeLogins;
639
-	}
640
-
641
-	/**
642
-	 * @return ServiceRegistration<InitialStateProvider>[]
643
-	 */
644
-	public function getInitialStates(): array {
645
-		return $this->initialStates;
646
-	}
647
-
648
-	/**
649
-	 * @return ServiceRegistration<IHandler>[]
650
-	 */
651
-	public function getWellKnownHandlers(): array {
652
-		return $this->wellKnownHandlers;
653
-	}
654
-
655
-	/**
656
-	 * @return ServiceRegistration<ICustomTemplateProvider>[]
657
-	 */
658
-	public function getTemplateProviders(): array {
659
-		return $this->templateProviders;
660
-	}
661
-
662
-	/**
663
-	 * @return ServiceRegistration<INotifier>[]
664
-	 */
665
-	public function getNotifierServices(): array {
666
-		return $this->notifierServices;
667
-	}
668
-
669
-	/**
670
-	 * @return ServiceRegistration<\OCP\Authentication\TwoFactorAuth\IProvider>[]
671
-	 */
672
-	public function getTwoFactorProviders(): array {
673
-		return $this->twoFactorProviders;
674
-	}
675
-
676
-	/**
677
-	 * @return PreviewProviderRegistration[]
678
-	 */
679
-	public function getPreviewProviders(): array {
680
-		return $this->previewProviders;
681
-	}
682
-
683
-	/**
684
-	 * @return ServiceRegistration<ICalendarProvider>[]
685
-	 */
686
-	public function getCalendarProviders(): array {
687
-		return $this->calendarProviders;
688
-	}
689
-
690
-	/**
691
-	 * @return ServiceRegistration<IReferenceProvider>[]
692
-	 */
693
-	public function getReferenceProviders(): array {
694
-		return $this->referenceProviders;
695
-	}
696
-
697
-	/**
698
-	 * @return ServiceRegistration<ILinkAction>[]
699
-	 */
700
-	public function getProfileLinkActions(): array {
701
-		return $this->profileLinkActions;
702
-	}
703
-
704
-	/**
705
-	 * @return ServiceRegistration|null
706
-	 * @psalm-return ServiceRegistration<ITalkBackend>|null
707
-	 */
708
-	public function getTalkBackendRegistration(): ?ServiceRegistration {
709
-		return $this->talkBackendRegistration;
710
-	}
711
-
712
-	/**
713
-	 * @return ServiceRegistration[]
714
-	 * @psalm-return ServiceRegistration<IResourceBackend>[]
715
-	 */
716
-	public function getCalendarResourceBackendRegistrations(): array {
717
-		return $this->calendarResourceBackendRegistrations;
718
-	}
719
-
720
-	/**
721
-	 * @return ServiceRegistration[]
722
-	 * @psalm-return ServiceRegistration<IRoomBackend>[]
723
-	 */
724
-	public function getCalendarRoomBackendRegistrations(): array {
725
-		return $this->calendarRoomBackendRegistrations;
726
-	}
727
-
728
-	/**
729
-	 * @return ServiceRegistration<IUserMigrator>[]
730
-	 */
731
-	public function getUserMigrators(): array {
732
-		return $this->userMigrators;
733
-	}
734
-
735
-	/**
736
-	 * @return ParameterRegistration[]
737
-	 */
738
-	public function getSensitiveMethods(): array {
739
-		return $this->sensitiveMethods;
740
-	}
103
+    /** @var ServiceRegistration<IAlternativeLogin>[] */
104
+    private $alternativeLogins = [];
105
+
106
+    /** @var ServiceRegistration<InitialStateProvider>[] */
107
+    private $initialStates = [];
108
+
109
+    /** @var ServiceRegistration<IHandler>[] */
110
+    private $wellKnownHandlers = [];
111
+
112
+    /** @var ServiceRegistration<ICustomTemplateProvider>[] */
113
+    private $templateProviders = [];
114
+
115
+    /** @var ServiceRegistration<INotifier>[] */
116
+    private $notifierServices = [];
117
+
118
+    /** @var ServiceRegistration<\OCP\Authentication\TwoFactorAuth\IProvider>[] */
119
+    private $twoFactorProviders = [];
120
+
121
+    /** @var ServiceRegistration<ICalendarProvider>[] */
122
+    private $calendarProviders = [];
123
+
124
+    /** @var ServiceRegistration<IReferenceProvider>[] */
125
+    private array $referenceProviders = [];
126
+
127
+    /** @var ParameterRegistration[] */
128
+    private $sensitiveMethods = [];
129
+
130
+    /** @var LoggerInterface */
131
+    private $logger;
132
+
133
+    /** @var PreviewProviderRegistration[] */
134
+    private $previewProviders = [];
135
+
136
+    public function __construct(LoggerInterface $logger) {
137
+        $this->logger = $logger;
138
+    }
139
+
140
+    public function for(string $appId): IRegistrationContext {
141
+        return new class($appId, $this) implements IRegistrationContext {
142
+            /** @var string */
143
+            private $appId;
144
+
145
+            /** @var RegistrationContext */
146
+            private $context;
147
+
148
+            public function __construct(string $appId, RegistrationContext $context) {
149
+                $this->appId = $appId;
150
+                $this->context = $context;
151
+            }
152
+
153
+            public function registerCapability(string $capability): void {
154
+                $this->context->registerCapability(
155
+                    $this->appId,
156
+                    $capability
157
+                );
158
+            }
159
+
160
+            public function registerCrashReporter(string $reporterClass): void {
161
+                $this->context->registerCrashReporter(
162
+                    $this->appId,
163
+                    $reporterClass
164
+                );
165
+            }
166
+
167
+            public function registerDashboardWidget(string $widgetClass): void {
168
+                $this->context->registerDashboardPanel(
169
+                    $this->appId,
170
+                    $widgetClass
171
+                );
172
+            }
173
+
174
+            public function registerService(string $name, callable $factory, bool $shared = true): void {
175
+                $this->context->registerService(
176
+                    $this->appId,
177
+                    $name,
178
+                    $factory,
179
+                    $shared
180
+                );
181
+            }
182
+
183
+            public function registerServiceAlias(string $alias, string $target): void {
184
+                $this->context->registerServiceAlias(
185
+                    $this->appId,
186
+                    $alias,
187
+                    $target
188
+                );
189
+            }
190
+
191
+            public function registerParameter(string $name, $value): void {
192
+                $this->context->registerParameter(
193
+                    $this->appId,
194
+                    $name,
195
+                    $value
196
+                );
197
+            }
198
+
199
+            public function registerEventListener(string $event, string $listener, int $priority = 0): void {
200
+                $this->context->registerEventListener(
201
+                    $this->appId,
202
+                    $event,
203
+                    $listener,
204
+                    $priority
205
+                );
206
+            }
207
+
208
+            public function registerMiddleware(string $class, bool $global = false): void {
209
+                $this->context->registerMiddleware(
210
+                    $this->appId,
211
+                    $class,
212
+                    $global,
213
+                );
214
+            }
215
+
216
+            public function registerSearchProvider(string $class): void {
217
+                $this->context->registerSearchProvider(
218
+                    $this->appId,
219
+                    $class
220
+                );
221
+            }
222
+
223
+            public function registerAlternativeLogin(string $class): void {
224
+                $this->context->registerAlternativeLogin(
225
+                    $this->appId,
226
+                    $class
227
+                );
228
+            }
229
+
230
+            public function registerInitialStateProvider(string $class): void {
231
+                $this->context->registerInitialState(
232
+                    $this->appId,
233
+                    $class
234
+                );
235
+            }
236
+
237
+            public function registerWellKnownHandler(string $class): void {
238
+                $this->context->registerWellKnown(
239
+                    $this->appId,
240
+                    $class
241
+                );
242
+            }
243
+
244
+            public function registerTemplateProvider(string $providerClass): void {
245
+                $this->context->registerTemplateProvider(
246
+                    $this->appId,
247
+                    $providerClass
248
+                );
249
+            }
250
+
251
+            public function registerNotifierService(string $notifierClass): void {
252
+                $this->context->registerNotifierService(
253
+                    $this->appId,
254
+                    $notifierClass
255
+                );
256
+            }
257
+
258
+            public function registerTwoFactorProvider(string $twoFactorProviderClass): void {
259
+                $this->context->registerTwoFactorProvider(
260
+                    $this->appId,
261
+                    $twoFactorProviderClass
262
+                );
263
+            }
264
+
265
+            public function registerPreviewProvider(string $previewProviderClass, string $mimeTypeRegex): void {
266
+                $this->context->registerPreviewProvider(
267
+                    $this->appId,
268
+                    $previewProviderClass,
269
+                    $mimeTypeRegex
270
+                );
271
+            }
272
+
273
+            public function registerCalendarProvider(string $class): void {
274
+                $this->context->registerCalendarProvider(
275
+                    $this->appId,
276
+                    $class
277
+                );
278
+            }
279
+
280
+            public function registerReferenceProvider(string $class): void {
281
+                $this->context->registerReferenceProvider(
282
+                    $this->appId,
283
+                    $class
284
+                );
285
+            }
286
+
287
+            public function registerProfileLinkAction(string $actionClass): void {
288
+                $this->context->registerProfileLinkAction(
289
+                    $this->appId,
290
+                    $actionClass
291
+                );
292
+            }
293
+
294
+            public function registerTalkBackend(string $backend): void {
295
+                $this->context->registerTalkBackend(
296
+                    $this->appId,
297
+                    $backend
298
+                );
299
+            }
300
+
301
+            public function registerCalendarResourceBackend(string $class): void {
302
+                $this->context->registerCalendarResourceBackend(
303
+                    $this->appId,
304
+                    $class
305
+                );
306
+            }
307
+
308
+            public function registerCalendarRoomBackend(string $class): void {
309
+                $this->context->registerCalendarRoomBackend(
310
+                    $this->appId,
311
+                    $class
312
+                );
313
+            }
314
+
315
+            public function registerUserMigrator(string $migratorClass): void {
316
+                $this->context->registerUserMigrator(
317
+                    $this->appId,
318
+                    $migratorClass
319
+                );
320
+            }
321
+
322
+            public function registerSensitiveMethods(string $class, array $methods): void {
323
+                $this->context->registerSensitiveMethods(
324
+                    $this->appId,
325
+                    $class,
326
+                    $methods
327
+                );
328
+            }
329
+        };
330
+    }
331
+
332
+    /**
333
+     * @psalm-param class-string<ICapability> $capability
334
+     */
335
+    public function registerCapability(string $appId, string $capability): void {
336
+        $this->capabilities[] = new ServiceRegistration($appId, $capability);
337
+    }
338
+
339
+    /**
340
+     * @psalm-param class-string<IReporter> $capability
341
+     */
342
+    public function registerCrashReporter(string $appId, string $reporterClass): void {
343
+        $this->crashReporters[] = new ServiceRegistration($appId, $reporterClass);
344
+    }
345
+
346
+    /**
347
+     * @psalm-param class-string<IWidget> $capability
348
+     */
349
+    public function registerDashboardPanel(string $appId, string $panelClass): void {
350
+        $this->dashboardPanels[] = new ServiceRegistration($appId, $panelClass);
351
+    }
352
+
353
+    public function registerService(string $appId, string $name, callable $factory, bool $shared = true): void {
354
+        $this->services[] = new ServiceFactoryRegistration($appId, $name, $factory, $shared);
355
+    }
356
+
357
+    public function registerServiceAlias(string $appId, string $alias, string $target): void {
358
+        $this->aliases[] = new ServiceAliasRegistration($appId, $alias, $target);
359
+    }
360
+
361
+    public function registerParameter(string $appId, string $name, $value): void {
362
+        $this->parameters[] = new ParameterRegistration($appId, $name, $value);
363
+    }
364
+
365
+    public function registerEventListener(string $appId, string $event, string $listener, int $priority = 0): void {
366
+        $this->eventListeners[] = new EventListenerRegistration($appId, $event, $listener, $priority);
367
+    }
368
+
369
+    /**
370
+     * @psalm-param class-string<Middleware> $class
371
+     */
372
+    public function registerMiddleware(string $appId, string $class, bool $global): void {
373
+        $this->middlewares[] = new MiddlewareRegistration($appId, $class, $global);
374
+    }
375
+
376
+    public function registerSearchProvider(string $appId, string $class) {
377
+        $this->searchProviders[] = new ServiceRegistration($appId, $class);
378
+    }
379
+
380
+    public function registerAlternativeLogin(string $appId, string $class): void {
381
+        $this->alternativeLogins[] = new ServiceRegistration($appId, $class);
382
+    }
383
+
384
+    public function registerInitialState(string $appId, string $class): void {
385
+        $this->initialStates[] = new ServiceRegistration($appId, $class);
386
+    }
387
+
388
+    public function registerWellKnown(string $appId, string $class): void {
389
+        $this->wellKnownHandlers[] = new ServiceRegistration($appId, $class);
390
+    }
391
+
392
+    public function registerTemplateProvider(string $appId, string $class): void {
393
+        $this->templateProviders[] = new ServiceRegistration($appId, $class);
394
+    }
395
+
396
+    public function registerNotifierService(string $appId, string $class): void {
397
+        $this->notifierServices[] = new ServiceRegistration($appId, $class);
398
+    }
399
+
400
+    public function registerTwoFactorProvider(string $appId, string $class): void {
401
+        $this->twoFactorProviders[] = new ServiceRegistration($appId, $class);
402
+    }
403
+
404
+    public function registerPreviewProvider(string $appId, string $class, string $mimeTypeRegex): void {
405
+        $this->previewProviders[] = new PreviewProviderRegistration($appId, $class, $mimeTypeRegex);
406
+    }
407
+
408
+    public function registerCalendarProvider(string $appId, string $class): void {
409
+        $this->calendarProviders[] = new ServiceRegistration($appId, $class);
410
+    }
411
+
412
+    public function registerReferenceProvider(string $appId, string $class): void {
413
+        $this->referenceProviders[] = new ServiceRegistration($appId, $class);
414
+    }
415
+
416
+    /**
417
+     * @psalm-param class-string<ILinkAction> $actionClass
418
+     */
419
+    public function registerProfileLinkAction(string $appId, string $actionClass): void {
420
+        $this->profileLinkActions[] = new ServiceRegistration($appId, $actionClass);
421
+    }
422
+
423
+    /**
424
+     * @psalm-param class-string<ITalkBackend> $backend
425
+     */
426
+    public function registerTalkBackend(string $appId, string $backend) {
427
+        // Some safeguards for invalid registrations
428
+        if ($appId !== 'spreed') {
429
+            throw new RuntimeException("Only the Talk app is allowed to register a Talk backend");
430
+        }
431
+        if ($this->talkBackendRegistration !== null) {
432
+            throw new RuntimeException("There can only be one Talk backend");
433
+        }
434
+
435
+        $this->talkBackendRegistration = new ServiceRegistration($appId, $backend);
436
+    }
437
+
438
+    public function registerCalendarResourceBackend(string $appId, string $class) {
439
+        $this->calendarResourceBackendRegistrations[] = new ServiceRegistration(
440
+            $appId,
441
+            $class,
442
+        );
443
+    }
444
+
445
+    public function registerCalendarRoomBackend(string $appId, string $class) {
446
+        $this->calendarRoomBackendRegistrations[] = new ServiceRegistration(
447
+            $appId,
448
+            $class,
449
+        );
450
+    }
451
+
452
+    /**
453
+     * @psalm-param class-string<IUserMigrator> $migratorClass
454
+     */
455
+    public function registerUserMigrator(string $appId, string $migratorClass): void {
456
+        $this->userMigrators[] = new ServiceRegistration($appId, $migratorClass);
457
+    }
458
+
459
+    public function registerSensitiveMethods(string $appId, string $class, array $methods): void {
460
+        $methods = array_filter($methods, 'is_string');
461
+        $this->sensitiveMethods[] = new ParameterRegistration($appId, $class, $methods);
462
+    }
463
+
464
+    /**
465
+     * @param App[] $apps
466
+     */
467
+    public function delegateCapabilityRegistrations(array $apps): void {
468
+        while (($registration = array_shift($this->capabilities)) !== null) {
469
+            $appId = $registration->getAppId();
470
+            if (!isset($apps[$appId])) {
471
+                // If we land here something really isn't right. But at least we caught the
472
+                // notice that is otherwise emitted for the undefined index
473
+                $this->logger->error("App $appId not loaded for the capability registration");
474
+
475
+                continue;
476
+            }
477
+
478
+            try {
479
+                $apps[$appId]
480
+                    ->getContainer()
481
+                    ->registerCapability($registration->getService());
482
+            } catch (Throwable $e) {
483
+                $this->logger->error("Error during capability registration of $appId: " . $e->getMessage(), [
484
+                    'exception' => $e,
485
+                ]);
486
+            }
487
+        }
488
+    }
489
+
490
+    /**
491
+     * @param App[] $apps
492
+     */
493
+    public function delegateCrashReporterRegistrations(array $apps, Registry $registry): void {
494
+        while (($registration = array_shift($this->crashReporters)) !== null) {
495
+            try {
496
+                $registry->registerLazy($registration->getService());
497
+            } catch (Throwable $e) {
498
+                $appId = $registration->getAppId();
499
+                $this->logger->error("Error during crash reporter registration of $appId: " . $e->getMessage(), [
500
+                    'exception' => $e,
501
+                ]);
502
+            }
503
+        }
504
+    }
505
+
506
+    /**
507
+     * @param App[] $apps
508
+     */
509
+    public function delegateDashboardPanelRegistrations(IManager $dashboardManager): void {
510
+        while (($panel = array_shift($this->dashboardPanels)) !== null) {
511
+            try {
512
+                $dashboardManager->lazyRegisterWidget($panel->getService(), $panel->getAppId());
513
+            } catch (Throwable $e) {
514
+                $appId = $panel->getAppId();
515
+                $this->logger->error("Error during dashboard registration of $appId: " . $e->getMessage(), [
516
+                    'exception' => $e,
517
+                ]);
518
+            }
519
+        }
520
+    }
521
+
522
+    public function delegateEventListenerRegistrations(IEventDispatcher $eventDispatcher): void {
523
+        while (($registration = array_shift($this->eventListeners)) !== null) {
524
+            try {
525
+                $eventDispatcher->addServiceListener(
526
+                    $registration->getEvent(),
527
+                    $registration->getService(),
528
+                    $registration->getPriority()
529
+                );
530
+            } catch (Throwable $e) {
531
+                $appId = $registration->getAppId();
532
+                $this->logger->error("Error during event listener registration of $appId: " . $e->getMessage(), [
533
+                    'exception' => $e,
534
+                ]);
535
+            }
536
+        }
537
+    }
538
+
539
+    /**
540
+     * @param App[] $apps
541
+     */
542
+    public function delegateContainerRegistrations(array $apps): void {
543
+        while (($registration = array_shift($this->services)) !== null) {
544
+            $appId = $registration->getAppId();
545
+            if (!isset($apps[$appId])) {
546
+                // If we land here something really isn't right. But at least we caught the
547
+                // notice that is otherwise emitted for the undefined index
548
+                $this->logger->error("App $appId not loaded for the container service registration");
549
+
550
+                continue;
551
+            }
552
+
553
+            try {
554
+                /**
555
+                 * Register the service and convert the callable into a \Closure if necessary
556
+                 */
557
+                $apps[$appId]
558
+                    ->getContainer()
559
+                    ->registerService(
560
+                        $registration->getName(),
561
+                        Closure::fromCallable($registration->getFactory()),
562
+                        $registration->isShared()
563
+                    );
564
+            } catch (Throwable $e) {
565
+                $this->logger->error("Error during service registration of $appId: " . $e->getMessage(), [
566
+                    'exception' => $e,
567
+                ]);
568
+            }
569
+        }
570
+
571
+        while (($registration = array_shift($this->aliases)) !== null) {
572
+            $appId = $registration->getAppId();
573
+            if (!isset($apps[$appId])) {
574
+                // If we land here something really isn't right. But at least we caught the
575
+                // notice that is otherwise emitted for the undefined index
576
+                $this->logger->error("App $appId not loaded for the container alias registration");
577
+
578
+                continue;
579
+            }
580
+
581
+            try {
582
+                $apps[$appId]
583
+                    ->getContainer()
584
+                    ->registerAlias(
585
+                        $registration->getAlias(),
586
+                        $registration->getTarget()
587
+                    );
588
+            } catch (Throwable $e) {
589
+                $this->logger->error("Error during service alias registration of $appId: " . $e->getMessage(), [
590
+                    'exception' => $e,
591
+                ]);
592
+            }
593
+        }
594
+
595
+        while (($registration = array_shift($this->parameters)) !== null) {
596
+            $appId = $registration->getAppId();
597
+            if (!isset($apps[$appId])) {
598
+                // If we land here something really isn't right. But at least we caught the
599
+                // notice that is otherwise emitted for the undefined index
600
+                $this->logger->error("App $appId not loaded for the container parameter registration");
601
+
602
+                continue;
603
+            }
604
+
605
+            try {
606
+                $apps[$appId]
607
+                    ->getContainer()
608
+                    ->registerParameter(
609
+                        $registration->getName(),
610
+                        $registration->getValue()
611
+                    );
612
+            } catch (Throwable $e) {
613
+                $this->logger->error("Error during service parameter registration of $appId: " . $e->getMessage(), [
614
+                    'exception' => $e,
615
+                ]);
616
+            }
617
+        }
618
+    }
619
+
620
+    /**
621
+     * @return MiddlewareRegistration[]
622
+     */
623
+    public function getMiddlewareRegistrations(): array {
624
+        return $this->middlewares;
625
+    }
626
+
627
+    /**
628
+     * @return ServiceRegistration<IProvider>[]
629
+     */
630
+    public function getSearchProviders(): array {
631
+        return $this->searchProviders;
632
+    }
633
+
634
+    /**
635
+     * @return ServiceRegistration<IAlternativeLogin>[]
636
+     */
637
+    public function getAlternativeLogins(): array {
638
+        return $this->alternativeLogins;
639
+    }
640
+
641
+    /**
642
+     * @return ServiceRegistration<InitialStateProvider>[]
643
+     */
644
+    public function getInitialStates(): array {
645
+        return $this->initialStates;
646
+    }
647
+
648
+    /**
649
+     * @return ServiceRegistration<IHandler>[]
650
+     */
651
+    public function getWellKnownHandlers(): array {
652
+        return $this->wellKnownHandlers;
653
+    }
654
+
655
+    /**
656
+     * @return ServiceRegistration<ICustomTemplateProvider>[]
657
+     */
658
+    public function getTemplateProviders(): array {
659
+        return $this->templateProviders;
660
+    }
661
+
662
+    /**
663
+     * @return ServiceRegistration<INotifier>[]
664
+     */
665
+    public function getNotifierServices(): array {
666
+        return $this->notifierServices;
667
+    }
668
+
669
+    /**
670
+     * @return ServiceRegistration<\OCP\Authentication\TwoFactorAuth\IProvider>[]
671
+     */
672
+    public function getTwoFactorProviders(): array {
673
+        return $this->twoFactorProviders;
674
+    }
675
+
676
+    /**
677
+     * @return PreviewProviderRegistration[]
678
+     */
679
+    public function getPreviewProviders(): array {
680
+        return $this->previewProviders;
681
+    }
682
+
683
+    /**
684
+     * @return ServiceRegistration<ICalendarProvider>[]
685
+     */
686
+    public function getCalendarProviders(): array {
687
+        return $this->calendarProviders;
688
+    }
689
+
690
+    /**
691
+     * @return ServiceRegistration<IReferenceProvider>[]
692
+     */
693
+    public function getReferenceProviders(): array {
694
+        return $this->referenceProviders;
695
+    }
696
+
697
+    /**
698
+     * @return ServiceRegistration<ILinkAction>[]
699
+     */
700
+    public function getProfileLinkActions(): array {
701
+        return $this->profileLinkActions;
702
+    }
703
+
704
+    /**
705
+     * @return ServiceRegistration|null
706
+     * @psalm-return ServiceRegistration<ITalkBackend>|null
707
+     */
708
+    public function getTalkBackendRegistration(): ?ServiceRegistration {
709
+        return $this->talkBackendRegistration;
710
+    }
711
+
712
+    /**
713
+     * @return ServiceRegistration[]
714
+     * @psalm-return ServiceRegistration<IResourceBackend>[]
715
+     */
716
+    public function getCalendarResourceBackendRegistrations(): array {
717
+        return $this->calendarResourceBackendRegistrations;
718
+    }
719
+
720
+    /**
721
+     * @return ServiceRegistration[]
722
+     * @psalm-return ServiceRegistration<IRoomBackend>[]
723
+     */
724
+    public function getCalendarRoomBackendRegistrations(): array {
725
+        return $this->calendarRoomBackendRegistrations;
726
+    }
727
+
728
+    /**
729
+     * @return ServiceRegistration<IUserMigrator>[]
730
+     */
731
+    public function getUserMigrators(): array {
732
+        return $this->userMigrators;
733
+    }
734
+
735
+    /**
736
+     * @return ParameterRegistration[]
737
+     */
738
+    public function getSensitiveMethods(): array {
739
+        return $this->sensitiveMethods;
740
+    }
741 741
 }
Please login to merge, or discard this patch.
lib/private/AppFramework/DependencyInjection/DIContainer.php 1 patch
Indentation   +417 added lines, -417 removed lines patch added patch discarded remove patch
@@ -79,421 +79,421 @@
 block discarded – undo
79 79
  * @deprecated 20.0.0
80 80
  */
81 81
 class DIContainer extends SimpleContainer implements IAppContainer {
82
-	private string $appName;
83
-
84
-	/**
85
-	 * @var array
86
-	 */
87
-	private $middleWares = [];
88
-
89
-	/** @var ServerContainer */
90
-	private $server;
91
-
92
-	/**
93
-	 * Put your class dependencies in here
94
-	 * @param string $appName the name of the app
95
-	 * @param array $urlParams
96
-	 * @param ServerContainer|null $server
97
-	 */
98
-	public function __construct(string $appName, array $urlParams = [], ServerContainer $server = null) {
99
-		parent::__construct();
100
-		$this->appName = $appName;
101
-		$this['appName'] = $appName;
102
-		$this['urlParams'] = $urlParams;
103
-
104
-		$this->registerAlias('Request', IRequest::class);
105
-
106
-		/** @var \OC\ServerContainer $server */
107
-		if ($server === null) {
108
-			$server = \OC::$server;
109
-		}
110
-		$this->server = $server;
111
-		$this->server->registerAppContainer($appName, $this);
112
-
113
-		// aliases
114
-		/** @deprecated inject $appName */
115
-		$this->registerAlias('AppName', 'appName');
116
-		/** @deprecated inject $webRoot*/
117
-		$this->registerAlias('WebRoot', 'webRoot');
118
-		/** @deprecated inject $userId */
119
-		$this->registerAlias('UserId', 'userId');
120
-
121
-		/**
122
-		 * Core services
123
-		 */
124
-		$this->registerService(IOutput::class, function () {
125
-			return new Output($this->getServer()->getWebRoot());
126
-		});
127
-
128
-		$this->registerService(Folder::class, function () {
129
-			return $this->getServer()->getUserFolder();
130
-		});
131
-
132
-		$this->registerService(IAppData::class, function (ContainerInterface $c) {
133
-			return $this->getServer()->getAppDataDir($c->get('AppName'));
134
-		});
135
-
136
-		$this->registerService(IL10N::class, function (ContainerInterface $c) {
137
-			return $this->getServer()->getL10N($c->get('AppName'));
138
-		});
139
-
140
-		// Log wrappers
141
-		$this->registerService(LoggerInterface::class, function (ContainerInterface $c) {
142
-			return new ScopedPsrLogger(
143
-				$c->get(PsrLoggerAdapter::class),
144
-				$c->get('AppName')
145
-			);
146
-		});
147
-		$this->registerService(ILogger::class, function (ContainerInterface $c) {
148
-			return new OC\AppFramework\Logger($this->server->query(ILogger::class), $c->get('AppName'));
149
-		});
150
-
151
-		$this->registerService(IServerContainer::class, function () {
152
-			return $this->getServer();
153
-		});
154
-		$this->registerAlias('ServerContainer', IServerContainer::class);
155
-
156
-		$this->registerService(\OCP\WorkflowEngine\IManager::class, function (ContainerInterface $c) {
157
-			return $c->get(Manager::class);
158
-		});
159
-
160
-		$this->registerService(ContainerInterface::class, function (ContainerInterface $c) {
161
-			return $c;
162
-		});
163
-		$this->registerAlias(IAppContainer::class, ContainerInterface::class);
164
-
165
-		// commonly used attributes
166
-		$this->registerService('userId', function (ContainerInterface $c) {
167
-			return $c->get(IUserSession::class)->getSession()->get('user_id');
168
-		});
169
-
170
-		$this->registerService('webRoot', function (ContainerInterface $c) {
171
-			return $c->get(IServerContainer::class)->getWebRoot();
172
-		});
173
-
174
-		$this->registerService('OC_Defaults', function (ContainerInterface $c) {
175
-			return $c->get(IServerContainer::class)->getThemingDefaults();
176
-		});
177
-
178
-		$this->registerService('Protocol', function (ContainerInterface $c) {
179
-			/** @var \OC\Server $server */
180
-			$server = $c->get(IServerContainer::class);
181
-			$protocol = $server->getRequest()->getHttpProtocol();
182
-			return new Http($_SERVER, $protocol);
183
-		});
184
-
185
-		$this->registerService('Dispatcher', function (ContainerInterface $c) {
186
-			return new Dispatcher(
187
-				$c->get('Protocol'),
188
-				$c->get(MiddlewareDispatcher::class),
189
-				$c->get(IControllerMethodReflector::class),
190
-				$c->get(IRequest::class),
191
-				$c->get(IConfig::class),
192
-				$c->get(IDBConnection::class),
193
-				$c->get(LoggerInterface::class),
194
-				$c->get(EventLogger::class),
195
-				$c,
196
-			);
197
-		});
198
-
199
-		/**
200
-		 * App Framework default arguments
201
-		 */
202
-		$this->registerParameter('corsMethods', 'PUT, POST, GET, DELETE, PATCH');
203
-		$this->registerParameter('corsAllowedHeaders', 'Authorization, Content-Type, Accept');
204
-		$this->registerParameter('corsMaxAge', 1728000);
205
-
206
-		/**
207
-		 * Middleware
208
-		 */
209
-		$this->registerAlias('MiddlewareDispatcher', MiddlewareDispatcher::class);
210
-		$this->registerService(MiddlewareDispatcher::class, function (ContainerInterface $c) {
211
-			$server = $this->getServer();
212
-
213
-			$dispatcher = new MiddlewareDispatcher();
214
-
215
-			$dispatcher->registerMiddleware(
216
-				$c->get(OC\AppFramework\Middleware\CompressionMiddleware::class)
217
-			);
218
-
219
-			$dispatcher->registerMiddleware($c->get(OC\AppFramework\Middleware\NotModifiedMiddleware::class));
220
-
221
-			$dispatcher->registerMiddleware(
222
-				$c->get(OC\AppFramework\Middleware\Security\ReloadExecutionMiddleware::class)
223
-			);
224
-
225
-			$dispatcher->registerMiddleware(
226
-				new OC\AppFramework\Middleware\Security\SameSiteCookieMiddleware(
227
-					$c->get(IRequest::class),
228
-					$c->get(IControllerMethodReflector::class)
229
-				)
230
-			);
231
-			$dispatcher->registerMiddleware(
232
-				new CORSMiddleware(
233
-					$c->get(IRequest::class),
234
-					$c->get(IControllerMethodReflector::class),
235
-					$c->get(IUserSession::class),
236
-					$c->get(OC\Security\Bruteforce\Throttler::class)
237
-				)
238
-			);
239
-			$dispatcher->registerMiddleware(
240
-				new OCSMiddleware(
241
-					$c->get(IRequest::class)
242
-				)
243
-			);
244
-
245
-
246
-
247
-			$securityMiddleware = new SecurityMiddleware(
248
-				$c->get(IRequest::class),
249
-				$c->get(IControllerMethodReflector::class),
250
-				$c->get(INavigationManager::class),
251
-				$c->get(IURLGenerator::class),
252
-				$server->get(LoggerInterface::class),
253
-				$c->get('AppName'),
254
-				$server->getUserSession()->isLoggedIn(),
255
-				$this->getUserId() !== null && $server->getGroupManager()->isAdmin($this->getUserId()),
256
-				$server->getUserSession()->getUser() !== null && $server->query(ISubAdmin::class)->isSubAdmin($server->getUserSession()->getUser()),
257
-				$server->getAppManager(),
258
-				$server->getL10N('lib'),
259
-				$c->get(AuthorizedGroupMapper::class),
260
-				$server->get(IUserSession::class)
261
-			);
262
-			$dispatcher->registerMiddleware($securityMiddleware);
263
-			$dispatcher->registerMiddleware(
264
-				new OC\AppFramework\Middleware\Security\CSPMiddleware(
265
-					$server->query(OC\Security\CSP\ContentSecurityPolicyManager::class),
266
-					$server->query(OC\Security\CSP\ContentSecurityPolicyNonceManager::class),
267
-					$server->query(OC\Security\CSRF\CsrfTokenManager::class)
268
-				)
269
-			);
270
-			$dispatcher->registerMiddleware(
271
-				$server->query(OC\AppFramework\Middleware\Security\FeaturePolicyMiddleware::class)
272
-			);
273
-			$dispatcher->registerMiddleware(
274
-				new OC\AppFramework\Middleware\Security\PasswordConfirmationMiddleware(
275
-					$c->get(IControllerMethodReflector::class),
276
-					$c->get(ISession::class),
277
-					$c->get(IUserSession::class),
278
-					$c->get(ITimeFactory::class)
279
-				)
280
-			);
281
-			$dispatcher->registerMiddleware(
282
-				new TwoFactorMiddleware(
283
-					$c->get(OC\Authentication\TwoFactorAuth\Manager::class),
284
-					$c->get(IUserSession::class),
285
-					$c->get(ISession::class),
286
-					$c->get(IURLGenerator::class),
287
-					$c->get(IControllerMethodReflector::class),
288
-					$c->get(IRequest::class)
289
-				)
290
-			);
291
-			$dispatcher->registerMiddleware(
292
-				new OC\AppFramework\Middleware\Security\BruteForceMiddleware(
293
-					$c->get(IControllerMethodReflector::class),
294
-					$c->get(OC\Security\Bruteforce\Throttler::class),
295
-					$c->get(IRequest::class)
296
-				)
297
-			);
298
-			$dispatcher->registerMiddleware(
299
-				new RateLimitingMiddleware(
300
-					$c->get(IRequest::class),
301
-					$c->get(IUserSession::class),
302
-					$c->get(IControllerMethodReflector::class),
303
-					$c->get(OC\Security\RateLimiting\Limiter::class)
304
-				)
305
-			);
306
-			$dispatcher->registerMiddleware(
307
-				new OC\AppFramework\Middleware\PublicShare\PublicShareMiddleware(
308
-					$c->get(IRequest::class),
309
-					$c->get(ISession::class),
310
-					$c->get(\OCP\IConfig::class),
311
-					$c->get(OC\Security\Bruteforce\Throttler::class)
312
-				)
313
-			);
314
-			$dispatcher->registerMiddleware(
315
-				$c->get(\OC\AppFramework\Middleware\AdditionalScriptsMiddleware::class)
316
-			);
317
-
318
-			/** @var \OC\AppFramework\Bootstrap\Coordinator $coordinator */
319
-			$coordinator = $c->get(\OC\AppFramework\Bootstrap\Coordinator::class);
320
-			$registrationContext = $coordinator->getRegistrationContext();
321
-			if ($registrationContext !== null) {
322
-				$appId = $this->getAppName();
323
-				foreach ($registrationContext->getMiddlewareRegistrations() as $middlewareRegistration) {
324
-					if ($middlewareRegistration->getAppId() === $appId
325
-						|| $middlewareRegistration->isGlobal()) {
326
-						$dispatcher->registerMiddleware($c->get($middlewareRegistration->getService()));
327
-					}
328
-				}
329
-			}
330
-			foreach ($this->middleWares as $middleWare) {
331
-				$dispatcher->registerMiddleware($c->get($middleWare));
332
-			}
333
-
334
-			$dispatcher->registerMiddleware(
335
-				new SessionMiddleware(
336
-					$c->get(IControllerMethodReflector::class),
337
-					$c->get(ISession::class)
338
-				)
339
-			);
340
-			return $dispatcher;
341
-		});
342
-
343
-		$this->registerService(IAppConfig::class, function (ContainerInterface $c) {
344
-			return new OC\AppFramework\Services\AppConfig(
345
-				$c->get(IConfig::class),
346
-				$c->get('AppName')
347
-			);
348
-		});
349
-		$this->registerService(IInitialState::class, function (ContainerInterface $c) {
350
-			return new OC\AppFramework\Services\InitialState(
351
-				$c->get(IInitialStateService::class),
352
-				$c->get('AppName')
353
-			);
354
-		});
355
-	}
356
-
357
-	/**
358
-	 * @return \OCP\IServerContainer
359
-	 */
360
-	public function getServer() {
361
-		return $this->server;
362
-	}
363
-
364
-	/**
365
-	 * @param string $middleWare
366
-	 * @return boolean|null
367
-	 */
368
-	public function registerMiddleWare($middleWare) {
369
-		if (in_array($middleWare, $this->middleWares, true) !== false) {
370
-			return false;
371
-		}
372
-		$this->middleWares[] = $middleWare;
373
-	}
374
-
375
-	/**
376
-	 * used to return the appname of the set application
377
-	 * @return string the name of your application
378
-	 */
379
-	public function getAppName() {
380
-		return $this->query('AppName');
381
-	}
382
-
383
-	/**
384
-	 * @deprecated use IUserSession->isLoggedIn()
385
-	 * @return boolean
386
-	 */
387
-	public function isLoggedIn() {
388
-		return \OC::$server->getUserSession()->isLoggedIn();
389
-	}
390
-
391
-	/**
392
-	 * @deprecated use IGroupManager->isAdmin($userId)
393
-	 * @return boolean
394
-	 */
395
-	public function isAdminUser() {
396
-		$uid = $this->getUserId();
397
-		return \OC_User::isAdminUser($uid);
398
-	}
399
-
400
-	private function getUserId() {
401
-		return $this->getServer()->getSession()->get('user_id');
402
-	}
403
-
404
-	/**
405
-	 * @deprecated use the ILogger instead
406
-	 * @param string $message
407
-	 * @param string $level
408
-	 * @return mixed
409
-	 */
410
-	public function log($message, $level) {
411
-		switch ($level) {
412
-			case 'debug':
413
-				$level = ILogger::DEBUG;
414
-				break;
415
-			case 'info':
416
-				$level = ILogger::INFO;
417
-				break;
418
-			case 'warn':
419
-				$level = ILogger::WARN;
420
-				break;
421
-			case 'fatal':
422
-				$level = ILogger::FATAL;
423
-				break;
424
-			default:
425
-				$level = ILogger::ERROR;
426
-				break;
427
-		}
428
-		\OCP\Util::writeLog($this->getAppName(), $message, $level);
429
-	}
430
-
431
-	/**
432
-	 * Register a capability
433
-	 *
434
-	 * @param string $serviceName e.g. 'OCA\Files\Capabilities'
435
-	 */
436
-	public function registerCapability($serviceName) {
437
-		$this->query('OC\CapabilitiesManager')->registerCapability(function () use ($serviceName) {
438
-			return $this->query($serviceName);
439
-		});
440
-	}
441
-
442
-	public function has($id): bool {
443
-		if (parent::has($id)) {
444
-			return true;
445
-		}
446
-
447
-		if ($this->server->has($id, true)) {
448
-			return true;
449
-		}
450
-
451
-		return false;
452
-	}
453
-
454
-	public function query(string $name, bool $autoload = true) {
455
-		if ($name === 'AppName' || $name === 'appName') {
456
-			return $this->appName;
457
-		}
458
-
459
-		$isServerClass = str_starts_with($name, 'OCP\\') || str_starts_with($name, 'OC\\');
460
-		if ($isServerClass && !$this->has($name)) {
461
-			return $this->getServer()->query($name, $autoload);
462
-		}
463
-
464
-		try {
465
-			return $this->queryNoFallback($name);
466
-		} catch (QueryException $firstException) {
467
-			try {
468
-				return $this->getServer()->query($name, $autoload);
469
-			} catch (QueryException $secondException) {
470
-				if ($firstException->getCode() === 1) {
471
-					throw $secondException;
472
-				}
473
-				throw $firstException;
474
-			}
475
-		}
476
-	}
477
-
478
-	/**
479
-	 * @param string $name
480
-	 * @return mixed
481
-	 * @throws QueryException if the query could not be resolved
482
-	 */
483
-	public function queryNoFallback($name) {
484
-		$name = $this->sanitizeName($name);
485
-
486
-		if ($this->offsetExists($name)) {
487
-			return parent::query($name);
488
-		} elseif ($this->appName === 'settings' && str_starts_with($name, 'OC\\Settings\\')) {
489
-			return parent::query($name);
490
-		} elseif ($this->appName === 'core' && str_starts_with($name, 'OC\\Core\\')) {
491
-			return parent::query($name);
492
-		} elseif (str_starts_with($name, \OC\AppFramework\App::buildAppNamespace($this->appName) . '\\')) {
493
-			return parent::query($name);
494
-		}
495
-
496
-		throw new QueryException('Could not resolve ' . $name . '!' .
497
-			' Class can not be instantiated', 1);
498
-	}
82
+    private string $appName;
83
+
84
+    /**
85
+     * @var array
86
+     */
87
+    private $middleWares = [];
88
+
89
+    /** @var ServerContainer */
90
+    private $server;
91
+
92
+    /**
93
+     * Put your class dependencies in here
94
+     * @param string $appName the name of the app
95
+     * @param array $urlParams
96
+     * @param ServerContainer|null $server
97
+     */
98
+    public function __construct(string $appName, array $urlParams = [], ServerContainer $server = null) {
99
+        parent::__construct();
100
+        $this->appName = $appName;
101
+        $this['appName'] = $appName;
102
+        $this['urlParams'] = $urlParams;
103
+
104
+        $this->registerAlias('Request', IRequest::class);
105
+
106
+        /** @var \OC\ServerContainer $server */
107
+        if ($server === null) {
108
+            $server = \OC::$server;
109
+        }
110
+        $this->server = $server;
111
+        $this->server->registerAppContainer($appName, $this);
112
+
113
+        // aliases
114
+        /** @deprecated inject $appName */
115
+        $this->registerAlias('AppName', 'appName');
116
+        /** @deprecated inject $webRoot*/
117
+        $this->registerAlias('WebRoot', 'webRoot');
118
+        /** @deprecated inject $userId */
119
+        $this->registerAlias('UserId', 'userId');
120
+
121
+        /**
122
+         * Core services
123
+         */
124
+        $this->registerService(IOutput::class, function () {
125
+            return new Output($this->getServer()->getWebRoot());
126
+        });
127
+
128
+        $this->registerService(Folder::class, function () {
129
+            return $this->getServer()->getUserFolder();
130
+        });
131
+
132
+        $this->registerService(IAppData::class, function (ContainerInterface $c) {
133
+            return $this->getServer()->getAppDataDir($c->get('AppName'));
134
+        });
135
+
136
+        $this->registerService(IL10N::class, function (ContainerInterface $c) {
137
+            return $this->getServer()->getL10N($c->get('AppName'));
138
+        });
139
+
140
+        // Log wrappers
141
+        $this->registerService(LoggerInterface::class, function (ContainerInterface $c) {
142
+            return new ScopedPsrLogger(
143
+                $c->get(PsrLoggerAdapter::class),
144
+                $c->get('AppName')
145
+            );
146
+        });
147
+        $this->registerService(ILogger::class, function (ContainerInterface $c) {
148
+            return new OC\AppFramework\Logger($this->server->query(ILogger::class), $c->get('AppName'));
149
+        });
150
+
151
+        $this->registerService(IServerContainer::class, function () {
152
+            return $this->getServer();
153
+        });
154
+        $this->registerAlias('ServerContainer', IServerContainer::class);
155
+
156
+        $this->registerService(\OCP\WorkflowEngine\IManager::class, function (ContainerInterface $c) {
157
+            return $c->get(Manager::class);
158
+        });
159
+
160
+        $this->registerService(ContainerInterface::class, function (ContainerInterface $c) {
161
+            return $c;
162
+        });
163
+        $this->registerAlias(IAppContainer::class, ContainerInterface::class);
164
+
165
+        // commonly used attributes
166
+        $this->registerService('userId', function (ContainerInterface $c) {
167
+            return $c->get(IUserSession::class)->getSession()->get('user_id');
168
+        });
169
+
170
+        $this->registerService('webRoot', function (ContainerInterface $c) {
171
+            return $c->get(IServerContainer::class)->getWebRoot();
172
+        });
173
+
174
+        $this->registerService('OC_Defaults', function (ContainerInterface $c) {
175
+            return $c->get(IServerContainer::class)->getThemingDefaults();
176
+        });
177
+
178
+        $this->registerService('Protocol', function (ContainerInterface $c) {
179
+            /** @var \OC\Server $server */
180
+            $server = $c->get(IServerContainer::class);
181
+            $protocol = $server->getRequest()->getHttpProtocol();
182
+            return new Http($_SERVER, $protocol);
183
+        });
184
+
185
+        $this->registerService('Dispatcher', function (ContainerInterface $c) {
186
+            return new Dispatcher(
187
+                $c->get('Protocol'),
188
+                $c->get(MiddlewareDispatcher::class),
189
+                $c->get(IControllerMethodReflector::class),
190
+                $c->get(IRequest::class),
191
+                $c->get(IConfig::class),
192
+                $c->get(IDBConnection::class),
193
+                $c->get(LoggerInterface::class),
194
+                $c->get(EventLogger::class),
195
+                $c,
196
+            );
197
+        });
198
+
199
+        /**
200
+         * App Framework default arguments
201
+         */
202
+        $this->registerParameter('corsMethods', 'PUT, POST, GET, DELETE, PATCH');
203
+        $this->registerParameter('corsAllowedHeaders', 'Authorization, Content-Type, Accept');
204
+        $this->registerParameter('corsMaxAge', 1728000);
205
+
206
+        /**
207
+         * Middleware
208
+         */
209
+        $this->registerAlias('MiddlewareDispatcher', MiddlewareDispatcher::class);
210
+        $this->registerService(MiddlewareDispatcher::class, function (ContainerInterface $c) {
211
+            $server = $this->getServer();
212
+
213
+            $dispatcher = new MiddlewareDispatcher();
214
+
215
+            $dispatcher->registerMiddleware(
216
+                $c->get(OC\AppFramework\Middleware\CompressionMiddleware::class)
217
+            );
218
+
219
+            $dispatcher->registerMiddleware($c->get(OC\AppFramework\Middleware\NotModifiedMiddleware::class));
220
+
221
+            $dispatcher->registerMiddleware(
222
+                $c->get(OC\AppFramework\Middleware\Security\ReloadExecutionMiddleware::class)
223
+            );
224
+
225
+            $dispatcher->registerMiddleware(
226
+                new OC\AppFramework\Middleware\Security\SameSiteCookieMiddleware(
227
+                    $c->get(IRequest::class),
228
+                    $c->get(IControllerMethodReflector::class)
229
+                )
230
+            );
231
+            $dispatcher->registerMiddleware(
232
+                new CORSMiddleware(
233
+                    $c->get(IRequest::class),
234
+                    $c->get(IControllerMethodReflector::class),
235
+                    $c->get(IUserSession::class),
236
+                    $c->get(OC\Security\Bruteforce\Throttler::class)
237
+                )
238
+            );
239
+            $dispatcher->registerMiddleware(
240
+                new OCSMiddleware(
241
+                    $c->get(IRequest::class)
242
+                )
243
+            );
244
+
245
+
246
+
247
+            $securityMiddleware = new SecurityMiddleware(
248
+                $c->get(IRequest::class),
249
+                $c->get(IControllerMethodReflector::class),
250
+                $c->get(INavigationManager::class),
251
+                $c->get(IURLGenerator::class),
252
+                $server->get(LoggerInterface::class),
253
+                $c->get('AppName'),
254
+                $server->getUserSession()->isLoggedIn(),
255
+                $this->getUserId() !== null && $server->getGroupManager()->isAdmin($this->getUserId()),
256
+                $server->getUserSession()->getUser() !== null && $server->query(ISubAdmin::class)->isSubAdmin($server->getUserSession()->getUser()),
257
+                $server->getAppManager(),
258
+                $server->getL10N('lib'),
259
+                $c->get(AuthorizedGroupMapper::class),
260
+                $server->get(IUserSession::class)
261
+            );
262
+            $dispatcher->registerMiddleware($securityMiddleware);
263
+            $dispatcher->registerMiddleware(
264
+                new OC\AppFramework\Middleware\Security\CSPMiddleware(
265
+                    $server->query(OC\Security\CSP\ContentSecurityPolicyManager::class),
266
+                    $server->query(OC\Security\CSP\ContentSecurityPolicyNonceManager::class),
267
+                    $server->query(OC\Security\CSRF\CsrfTokenManager::class)
268
+                )
269
+            );
270
+            $dispatcher->registerMiddleware(
271
+                $server->query(OC\AppFramework\Middleware\Security\FeaturePolicyMiddleware::class)
272
+            );
273
+            $dispatcher->registerMiddleware(
274
+                new OC\AppFramework\Middleware\Security\PasswordConfirmationMiddleware(
275
+                    $c->get(IControllerMethodReflector::class),
276
+                    $c->get(ISession::class),
277
+                    $c->get(IUserSession::class),
278
+                    $c->get(ITimeFactory::class)
279
+                )
280
+            );
281
+            $dispatcher->registerMiddleware(
282
+                new TwoFactorMiddleware(
283
+                    $c->get(OC\Authentication\TwoFactorAuth\Manager::class),
284
+                    $c->get(IUserSession::class),
285
+                    $c->get(ISession::class),
286
+                    $c->get(IURLGenerator::class),
287
+                    $c->get(IControllerMethodReflector::class),
288
+                    $c->get(IRequest::class)
289
+                )
290
+            );
291
+            $dispatcher->registerMiddleware(
292
+                new OC\AppFramework\Middleware\Security\BruteForceMiddleware(
293
+                    $c->get(IControllerMethodReflector::class),
294
+                    $c->get(OC\Security\Bruteforce\Throttler::class),
295
+                    $c->get(IRequest::class)
296
+                )
297
+            );
298
+            $dispatcher->registerMiddleware(
299
+                new RateLimitingMiddleware(
300
+                    $c->get(IRequest::class),
301
+                    $c->get(IUserSession::class),
302
+                    $c->get(IControllerMethodReflector::class),
303
+                    $c->get(OC\Security\RateLimiting\Limiter::class)
304
+                )
305
+            );
306
+            $dispatcher->registerMiddleware(
307
+                new OC\AppFramework\Middleware\PublicShare\PublicShareMiddleware(
308
+                    $c->get(IRequest::class),
309
+                    $c->get(ISession::class),
310
+                    $c->get(\OCP\IConfig::class),
311
+                    $c->get(OC\Security\Bruteforce\Throttler::class)
312
+                )
313
+            );
314
+            $dispatcher->registerMiddleware(
315
+                $c->get(\OC\AppFramework\Middleware\AdditionalScriptsMiddleware::class)
316
+            );
317
+
318
+            /** @var \OC\AppFramework\Bootstrap\Coordinator $coordinator */
319
+            $coordinator = $c->get(\OC\AppFramework\Bootstrap\Coordinator::class);
320
+            $registrationContext = $coordinator->getRegistrationContext();
321
+            if ($registrationContext !== null) {
322
+                $appId = $this->getAppName();
323
+                foreach ($registrationContext->getMiddlewareRegistrations() as $middlewareRegistration) {
324
+                    if ($middlewareRegistration->getAppId() === $appId
325
+                        || $middlewareRegistration->isGlobal()) {
326
+                        $dispatcher->registerMiddleware($c->get($middlewareRegistration->getService()));
327
+                    }
328
+                }
329
+            }
330
+            foreach ($this->middleWares as $middleWare) {
331
+                $dispatcher->registerMiddleware($c->get($middleWare));
332
+            }
333
+
334
+            $dispatcher->registerMiddleware(
335
+                new SessionMiddleware(
336
+                    $c->get(IControllerMethodReflector::class),
337
+                    $c->get(ISession::class)
338
+                )
339
+            );
340
+            return $dispatcher;
341
+        });
342
+
343
+        $this->registerService(IAppConfig::class, function (ContainerInterface $c) {
344
+            return new OC\AppFramework\Services\AppConfig(
345
+                $c->get(IConfig::class),
346
+                $c->get('AppName')
347
+            );
348
+        });
349
+        $this->registerService(IInitialState::class, function (ContainerInterface $c) {
350
+            return new OC\AppFramework\Services\InitialState(
351
+                $c->get(IInitialStateService::class),
352
+                $c->get('AppName')
353
+            );
354
+        });
355
+    }
356
+
357
+    /**
358
+     * @return \OCP\IServerContainer
359
+     */
360
+    public function getServer() {
361
+        return $this->server;
362
+    }
363
+
364
+    /**
365
+     * @param string $middleWare
366
+     * @return boolean|null
367
+     */
368
+    public function registerMiddleWare($middleWare) {
369
+        if (in_array($middleWare, $this->middleWares, true) !== false) {
370
+            return false;
371
+        }
372
+        $this->middleWares[] = $middleWare;
373
+    }
374
+
375
+    /**
376
+     * used to return the appname of the set application
377
+     * @return string the name of your application
378
+     */
379
+    public function getAppName() {
380
+        return $this->query('AppName');
381
+    }
382
+
383
+    /**
384
+     * @deprecated use IUserSession->isLoggedIn()
385
+     * @return boolean
386
+     */
387
+    public function isLoggedIn() {
388
+        return \OC::$server->getUserSession()->isLoggedIn();
389
+    }
390
+
391
+    /**
392
+     * @deprecated use IGroupManager->isAdmin($userId)
393
+     * @return boolean
394
+     */
395
+    public function isAdminUser() {
396
+        $uid = $this->getUserId();
397
+        return \OC_User::isAdminUser($uid);
398
+    }
399
+
400
+    private function getUserId() {
401
+        return $this->getServer()->getSession()->get('user_id');
402
+    }
403
+
404
+    /**
405
+     * @deprecated use the ILogger instead
406
+     * @param string $message
407
+     * @param string $level
408
+     * @return mixed
409
+     */
410
+    public function log($message, $level) {
411
+        switch ($level) {
412
+            case 'debug':
413
+                $level = ILogger::DEBUG;
414
+                break;
415
+            case 'info':
416
+                $level = ILogger::INFO;
417
+                break;
418
+            case 'warn':
419
+                $level = ILogger::WARN;
420
+                break;
421
+            case 'fatal':
422
+                $level = ILogger::FATAL;
423
+                break;
424
+            default:
425
+                $level = ILogger::ERROR;
426
+                break;
427
+        }
428
+        \OCP\Util::writeLog($this->getAppName(), $message, $level);
429
+    }
430
+
431
+    /**
432
+     * Register a capability
433
+     *
434
+     * @param string $serviceName e.g. 'OCA\Files\Capabilities'
435
+     */
436
+    public function registerCapability($serviceName) {
437
+        $this->query('OC\CapabilitiesManager')->registerCapability(function () use ($serviceName) {
438
+            return $this->query($serviceName);
439
+        });
440
+    }
441
+
442
+    public function has($id): bool {
443
+        if (parent::has($id)) {
444
+            return true;
445
+        }
446
+
447
+        if ($this->server->has($id, true)) {
448
+            return true;
449
+        }
450
+
451
+        return false;
452
+    }
453
+
454
+    public function query(string $name, bool $autoload = true) {
455
+        if ($name === 'AppName' || $name === 'appName') {
456
+            return $this->appName;
457
+        }
458
+
459
+        $isServerClass = str_starts_with($name, 'OCP\\') || str_starts_with($name, 'OC\\');
460
+        if ($isServerClass && !$this->has($name)) {
461
+            return $this->getServer()->query($name, $autoload);
462
+        }
463
+
464
+        try {
465
+            return $this->queryNoFallback($name);
466
+        } catch (QueryException $firstException) {
467
+            try {
468
+                return $this->getServer()->query($name, $autoload);
469
+            } catch (QueryException $secondException) {
470
+                if ($firstException->getCode() === 1) {
471
+                    throw $secondException;
472
+                }
473
+                throw $firstException;
474
+            }
475
+        }
476
+    }
477
+
478
+    /**
479
+     * @param string $name
480
+     * @return mixed
481
+     * @throws QueryException if the query could not be resolved
482
+     */
483
+    public function queryNoFallback($name) {
484
+        $name = $this->sanitizeName($name);
485
+
486
+        if ($this->offsetExists($name)) {
487
+            return parent::query($name);
488
+        } elseif ($this->appName === 'settings' && str_starts_with($name, 'OC\\Settings\\')) {
489
+            return parent::query($name);
490
+        } elseif ($this->appName === 'core' && str_starts_with($name, 'OC\\Core\\')) {
491
+            return parent::query($name);
492
+        } elseif (str_starts_with($name, \OC\AppFramework\App::buildAppNamespace($this->appName) . '\\')) {
493
+            return parent::query($name);
494
+        }
495
+
496
+        throw new QueryException('Could not resolve ' . $name . '!' .
497
+            ' Class can not be instantiated', 1);
498
+    }
499 499
 }
Please login to merge, or discard this patch.