Passed
Push — master ( 1b3486...6f167f )
by Morris
13:41 queued 12s
created
lib/private/AppFramework/Bootstrap/RegistrationContext.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 		$this->logger = $logger;
64 64
 	}
65 65
 
66
-	public function for(string $appId): IRegistrationContext {
66
+	public function for (string $appId): IRegistrationContext {
67 67
 		return new class($appId, $this) implements IRegistrationContext {
68 68
 			/** @var string */
69 69
 			private $appId;
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 			} catch (Throwable $e) {
201 201
 				$appId = $registration['appId'];
202 202
 				$this->logger->logException($e, [
203
-					'message' => "Error during capability registration of $appId: " . $e->getMessage(),
203
+					'message' => "Error during capability registration of $appId: ".$e->getMessage(),
204 204
 					'level' => ILogger::ERROR,
205 205
 				]);
206 206
 			}
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 			} catch (Throwable $e) {
218 218
 				$appId = $registration['appId'];
219 219
 				$this->logger->logException($e, [
220
-					'message' => "Error during crash reporter registration of $appId: " . $e->getMessage(),
220
+					'message' => "Error during crash reporter registration of $appId: ".$e->getMessage(),
221 221
 					'level' => ILogger::ERROR,
222 222
 				]);
223 223
 			}
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 			} catch (Throwable $e) {
243 243
 				$appId = $registration['appId'];
244 244
 				$this->logger->logException($e, [
245
-					'message' => "Error during event listener registration of $appId: " . $e->getMessage(),
245
+					'message' => "Error during event listener registration of $appId: ".$e->getMessage(),
246 246
 					'level' => ILogger::ERROR,
247 247
 				]);
248 248
 			}
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 			} catch (Throwable $e) {
269 269
 				$appId = $registration['appId'];
270 270
 				$this->logger->logException($e, [
271
-					'message' => "Error during service registration of $appId: " . $e->getMessage(),
271
+					'message' => "Error during service registration of $appId: ".$e->getMessage(),
272 272
 					'level' => ILogger::ERROR,
273 273
 				]);
274 274
 			}
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 			} catch (Throwable $e) {
286 286
 				$appId = $registration['appId'];
287 287
 				$this->logger->logException($e, [
288
-					'message' => "Error during service alias registration of $appId: " . $e->getMessage(),
288
+					'message' => "Error during service alias registration of $appId: ".$e->getMessage(),
289 289
 					'level' => ILogger::ERROR,
290 290
 				]);
291 291
 			}
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 			} catch (Throwable $e) {
303 303
 				$appId = $registration['appId'];
304 304
 				$this->logger->logException($e, [
305
-					'message' => "Error during service alias registration of $appId: " . $e->getMessage(),
305
+					'message' => "Error during service alias registration of $appId: ".$e->getMessage(),
306 306
 					'level' => ILogger::ERROR,
307 307
 				]);
308 308
 			}
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 			} catch (Throwable $e) {
322 322
 				$appId = $middleware['appId'];
323 323
 				$this->logger->logException($e, [
324
-					'message' => "Error during capability registration of $appId: " . $e->getMessage(),
324
+					'message' => "Error during capability registration of $appId: ".$e->getMessage(),
325 325
 					'level' => ILogger::ERROR,
326 326
 				]);
327 327
 			}
Please login to merge, or discard this patch.
Indentation   +316 added lines, -316 removed lines patch added patch discarded remove patch
@@ -35,320 +35,320 @@
 block discarded – undo
35 35
 
36 36
 class RegistrationContext {
37 37
 
38
-	/** @var array[] */
39
-	private $capabilities = [];
40
-
41
-	/** @var array[] */
42
-	private $crashReporters = [];
43
-
44
-	/** @var array[] */
45
-	private $services = [];
46
-
47
-	/** @var array[] */
48
-	private $aliases = [];
49
-
50
-	/** @var array[] */
51
-	private $parameters = [];
52
-
53
-	/** @var array[] */
54
-	private $eventListeners = [];
55
-
56
-	/** @var array[] */
57
-	private $middlewares = [];
58
-
59
-	/** @var array[] */
60
-	private $searchProviders = [];
61
-
62
-	/** @var ILogger */
63
-	private $logger;
64
-
65
-	public function __construct(ILogger $logger) {
66
-		$this->logger = $logger;
67
-	}
68
-
69
-	public function for(string $appId): IRegistrationContext {
70
-		return new class($appId, $this) implements IRegistrationContext {
71
-			/** @var string */
72
-			private $appId;
73
-
74
-			/** @var RegistrationContext */
75
-			private $context;
76
-
77
-			public function __construct(string $appId, RegistrationContext $context) {
78
-				$this->appId = $appId;
79
-				$this->context = $context;
80
-			}
81
-
82
-			public function registerCapability(string $capability): void {
83
-				$this->context->registerCapability(
84
-					$this->appId,
85
-					$capability
86
-				);
87
-			}
88
-
89
-			public function registerCrashReporter(string $reporterClass): void {
90
-				$this->context->registerCrashReporter(
91
-					$this->appId,
92
-					$reporterClass
93
-				);
94
-			}
95
-
96
-			public function registerService(string $name, callable $factory, bool $shared = true): void {
97
-				$this->context->registerService(
98
-					$this->appId,
99
-					$name,
100
-					$factory,
101
-					$shared
102
-				);
103
-			}
104
-
105
-			public function registerServiceAlias(string $alias, string $target): void {
106
-				$this->context->registerServiceAlias(
107
-					$this->appId,
108
-					$alias,
109
-					$target
110
-				);
111
-			}
112
-
113
-			public function registerParameter(string $name, $value): void {
114
-				$this->context->registerParameter(
115
-					$this->appId,
116
-					$name,
117
-					$value
118
-				);
119
-			}
120
-
121
-			public function registerEventListener(string $event, string $listener, int $priority = 0): void {
122
-				$this->context->registerEventListener(
123
-					$this->appId,
124
-					$event,
125
-					$listener,
126
-					$priority
127
-				);
128
-			}
129
-
130
-			public function registerMiddleware(string $class): void {
131
-				$this->context->registerMiddleware(
132
-					$this->appId,
133
-					$class
134
-				);
135
-			}
136
-
137
-			public function registerSearchProvider(string $class): void {
138
-				$this->context->registerSearchProvider(
139
-					$this->appId,
140
-					$class
141
-				);
142
-			}
143
-		};
144
-	}
145
-
146
-	public function registerCapability(string $appId, string $capability): void {
147
-		$this->capabilities[] = [
148
-			'appId' => $appId,
149
-			'capability' => $capability
150
-		];
151
-	}
152
-
153
-	public function registerCrashReporter(string $appId, string $reporterClass): void {
154
-		$this->crashReporters[] = [
155
-			'appId' => $appId,
156
-			'class' => $reporterClass,
157
-		];
158
-	}
159
-
160
-	public function registerService(string $appId, string $name, callable $factory, bool $shared = true): void {
161
-		$this->services[] = [
162
-			"appId" => $appId,
163
-			"name" => $name,
164
-			"factory" => $factory,
165
-			"sharred" => $shared,
166
-		];
167
-	}
168
-
169
-	public function registerServiceAlias(string $appId, string $alias, string $target): void {
170
-		$this->aliases[] = [
171
-			"appId" => $appId,
172
-			"alias" => $alias,
173
-			"target" => $target,
174
-		];
175
-	}
176
-
177
-	public function registerParameter(string $appId, string $name, $value): void {
178
-		$this->parameters[] = [
179
-			"appId" => $appId,
180
-			"name" => $name,
181
-			"value" => $value,
182
-		];
183
-	}
184
-
185
-	public function registerEventListener(string $appId, string $event, string $listener, int $priority = 0): void {
186
-		$this->eventListeners[] = [
187
-			"appId" => $appId,
188
-			"event" => $event,
189
-			"listener" => $listener,
190
-			"priority" => $priority,
191
-		];
192
-	}
193
-
194
-	public function registerMiddleware(string $appId, string $class): void {
195
-		$this->middlewares[] = [
196
-			"appId" => $appId,
197
-			"class" => $class,
198
-		];
199
-	}
200
-
201
-	public function registerSearchProvider(string $appId, string $class) {
202
-		$this->searchProviders[] = [
203
-			'appId' => $appId,
204
-			'class' => $class,
205
-		];
206
-	}
207
-
208
-	/**
209
-	 * @param App[] $apps
210
-	 */
211
-	public function delegateCapabilityRegistrations(array $apps): void {
212
-		foreach ($this->capabilities as $registration) {
213
-			try {
214
-				$apps[$registration['appId']]
215
-					->getContainer()
216
-					->registerCapability($registration['capability']);
217
-			} catch (Throwable $e) {
218
-				$appId = $registration['appId'];
219
-				$this->logger->logException($e, [
220
-					'message' => "Error during capability registration of $appId: " . $e->getMessage(),
221
-					'level' => ILogger::ERROR,
222
-				]);
223
-			}
224
-		}
225
-	}
226
-
227
-	/**
228
-	 * @param App[] $apps
229
-	 */
230
-	public function delegateCrashReporterRegistrations(array $apps, Registry $registry): void {
231
-		foreach ($this->crashReporters as $registration) {
232
-			try {
233
-				$registry->registerLazy($registration['class']);
234
-			} catch (Throwable $e) {
235
-				$appId = $registration['appId'];
236
-				$this->logger->logException($e, [
237
-					'message' => "Error during crash reporter registration of $appId: " . $e->getMessage(),
238
-					'level' => ILogger::ERROR,
239
-				]);
240
-			}
241
-		}
242
-	}
243
-
244
-	public function delegateEventListenerRegistrations(IEventDispatcher $eventDispatcher): void {
245
-		foreach ($this->eventListeners as $registration) {
246
-			try {
247
-				if (isset($registration['priority'])) {
248
-					$eventDispatcher->addServiceListener(
249
-						$registration['event'],
250
-						$registration['listener'],
251
-						$registration['priority']
252
-					);
253
-				} else {
254
-					$eventDispatcher->addServiceListener(
255
-						$registration['event'],
256
-						$registration['listener']
257
-					);
258
-				}
259
-			} catch (Throwable $e) {
260
-				$appId = $registration['appId'];
261
-				$this->logger->logException($e, [
262
-					'message' => "Error during event listener registration of $appId: " . $e->getMessage(),
263
-					'level' => ILogger::ERROR,
264
-				]);
265
-			}
266
-		}
267
-	}
268
-
269
-	/**
270
-	 * @param App[] $apps
271
-	 */
272
-	public function delegateContainerRegistrations(array $apps): void {
273
-		foreach ($this->services as $registration) {
274
-			try {
275
-				/**
276
-				 * Register the service and convert the callable into a \Closure if necessary
277
-				 */
278
-				$apps[$registration['appId']]
279
-					->getContainer()
280
-					->registerService(
281
-						$registration['name'],
282
-						Closure::fromCallable($registration['factory']),
283
-						$registration['shared'] ?? true
284
-					);
285
-			} catch (Throwable $e) {
286
-				$appId = $registration['appId'];
287
-				$this->logger->logException($e, [
288
-					'message' => "Error during service registration of $appId: " . $e->getMessage(),
289
-					'level' => ILogger::ERROR,
290
-				]);
291
-			}
292
-		}
293
-
294
-		foreach ($this->aliases as $registration) {
295
-			try {
296
-				$apps[$registration['appId']]
297
-					->getContainer()
298
-					->registerAlias(
299
-						$registration['alias'],
300
-						$registration['target']
301
-					);
302
-			} catch (Throwable $e) {
303
-				$appId = $registration['appId'];
304
-				$this->logger->logException($e, [
305
-					'message' => "Error during service alias registration of $appId: " . $e->getMessage(),
306
-					'level' => ILogger::ERROR,
307
-				]);
308
-			}
309
-		}
310
-
311
-		foreach ($this->parameters as $registration) {
312
-			try {
313
-				$apps[$registration['appId']]
314
-					->getContainer()
315
-					->registerParameter(
316
-						$registration['name'],
317
-						$registration['value']
318
-					);
319
-			} catch (Throwable $e) {
320
-				$appId = $registration['appId'];
321
-				$this->logger->logException($e, [
322
-					'message' => "Error during service alias registration of $appId: " . $e->getMessage(),
323
-					'level' => ILogger::ERROR,
324
-				]);
325
-			}
326
-		}
327
-	}
328
-
329
-	/**
330
-	 * @param App[] $apps
331
-	 */
332
-	public function delegateMiddlewareRegistrations(array $apps): void {
333
-		foreach ($this->middlewares as $middleware) {
334
-			try {
335
-				$apps[$middleware['appId']]
336
-					->getContainer()
337
-					->registerMiddleWare($middleware['class']);
338
-			} catch (Throwable $e) {
339
-				$appId = $middleware['appId'];
340
-				$this->logger->logException($e, [
341
-					'message' => "Error during capability registration of $appId: " . $e->getMessage(),
342
-					'level' => ILogger::ERROR,
343
-				]);
344
-			}
345
-		}
346
-	}
347
-
348
-	/**
349
-	 * @return array[]
350
-	 */
351
-	public function getSearchProviders(): array {
352
-		return $this->searchProviders;
353
-	}
38
+    /** @var array[] */
39
+    private $capabilities = [];
40
+
41
+    /** @var array[] */
42
+    private $crashReporters = [];
43
+
44
+    /** @var array[] */
45
+    private $services = [];
46
+
47
+    /** @var array[] */
48
+    private $aliases = [];
49
+
50
+    /** @var array[] */
51
+    private $parameters = [];
52
+
53
+    /** @var array[] */
54
+    private $eventListeners = [];
55
+
56
+    /** @var array[] */
57
+    private $middlewares = [];
58
+
59
+    /** @var array[] */
60
+    private $searchProviders = [];
61
+
62
+    /** @var ILogger */
63
+    private $logger;
64
+
65
+    public function __construct(ILogger $logger) {
66
+        $this->logger = $logger;
67
+    }
68
+
69
+    public function for(string $appId): IRegistrationContext {
70
+        return new class($appId, $this) implements IRegistrationContext {
71
+            /** @var string */
72
+            private $appId;
73
+
74
+            /** @var RegistrationContext */
75
+            private $context;
76
+
77
+            public function __construct(string $appId, RegistrationContext $context) {
78
+                $this->appId = $appId;
79
+                $this->context = $context;
80
+            }
81
+
82
+            public function registerCapability(string $capability): void {
83
+                $this->context->registerCapability(
84
+                    $this->appId,
85
+                    $capability
86
+                );
87
+            }
88
+
89
+            public function registerCrashReporter(string $reporterClass): void {
90
+                $this->context->registerCrashReporter(
91
+                    $this->appId,
92
+                    $reporterClass
93
+                );
94
+            }
95
+
96
+            public function registerService(string $name, callable $factory, bool $shared = true): void {
97
+                $this->context->registerService(
98
+                    $this->appId,
99
+                    $name,
100
+                    $factory,
101
+                    $shared
102
+                );
103
+            }
104
+
105
+            public function registerServiceAlias(string $alias, string $target): void {
106
+                $this->context->registerServiceAlias(
107
+                    $this->appId,
108
+                    $alias,
109
+                    $target
110
+                );
111
+            }
112
+
113
+            public function registerParameter(string $name, $value): void {
114
+                $this->context->registerParameter(
115
+                    $this->appId,
116
+                    $name,
117
+                    $value
118
+                );
119
+            }
120
+
121
+            public function registerEventListener(string $event, string $listener, int $priority = 0): void {
122
+                $this->context->registerEventListener(
123
+                    $this->appId,
124
+                    $event,
125
+                    $listener,
126
+                    $priority
127
+                );
128
+            }
129
+
130
+            public function registerMiddleware(string $class): void {
131
+                $this->context->registerMiddleware(
132
+                    $this->appId,
133
+                    $class
134
+                );
135
+            }
136
+
137
+            public function registerSearchProvider(string $class): void {
138
+                $this->context->registerSearchProvider(
139
+                    $this->appId,
140
+                    $class
141
+                );
142
+            }
143
+        };
144
+    }
145
+
146
+    public function registerCapability(string $appId, string $capability): void {
147
+        $this->capabilities[] = [
148
+            'appId' => $appId,
149
+            'capability' => $capability
150
+        ];
151
+    }
152
+
153
+    public function registerCrashReporter(string $appId, string $reporterClass): void {
154
+        $this->crashReporters[] = [
155
+            'appId' => $appId,
156
+            'class' => $reporterClass,
157
+        ];
158
+    }
159
+
160
+    public function registerService(string $appId, string $name, callable $factory, bool $shared = true): void {
161
+        $this->services[] = [
162
+            "appId" => $appId,
163
+            "name" => $name,
164
+            "factory" => $factory,
165
+            "sharred" => $shared,
166
+        ];
167
+    }
168
+
169
+    public function registerServiceAlias(string $appId, string $alias, string $target): void {
170
+        $this->aliases[] = [
171
+            "appId" => $appId,
172
+            "alias" => $alias,
173
+            "target" => $target,
174
+        ];
175
+    }
176
+
177
+    public function registerParameter(string $appId, string $name, $value): void {
178
+        $this->parameters[] = [
179
+            "appId" => $appId,
180
+            "name" => $name,
181
+            "value" => $value,
182
+        ];
183
+    }
184
+
185
+    public function registerEventListener(string $appId, string $event, string $listener, int $priority = 0): void {
186
+        $this->eventListeners[] = [
187
+            "appId" => $appId,
188
+            "event" => $event,
189
+            "listener" => $listener,
190
+            "priority" => $priority,
191
+        ];
192
+    }
193
+
194
+    public function registerMiddleware(string $appId, string $class): void {
195
+        $this->middlewares[] = [
196
+            "appId" => $appId,
197
+            "class" => $class,
198
+        ];
199
+    }
200
+
201
+    public function registerSearchProvider(string $appId, string $class) {
202
+        $this->searchProviders[] = [
203
+            'appId' => $appId,
204
+            'class' => $class,
205
+        ];
206
+    }
207
+
208
+    /**
209
+     * @param App[] $apps
210
+     */
211
+    public function delegateCapabilityRegistrations(array $apps): void {
212
+        foreach ($this->capabilities as $registration) {
213
+            try {
214
+                $apps[$registration['appId']]
215
+                    ->getContainer()
216
+                    ->registerCapability($registration['capability']);
217
+            } catch (Throwable $e) {
218
+                $appId = $registration['appId'];
219
+                $this->logger->logException($e, [
220
+                    'message' => "Error during capability registration of $appId: " . $e->getMessage(),
221
+                    'level' => ILogger::ERROR,
222
+                ]);
223
+            }
224
+        }
225
+    }
226
+
227
+    /**
228
+     * @param App[] $apps
229
+     */
230
+    public function delegateCrashReporterRegistrations(array $apps, Registry $registry): void {
231
+        foreach ($this->crashReporters as $registration) {
232
+            try {
233
+                $registry->registerLazy($registration['class']);
234
+            } catch (Throwable $e) {
235
+                $appId = $registration['appId'];
236
+                $this->logger->logException($e, [
237
+                    'message' => "Error during crash reporter registration of $appId: " . $e->getMessage(),
238
+                    'level' => ILogger::ERROR,
239
+                ]);
240
+            }
241
+        }
242
+    }
243
+
244
+    public function delegateEventListenerRegistrations(IEventDispatcher $eventDispatcher): void {
245
+        foreach ($this->eventListeners as $registration) {
246
+            try {
247
+                if (isset($registration['priority'])) {
248
+                    $eventDispatcher->addServiceListener(
249
+                        $registration['event'],
250
+                        $registration['listener'],
251
+                        $registration['priority']
252
+                    );
253
+                } else {
254
+                    $eventDispatcher->addServiceListener(
255
+                        $registration['event'],
256
+                        $registration['listener']
257
+                    );
258
+                }
259
+            } catch (Throwable $e) {
260
+                $appId = $registration['appId'];
261
+                $this->logger->logException($e, [
262
+                    'message' => "Error during event listener registration of $appId: " . $e->getMessage(),
263
+                    'level' => ILogger::ERROR,
264
+                ]);
265
+            }
266
+        }
267
+    }
268
+
269
+    /**
270
+     * @param App[] $apps
271
+     */
272
+    public function delegateContainerRegistrations(array $apps): void {
273
+        foreach ($this->services as $registration) {
274
+            try {
275
+                /**
276
+                 * Register the service and convert the callable into a \Closure if necessary
277
+                 */
278
+                $apps[$registration['appId']]
279
+                    ->getContainer()
280
+                    ->registerService(
281
+                        $registration['name'],
282
+                        Closure::fromCallable($registration['factory']),
283
+                        $registration['shared'] ?? true
284
+                    );
285
+            } catch (Throwable $e) {
286
+                $appId = $registration['appId'];
287
+                $this->logger->logException($e, [
288
+                    'message' => "Error during service registration of $appId: " . $e->getMessage(),
289
+                    'level' => ILogger::ERROR,
290
+                ]);
291
+            }
292
+        }
293
+
294
+        foreach ($this->aliases as $registration) {
295
+            try {
296
+                $apps[$registration['appId']]
297
+                    ->getContainer()
298
+                    ->registerAlias(
299
+                        $registration['alias'],
300
+                        $registration['target']
301
+                    );
302
+            } catch (Throwable $e) {
303
+                $appId = $registration['appId'];
304
+                $this->logger->logException($e, [
305
+                    'message' => "Error during service alias registration of $appId: " . $e->getMessage(),
306
+                    'level' => ILogger::ERROR,
307
+                ]);
308
+            }
309
+        }
310
+
311
+        foreach ($this->parameters as $registration) {
312
+            try {
313
+                $apps[$registration['appId']]
314
+                    ->getContainer()
315
+                    ->registerParameter(
316
+                        $registration['name'],
317
+                        $registration['value']
318
+                    );
319
+            } catch (Throwable $e) {
320
+                $appId = $registration['appId'];
321
+                $this->logger->logException($e, [
322
+                    'message' => "Error during service alias registration of $appId: " . $e->getMessage(),
323
+                    'level' => ILogger::ERROR,
324
+                ]);
325
+            }
326
+        }
327
+    }
328
+
329
+    /**
330
+     * @param App[] $apps
331
+     */
332
+    public function delegateMiddlewareRegistrations(array $apps): void {
333
+        foreach ($this->middlewares as $middleware) {
334
+            try {
335
+                $apps[$middleware['appId']]
336
+                    ->getContainer()
337
+                    ->registerMiddleWare($middleware['class']);
338
+            } catch (Throwable $e) {
339
+                $appId = $middleware['appId'];
340
+                $this->logger->logException($e, [
341
+                    'message' => "Error during capability registration of $appId: " . $e->getMessage(),
342
+                    'level' => ILogger::ERROR,
343
+                ]);
344
+            }
345
+        }
346
+    }
347
+
348
+    /**
349
+     * @return array[]
350
+     */
351
+    public function getSearchProviders(): array {
352
+        return $this->searchProviders;
353
+    }
354 354
 }
Please login to merge, or discard this patch.
lib/private/AppFramework/Bootstrap/Coordinator.php 2 patches
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -41,123 +41,123 @@
 block discarded – undo
41 41
 
42 42
 class Coordinator {
43 43
 
44
-	/** @var IServerContainer */
45
-	private $serverContainer;
46
-
47
-	/** @var Registry */
48
-	private $registry;
49
-
50
-	/** @var IEventDispatcher */
51
-	private $eventDispatcher;
52
-
53
-	/** @var ILogger */
54
-	private $logger;
55
-
56
-	/** @var RegistrationContext|null */
57
-	private $registrationContext;
58
-
59
-	public function __construct(IServerContainer $container,
60
-								Registry $registry,
61
-								IEventDispatcher $eventListener,
62
-								ILogger $logger) {
63
-		$this->serverContainer = $container;
64
-		$this->registry = $registry;
65
-		$this->eventDispatcher = $eventListener;
66
-		$this->logger = $logger;
67
-	}
68
-
69
-	public function runRegistration(): void {
70
-		if ($this->registrationContext !== null) {
71
-			throw new RuntimeException('Registration has already been run');
72
-		}
73
-
74
-		$this->registrationContext = new RegistrationContext($this->logger);
75
-		$apps = [];
76
-		foreach (OC_App::getEnabledApps() as $appId) {
77
-			/*
44
+    /** @var IServerContainer */
45
+    private $serverContainer;
46
+
47
+    /** @var Registry */
48
+    private $registry;
49
+
50
+    /** @var IEventDispatcher */
51
+    private $eventDispatcher;
52
+
53
+    /** @var ILogger */
54
+    private $logger;
55
+
56
+    /** @var RegistrationContext|null */
57
+    private $registrationContext;
58
+
59
+    public function __construct(IServerContainer $container,
60
+                                Registry $registry,
61
+                                IEventDispatcher $eventListener,
62
+                                ILogger $logger) {
63
+        $this->serverContainer = $container;
64
+        $this->registry = $registry;
65
+        $this->eventDispatcher = $eventListener;
66
+        $this->logger = $logger;
67
+    }
68
+
69
+    public function runRegistration(): void {
70
+        if ($this->registrationContext !== null) {
71
+            throw new RuntimeException('Registration has already been run');
72
+        }
73
+
74
+        $this->registrationContext = new RegistrationContext($this->logger);
75
+        $apps = [];
76
+        foreach (OC_App::getEnabledApps() as $appId) {
77
+            /*
78 78
 			 * First, we have to enable the app's autoloader
79 79
 			 *
80 80
 			 * @todo use $this->appManager->getAppPath($appId) here
81 81
 			 */
82
-			$path = OC_App::getAppPath($appId);
83
-			if ($path === false) {
84
-				// Ignore
85
-				continue;
86
-			}
87
-			OC_App::registerAutoloading($appId, $path);
88
-
89
-			/*
82
+            $path = OC_App::getAppPath($appId);
83
+            if ($path === false) {
84
+                // Ignore
85
+                continue;
86
+            }
87
+            OC_App::registerAutoloading($appId, $path);
88
+
89
+            /*
90 90
 			 * Next we check if there is an application class and it implements
91 91
 			 * the \OCP\AppFramework\Bootstrap\IBootstrap interface
92 92
 			 */
93
-			$appNameSpace = App::buildAppNamespace($appId);
94
-			$applicationClassName = $appNameSpace . '\\AppInfo\\Application';
95
-			if (class_exists($applicationClassName) && in_array(IBootstrap::class, class_implements($applicationClassName), true)) {
96
-				try {
97
-					/** @var IBootstrap|App $application */
98
-					$apps[$appId] = $application = $this->serverContainer->query($applicationClassName);
99
-				} catch (QueryException $e) {
100
-					// Weird, but ok
101
-					continue;
102
-				}
103
-				try {
104
-					$application->register($this->registrationContext->for($appId));
105
-				} catch (Throwable $e) {
106
-					$this->logger->logException($e, [
107
-						'message' => 'Error during app service registration: ' . $e->getMessage(),
108
-						'level' => ILogger::FATAL,
109
-					]);
110
-				}
111
-			}
112
-		}
113
-
114
-		/**
115
-		 * Now that all register methods have been called, we can delegate the registrations
116
-		 * to the actual services
117
-		 */
118
-		$this->registrationContext->delegateCapabilityRegistrations($apps);
119
-		$this->registrationContext->delegateCrashReporterRegistrations($apps, $this->registry);
120
-		$this->registrationContext->delegateEventListenerRegistrations($this->eventDispatcher);
121
-		$this->registrationContext->delegateContainerRegistrations($apps);
122
-		$this->registrationContext->delegateMiddlewareRegistrations($apps);
123
-	}
124
-
125
-	public function getRegistrationContext(): ?RegistrationContext {
126
-		return $this->registrationContext;
127
-	}
128
-
129
-	public function bootApp(string $appId): void {
130
-		$appNameSpace = App::buildAppNamespace($appId);
131
-		$applicationClassName = $appNameSpace . '\\AppInfo\\Application';
132
-		if (!class_exists($applicationClassName)) {
133
-			// Nothing to boot
134
-			return;
135
-		}
136
-
137
-		/*
93
+            $appNameSpace = App::buildAppNamespace($appId);
94
+            $applicationClassName = $appNameSpace . '\\AppInfo\\Application';
95
+            if (class_exists($applicationClassName) && in_array(IBootstrap::class, class_implements($applicationClassName), true)) {
96
+                try {
97
+                    /** @var IBootstrap|App $application */
98
+                    $apps[$appId] = $application = $this->serverContainer->query($applicationClassName);
99
+                } catch (QueryException $e) {
100
+                    // Weird, but ok
101
+                    continue;
102
+                }
103
+                try {
104
+                    $application->register($this->registrationContext->for($appId));
105
+                } catch (Throwable $e) {
106
+                    $this->logger->logException($e, [
107
+                        'message' => 'Error during app service registration: ' . $e->getMessage(),
108
+                        'level' => ILogger::FATAL,
109
+                    ]);
110
+                }
111
+            }
112
+        }
113
+
114
+        /**
115
+         * Now that all register methods have been called, we can delegate the registrations
116
+         * to the actual services
117
+         */
118
+        $this->registrationContext->delegateCapabilityRegistrations($apps);
119
+        $this->registrationContext->delegateCrashReporterRegistrations($apps, $this->registry);
120
+        $this->registrationContext->delegateEventListenerRegistrations($this->eventDispatcher);
121
+        $this->registrationContext->delegateContainerRegistrations($apps);
122
+        $this->registrationContext->delegateMiddlewareRegistrations($apps);
123
+    }
124
+
125
+    public function getRegistrationContext(): ?RegistrationContext {
126
+        return $this->registrationContext;
127
+    }
128
+
129
+    public function bootApp(string $appId): void {
130
+        $appNameSpace = App::buildAppNamespace($appId);
131
+        $applicationClassName = $appNameSpace . '\\AppInfo\\Application';
132
+        if (!class_exists($applicationClassName)) {
133
+            // Nothing to boot
134
+            return;
135
+        }
136
+
137
+        /*
138 138
 		 * Now it is time to fetch an instance of the App class. For classes
139 139
 		 * that implement \OCP\AppFramework\Bootstrap\IBootstrap this means
140 140
 		 * the instance was already created for register, but any other
141 141
 		 * (legacy) code will now do their magic via the constructor.
142 142
 		 */
143
-		try {
144
-			/** @var App $application */
145
-			$application = $this->serverContainer->query($applicationClassName);
146
-			if ($application instanceof IBootstrap) {
147
-				/** @var BootContext $context */
148
-				$context = new BootContext($application->getContainer());
149
-				$application->boot($context);
150
-			}
151
-		} catch (QueryException $e) {
152
-			$this->logger->logException($e, [
153
-				'message' => "Could not boot $appId" . $e->getMessage(),
154
-			]);
155
-			return;
156
-		} catch (Throwable $e) {
157
-			$this->logger->logException($e, [
158
-				'message' => "Could not boot $appId" . $e->getMessage(),
159
-				'level' => ILogger::FATAL,
160
-			]);
161
-		}
162
-	}
143
+        try {
144
+            /** @var App $application */
145
+            $application = $this->serverContainer->query($applicationClassName);
146
+            if ($application instanceof IBootstrap) {
147
+                /** @var BootContext $context */
148
+                $context = new BootContext($application->getContainer());
149
+                $application->boot($context);
150
+            }
151
+        } catch (QueryException $e) {
152
+            $this->logger->logException($e, [
153
+                'message' => "Could not boot $appId" . $e->getMessage(),
154
+            ]);
155
+            return;
156
+        } catch (Throwable $e) {
157
+            $this->logger->logException($e, [
158
+                'message' => "Could not boot $appId" . $e->getMessage(),
159
+                'level' => ILogger::FATAL,
160
+            ]);
161
+        }
162
+    }
163 163
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 			 * the \OCP\AppFramework\Bootstrap\IBootstrap interface
92 92
 			 */
93 93
 			$appNameSpace = App::buildAppNamespace($appId);
94
-			$applicationClassName = $appNameSpace . '\\AppInfo\\Application';
94
+			$applicationClassName = $appNameSpace.'\\AppInfo\\Application';
95 95
 			if (class_exists($applicationClassName) && in_array(IBootstrap::class, class_implements($applicationClassName), true)) {
96 96
 				try {
97 97
 					/** @var IBootstrap|App $application */
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 					$application->register($this->registrationContext->for($appId));
105 105
 				} catch (Throwable $e) {
106 106
 					$this->logger->logException($e, [
107
-						'message' => 'Error during app service registration: ' . $e->getMessage(),
107
+						'message' => 'Error during app service registration: '.$e->getMessage(),
108 108
 						'level' => ILogger::FATAL,
109 109
 					]);
110 110
 				}
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 
129 129
 	public function bootApp(string $appId): void {
130 130
 		$appNameSpace = App::buildAppNamespace($appId);
131
-		$applicationClassName = $appNameSpace . '\\AppInfo\\Application';
131
+		$applicationClassName = $appNameSpace.'\\AppInfo\\Application';
132 132
 		if (!class_exists($applicationClassName)) {
133 133
 			// Nothing to boot
134 134
 			return;
@@ -150,12 +150,12 @@  discard block
 block discarded – undo
150 150
 			}
151 151
 		} catch (QueryException $e) {
152 152
 			$this->logger->logException($e, [
153
-				'message' => "Could not boot $appId" . $e->getMessage(),
153
+				'message' => "Could not boot $appId".$e->getMessage(),
154 154
 			]);
155 155
 			return;
156 156
 		} catch (Throwable $e) {
157 157
 			$this->logger->logException($e, [
158
-				'message' => "Could not boot $appId" . $e->getMessage(),
158
+				'message' => "Could not boot $appId".$e->getMessage(),
159 159
 				'level' => ILogger::FATAL,
160 160
 			]);
161 161
 		}
Please login to merge, or discard this patch.
lib/private/Search/SearchComposer.php 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -57,90 +57,90 @@
 block discarded – undo
57 57
  */
58 58
 class SearchComposer {
59 59
 
60
-	/** @var IProvider[] */
61
-	private $providers = [];
62
-
63
-	/** @var Coordinator */
64
-	private $bootstrapCoordinator;
65
-
66
-	/** @var IServerContainer */
67
-	private $container;
68
-
69
-	/** @var ILogger */
70
-	private $logger;
71
-
72
-	public function __construct(Coordinator $bootstrapCoordinator,
73
-								IServerContainer $container,
74
-								ILogger $logger) {
75
-		$this->container = $container;
76
-		$this->logger = $logger;
77
-		$this->bootstrapCoordinator = $bootstrapCoordinator;
78
-	}
79
-
80
-	/**
81
-	 * Load all providers dynamically that were registered through `registerProvider`
82
-	 *
83
-	 * If a provider can't be loaded we log it but the operation continues nevertheless
84
-	 */
85
-	private function loadLazyProviders(): void {
86
-		$context = $this->bootstrapCoordinator->getRegistrationContext();
87
-		if ($context === null) {
88
-			// Too early, nothing registered yet
89
-			return;
90
-		}
91
-
92
-		$registrations = $context->getSearchProviders();
93
-		foreach ($registrations as $registration) {
94
-			try {
95
-				/** @var IProvider $provider */
96
-				$provider = $this->container->query($registration['class']);
97
-				$this->providers[$provider->getId()] = $provider;
98
-			} catch (QueryException $e) {
99
-				// Log an continue. We can be fault tolerant here.
100
-				$this->logger->logException($e, [
101
-					'message' => 'Could not load search provider dynamically: ' . $e->getMessage(),
102
-					'level' => ILogger::ERROR,
103
-				]);
104
-			}
105
-		}
106
-	}
107
-
108
-	/**
109
-	 * Get a list of all provider IDs for the consecutive calls to `search`
110
-	 *
111
-	 * @return string[]
112
-	 */
113
-	public function getProviders(): array {
114
-		$this->loadLazyProviders();
115
-
116
-		/**
117
-		 * Return an array with the IDs, but strip the associative keys
118
-		 */
119
-		return array_values(
120
-			array_map(function (IProvider $provider) {
121
-				return $provider->getId();
122
-			}, $this->providers));
123
-	}
124
-
125
-	/**
126
-	 * Query an individual search provider for results
127
-	 *
128
-	 * @param IUser $user
129
-	 * @param string $providerId one of the IDs received by `getProviders`
130
-	 * @param ISearchQuery $query
131
-	 *
132
-	 * @return SearchResult
133
-	 * @throws InvalidArgumentException when the $providerId does not correspond to a registered provider
134
-	 */
135
-	public function search(IUser $user,
136
-						   string $providerId,
137
-						   ISearchQuery $query): SearchResult {
138
-		$this->loadLazyProviders();
139
-
140
-		$provider = $this->providers[$providerId] ?? null;
141
-		if ($provider === null) {
142
-			throw new InvalidArgumentException("Provider $providerId is unknown");
143
-		}
144
-		return $provider->search($user, $query);
145
-	}
60
+    /** @var IProvider[] */
61
+    private $providers = [];
62
+
63
+    /** @var Coordinator */
64
+    private $bootstrapCoordinator;
65
+
66
+    /** @var IServerContainer */
67
+    private $container;
68
+
69
+    /** @var ILogger */
70
+    private $logger;
71
+
72
+    public function __construct(Coordinator $bootstrapCoordinator,
73
+                                IServerContainer $container,
74
+                                ILogger $logger) {
75
+        $this->container = $container;
76
+        $this->logger = $logger;
77
+        $this->bootstrapCoordinator = $bootstrapCoordinator;
78
+    }
79
+
80
+    /**
81
+     * Load all providers dynamically that were registered through `registerProvider`
82
+     *
83
+     * If a provider can't be loaded we log it but the operation continues nevertheless
84
+     */
85
+    private function loadLazyProviders(): void {
86
+        $context = $this->bootstrapCoordinator->getRegistrationContext();
87
+        if ($context === null) {
88
+            // Too early, nothing registered yet
89
+            return;
90
+        }
91
+
92
+        $registrations = $context->getSearchProviders();
93
+        foreach ($registrations as $registration) {
94
+            try {
95
+                /** @var IProvider $provider */
96
+                $provider = $this->container->query($registration['class']);
97
+                $this->providers[$provider->getId()] = $provider;
98
+            } catch (QueryException $e) {
99
+                // Log an continue. We can be fault tolerant here.
100
+                $this->logger->logException($e, [
101
+                    'message' => 'Could not load search provider dynamically: ' . $e->getMessage(),
102
+                    'level' => ILogger::ERROR,
103
+                ]);
104
+            }
105
+        }
106
+    }
107
+
108
+    /**
109
+     * Get a list of all provider IDs for the consecutive calls to `search`
110
+     *
111
+     * @return string[]
112
+     */
113
+    public function getProviders(): array {
114
+        $this->loadLazyProviders();
115
+
116
+        /**
117
+         * Return an array with the IDs, but strip the associative keys
118
+         */
119
+        return array_values(
120
+            array_map(function (IProvider $provider) {
121
+                return $provider->getId();
122
+            }, $this->providers));
123
+    }
124
+
125
+    /**
126
+     * Query an individual search provider for results
127
+     *
128
+     * @param IUser $user
129
+     * @param string $providerId one of the IDs received by `getProviders`
130
+     * @param ISearchQuery $query
131
+     *
132
+     * @return SearchResult
133
+     * @throws InvalidArgumentException when the $providerId does not correspond to a registered provider
134
+     */
135
+    public function search(IUser $user,
136
+                            string $providerId,
137
+                            ISearchQuery $query): SearchResult {
138
+        $this->loadLazyProviders();
139
+
140
+        $provider = $this->providers[$providerId] ?? null;
141
+        if ($provider === null) {
142
+            throw new InvalidArgumentException("Provider $providerId is unknown");
143
+        }
144
+        return $provider->search($user, $query);
145
+    }
146 146
 }
Please login to merge, or discard this patch.