Passed
Push — master ( d1b03f...c1183f )
by Christoph
11:01 queued 11s
created
lib/public/AppFramework/Bootstrap/IRegistrationContext.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -37,72 +37,72 @@
 block discarded – undo
37 37
  */
38 38
 interface IRegistrationContext {
39 39
 
40
-	/**
41
-	 * @param string $capability
42
-	 * @see IAppContainer::registerCapability
43
-	 *
44
-	 * @since 20.0.0
45
-	 */
46
-	public function registerCapability(string $capability): void;
40
+    /**
41
+     * @param string $capability
42
+     * @see IAppContainer::registerCapability
43
+     *
44
+     * @since 20.0.0
45
+     */
46
+    public function registerCapability(string $capability): void;
47 47
 
48
-	/**
49
-	 * Register a service
50
-	 *
51
-	 * @param string $name
52
-	 * @param callable $factory
53
-	 * @param bool $shared
54
-	 *
55
-	 * @return void
56
-	 * @see IContainer::registerService()
57
-	 *
58
-	 * @since 20.0.0
59
-	 */
60
-	public function registerService(string $name, callable $factory, bool $shared = true): void;
48
+    /**
49
+     * Register a service
50
+     *
51
+     * @param string $name
52
+     * @param callable $factory
53
+     * @param bool $shared
54
+     *
55
+     * @return void
56
+     * @see IContainer::registerService()
57
+     *
58
+     * @since 20.0.0
59
+     */
60
+    public function registerService(string $name, callable $factory, bool $shared = true): void;
61 61
 
62
-	/**
63
-	 * @param string $alias
64
-	 * @param string $target
65
-	 *
66
-	 * @return void
67
-	 * @see IContainer::registerAlias()
68
-	 *
69
-	 * @since 20.0.0
70
-	 */
71
-	public function registerServiceAlias(string $alias, string $target): void;
62
+    /**
63
+     * @param string $alias
64
+     * @param string $target
65
+     *
66
+     * @return void
67
+     * @see IContainer::registerAlias()
68
+     *
69
+     * @since 20.0.0
70
+     */
71
+    public function registerServiceAlias(string $alias, string $target): void;
72 72
 
73
-	/**
74
-	 * @param string $name
75
-	 * @param mixed $value
76
-	 *
77
-	 * @return void
78
-	 * @see IContainer::registerParameter()
79
-	 *
80
-	 * @since 20.0.0
81
-	 */
82
-	public function registerParameter(string $name, $value): void;
73
+    /**
74
+     * @param string $name
75
+     * @param mixed $value
76
+     *
77
+     * @return void
78
+     * @see IContainer::registerParameter()
79
+     *
80
+     * @since 20.0.0
81
+     */
82
+    public function registerParameter(string $name, $value): void;
83 83
 
84
-	/**
85
-	 * Register a service listener
86
-	 *
87
-	 * This is equivalent to calling IEventDispatcher::addServiceListener
88
-	 *
89
-	 * @param string $event preferably the fully-qualified class name of the Event sub class to listen for
90
-	 * @param string $listener fully qualified class name (or ::class notation) of a \OCP\EventDispatcher\IEventListener that can be built by the DI container
91
-	 * @param int $priority
92
-	 *
93
-	 * @see IEventDispatcher::addServiceListener()
94
-	 *
95
-	 * @since 20.0.0
96
-	 */
97
-	public function registerEventListener(string $event, string $listener, int $priority = 0): void;
84
+    /**
85
+     * Register a service listener
86
+     *
87
+     * This is equivalent to calling IEventDispatcher::addServiceListener
88
+     *
89
+     * @param string $event preferably the fully-qualified class name of the Event sub class to listen for
90
+     * @param string $listener fully qualified class name (or ::class notation) of a \OCP\EventDispatcher\IEventListener that can be built by the DI container
91
+     * @param int $priority
92
+     *
93
+     * @see IEventDispatcher::addServiceListener()
94
+     *
95
+     * @since 20.0.0
96
+     */
97
+    public function registerEventListener(string $event, string $listener, int $priority = 0): void;
98 98
 
99
-	/**
100
-	 * @param string $class
101
-	 *
102
-	 * @return void
103
-	 * @see IAppContainer::registerMiddleWare()
104
-	 *
105
-	 * @since 20.0.0
106
-	 */
107
-	public function registerMiddleware(string $class): void;
99
+    /**
100
+     * @param string $class
101
+     *
102
+     * @return void
103
+     * @see IAppContainer::registerMiddleWare()
104
+     *
105
+     * @since 20.0.0
106
+     */
107
+    public function registerMiddleware(string $class): void;
108 108
 }
Please login to merge, or discard this patch.
lib/public/AppFramework/Bootstrap/IBootstrap.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -30,17 +30,17 @@
 block discarded – undo
30 30
  */
31 31
 interface IBootstrap {
32 32
 
33
-	/**
34
-	 * @param IRegistrationContext $context
35
-	 *
36
-	 * @since 20.0.0
37
-	 */
38
-	public function register(IRegistrationContext $context): void;
33
+    /**
34
+     * @param IRegistrationContext $context
35
+     *
36
+     * @since 20.0.0
37
+     */
38
+    public function register(IRegistrationContext $context): void;
39 39
 
40
-	/**
41
-	 * @param IBootContext $context
42
-	 *
43
-	 * @since 20.0.0
44
-	 */
45
-	public function boot(IBootContext $context): void;
40
+    /**
41
+     * @param IBootContext $context
42
+     *
43
+     * @since 20.0.0
44
+     */
45
+    public function boot(IBootContext $context): void;
46 46
 }
Please login to merge, or discard this patch.
lib/public/AppFramework/Bootstrap/IBootContext.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -33,23 +33,23 @@
 block discarded – undo
33 33
  */
34 34
 interface IBootContext {
35 35
 
36
-	/**
37
-	 * Get hold of the app's container
38
-	 *
39
-	 * Useful to register and query app-specific services
40
-	 *
41
-	 * @return IAppContainer
42
-	 * @since 20.0.0
43
-	 */
44
-	public function getAppContainer(): IAppContainer;
36
+    /**
37
+     * Get hold of the app's container
38
+     *
39
+     * Useful to register and query app-specific services
40
+     *
41
+     * @return IAppContainer
42
+     * @since 20.0.0
43
+     */
44
+    public function getAppContainer(): IAppContainer;
45 45
 
46
-	/**
47
-	 * Get hold of the server DI container
48
-	 *
49
-	 * Useful to register and query system-wide services
50
-	 *
51
-	 * @return IServerContainer
52
-	 * @since 20.0.0
53
-	 */
54
-	public function getServerContainer(): IServerContainer;
46
+    /**
47
+     * Get hold of the server DI container
48
+     *
49
+     * Useful to register and query system-wide services
50
+     *
51
+     * @return IServerContainer
52
+     * @since 20.0.0
53
+     */
54
+    public function getServerContainer(): IServerContainer;
55 55
 }
Please login to merge, or discard this patch.
lib/private/AppFramework/Bootstrap/RegistrationContext.php 2 patches
Indentation   +258 added lines, -258 removed lines patch added patch discarded remove patch
@@ -34,262 +34,262 @@
 block discarded – undo
34 34
 
35 35
 class RegistrationContext {
36 36
 
37
-	/** @var array[] */
38
-	private $capabilities = [];
39
-
40
-	/** @var array[] */
41
-	private $services = [];
42
-
43
-	/** @var array[] */
44
-	private $aliases = [];
45
-
46
-	/** @var array[] */
47
-	private $parameters = [];
48
-
49
-	/** @var array[] */
50
-	private $eventListeners = [];
51
-
52
-	/** @var array[] */
53
-	private $middlewares = [];
54
-
55
-	/** @var ILogger */
56
-	private $logger;
57
-
58
-	public function __construct(ILogger $logger) {
59
-		$this->logger = $logger;
60
-	}
61
-
62
-	public function for(string $appId): IRegistrationContext {
63
-		return new class($appId, $this) implements IRegistrationContext {
64
-			/** @var string */
65
-			private $appId;
66
-
67
-			/** @var RegistrationContext */
68
-			private $context;
69
-
70
-			public function __construct(string $appId, RegistrationContext $context) {
71
-				$this->appId = $appId;
72
-				$this->context = $context;
73
-			}
74
-
75
-			public function registerCapability(string $capability): void {
76
-				$this->context->registerCapability(
77
-					$this->appId,
78
-					$capability
79
-				);
80
-			}
81
-
82
-			public function registerService(string $name, callable $factory, bool $shared = true): void {
83
-				$this->context->registerService(
84
-					$this->appId,
85
-					$name,
86
-					$factory,
87
-					$shared
88
-				);
89
-			}
90
-
91
-			public function registerServiceAlias(string $alias, string $target): void {
92
-				$this->context->registerServiceAlias(
93
-					$this->appId,
94
-					$alias,
95
-					$target
96
-				);
97
-			}
98
-
99
-			public function registerParameter(string $name, $value): void {
100
-				$this->context->registerParameter(
101
-					$this->appId,
102
-					$name,
103
-					$value
104
-				);
105
-			}
106
-
107
-			public function registerEventListener(string $event, string $listener, int $priority = 0): void {
108
-				$this->context->registerEventListener(
109
-					$this->appId,
110
-					$event,
111
-					$listener,
112
-					$priority
113
-				);
114
-			}
115
-
116
-			public function registerMiddleware(string $class): void {
117
-				$this->context->registerMiddleware(
118
-					$this->appId,
119
-					$class
120
-				);
121
-			}
122
-		};
123
-	}
124
-
125
-	public function registerCapability(string $appId, string $capability): void {
126
-		$this->capabilities[] = [
127
-			'appId' => $appId,
128
-			'capability' => $capability
129
-		];
130
-	}
131
-
132
-	public function registerService(string $appId, string $name, callable $factory, bool $shared = true): void {
133
-		$this->services[] = [
134
-			"appId" => $appId,
135
-			"name" => $name,
136
-			"factory" => $factory,
137
-			"sharred" => $shared,
138
-		];
139
-	}
140
-
141
-	public function registerServiceAlias(string $appId, string $alias, string $target): void {
142
-		$this->aliases[] = [
143
-			"appId" => $appId,
144
-			"alias" => $alias,
145
-			"target" => $target,
146
-		];
147
-	}
148
-
149
-	public function registerParameter(string $appId, string $name, $value): void {
150
-		$this->parameters[] = [
151
-			"appId" => $appId,
152
-			"name" => $name,
153
-			"value" => $value,
154
-		];
155
-	}
156
-
157
-	public function registerEventListener(string $appId, string $event, string $listener, int $priority = 0): void {
158
-		$this->eventListeners[] = [
159
-			"appId" => $appId,
160
-			"event" => $event,
161
-			"listener" => $listener,
162
-			"priority" => $priority,
163
-		];
164
-	}
165
-
166
-	public function registerMiddleware(string $appId, string $class): void {
167
-		$this->middlewares[] = [
168
-			"appId" => $appId,
169
-			"class" => $class,
170
-		];
171
-	}
172
-
173
-	/**
174
-	 * @param App[] $apps
175
-	 */
176
-	public function delegateCapabilityRegistrations(array $apps): void {
177
-		foreach ($this->capabilities as $registration) {
178
-			try {
179
-				$apps[$registration['appId']]
180
-					->getContainer()
181
-					->registerCapability($registration['capability']);
182
-			} catch (Throwable $e) {
183
-				$appId = $registration['appId'];
184
-				$this->logger->logException($e, [
185
-					'message' => "Error during capability registration of $appId: " . $e->getMessage(),
186
-					'level' => ILogger::ERROR,
187
-				]);
188
-			}
189
-		}
190
-	}
191
-
192
-	public function delegateEventListenerRegistrations(IEventDispatcher $eventDispatcher): void {
193
-		foreach ($this->eventListeners as $registration) {
194
-			try {
195
-				if (isset($registration['priority'])) {
196
-					$eventDispatcher->addServiceListener(
197
-						$registration['event'],
198
-						$registration['listener'],
199
-						$registration['priority']
200
-					);
201
-				} else {
202
-					$eventDispatcher->addListener(
203
-						$registration['event'],
204
-						$registration['listener']
205
-					);
206
-				}
207
-			} catch (Throwable $e) {
208
-				$appId = $registration['appId'];
209
-				$this->logger->logException($e, [
210
-					'message' => "Error during event listener registration of $appId: " . $e->getMessage(),
211
-					'level' => ILogger::ERROR,
212
-				]);
213
-			}
214
-		}
215
-	}
216
-
217
-	/**
218
-	 * @param App[] $apps
219
-	 */
220
-	public function delegateContainerRegistrations(array $apps): void {
221
-		foreach ($this->services as $registration) {
222
-			try {
223
-				/**
224
-				 * Register the service and convert the callable into a \Closure if necessary
225
-				 */
226
-				$apps[$registration['appId']]
227
-					->getContainer()
228
-					->registerService(
229
-						$registration['name'],
230
-						Closure::fromCallable($registration['factory']),
231
-						$registration['shared'] ?? true
232
-					);
233
-			} catch (Throwable $e) {
234
-				$appId = $registration['appId'];
235
-				$this->logger->logException($e, [
236
-					'message' => "Error during service registration of $appId: " . $e->getMessage(),
237
-					'level' => ILogger::ERROR,
238
-				]);
239
-			}
240
-		}
241
-
242
-		foreach ($this->aliases as $registration) {
243
-			try {
244
-				$apps[$registration['appId']]
245
-					->getContainer()
246
-					->registerAlias(
247
-						$registration['alias'],
248
-						$registration['target']
249
-					);
250
-			} catch (Throwable $e) {
251
-				$appId = $registration['appId'];
252
-				$this->logger->logException($e, [
253
-					'message' => "Error during service alias registration of $appId: " . $e->getMessage(),
254
-					'level' => ILogger::ERROR,
255
-				]);
256
-			}
257
-		}
258
-
259
-		foreach ($this->parameters as $registration) {
260
-			try {
261
-				$apps[$registration['appId']]
262
-					->getContainer()
263
-					->registerParameter(
264
-						$registration['name'],
265
-						$registration['value']
266
-					);
267
-			} catch (Throwable $e) {
268
-				$appId = $registration['appId'];
269
-				$this->logger->logException($e, [
270
-					'message' => "Error during service alias registration of $appId: " . $e->getMessage(),
271
-					'level' => ILogger::ERROR,
272
-				]);
273
-			}
274
-		}
275
-	}
276
-
277
-	/**
278
-	 * @param App[] $apps
279
-	 */
280
-	public function delegateMiddlewareRegistrations(array $apps): void {
281
-		foreach ($this->middlewares as $middleware) {
282
-			try {
283
-				$apps[$middleware['appId']]
284
-					->getContainer()
285
-					->registerMiddleWare($middleware['class']);
286
-			} catch (Throwable $e) {
287
-				$appId = $middleware['appId'];
288
-				$this->logger->logException($e, [
289
-					'message' => "Error during capability registration of $appId: " . $e->getMessage(),
290
-					'level' => ILogger::ERROR,
291
-				]);
292
-			}
293
-		}
294
-	}
37
+    /** @var array[] */
38
+    private $capabilities = [];
39
+
40
+    /** @var array[] */
41
+    private $services = [];
42
+
43
+    /** @var array[] */
44
+    private $aliases = [];
45
+
46
+    /** @var array[] */
47
+    private $parameters = [];
48
+
49
+    /** @var array[] */
50
+    private $eventListeners = [];
51
+
52
+    /** @var array[] */
53
+    private $middlewares = [];
54
+
55
+    /** @var ILogger */
56
+    private $logger;
57
+
58
+    public function __construct(ILogger $logger) {
59
+        $this->logger = $logger;
60
+    }
61
+
62
+    public function for(string $appId): IRegistrationContext {
63
+        return new class($appId, $this) implements IRegistrationContext {
64
+            /** @var string */
65
+            private $appId;
66
+
67
+            /** @var RegistrationContext */
68
+            private $context;
69
+
70
+            public function __construct(string $appId, RegistrationContext $context) {
71
+                $this->appId = $appId;
72
+                $this->context = $context;
73
+            }
74
+
75
+            public function registerCapability(string $capability): void {
76
+                $this->context->registerCapability(
77
+                    $this->appId,
78
+                    $capability
79
+                );
80
+            }
81
+
82
+            public function registerService(string $name, callable $factory, bool $shared = true): void {
83
+                $this->context->registerService(
84
+                    $this->appId,
85
+                    $name,
86
+                    $factory,
87
+                    $shared
88
+                );
89
+            }
90
+
91
+            public function registerServiceAlias(string $alias, string $target): void {
92
+                $this->context->registerServiceAlias(
93
+                    $this->appId,
94
+                    $alias,
95
+                    $target
96
+                );
97
+            }
98
+
99
+            public function registerParameter(string $name, $value): void {
100
+                $this->context->registerParameter(
101
+                    $this->appId,
102
+                    $name,
103
+                    $value
104
+                );
105
+            }
106
+
107
+            public function registerEventListener(string $event, string $listener, int $priority = 0): void {
108
+                $this->context->registerEventListener(
109
+                    $this->appId,
110
+                    $event,
111
+                    $listener,
112
+                    $priority
113
+                );
114
+            }
115
+
116
+            public function registerMiddleware(string $class): void {
117
+                $this->context->registerMiddleware(
118
+                    $this->appId,
119
+                    $class
120
+                );
121
+            }
122
+        };
123
+    }
124
+
125
+    public function registerCapability(string $appId, string $capability): void {
126
+        $this->capabilities[] = [
127
+            'appId' => $appId,
128
+            'capability' => $capability
129
+        ];
130
+    }
131
+
132
+    public function registerService(string $appId, string $name, callable $factory, bool $shared = true): void {
133
+        $this->services[] = [
134
+            "appId" => $appId,
135
+            "name" => $name,
136
+            "factory" => $factory,
137
+            "sharred" => $shared,
138
+        ];
139
+    }
140
+
141
+    public function registerServiceAlias(string $appId, string $alias, string $target): void {
142
+        $this->aliases[] = [
143
+            "appId" => $appId,
144
+            "alias" => $alias,
145
+            "target" => $target,
146
+        ];
147
+    }
148
+
149
+    public function registerParameter(string $appId, string $name, $value): void {
150
+        $this->parameters[] = [
151
+            "appId" => $appId,
152
+            "name" => $name,
153
+            "value" => $value,
154
+        ];
155
+    }
156
+
157
+    public function registerEventListener(string $appId, string $event, string $listener, int $priority = 0): void {
158
+        $this->eventListeners[] = [
159
+            "appId" => $appId,
160
+            "event" => $event,
161
+            "listener" => $listener,
162
+            "priority" => $priority,
163
+        ];
164
+    }
165
+
166
+    public function registerMiddleware(string $appId, string $class): void {
167
+        $this->middlewares[] = [
168
+            "appId" => $appId,
169
+            "class" => $class,
170
+        ];
171
+    }
172
+
173
+    /**
174
+     * @param App[] $apps
175
+     */
176
+    public function delegateCapabilityRegistrations(array $apps): void {
177
+        foreach ($this->capabilities as $registration) {
178
+            try {
179
+                $apps[$registration['appId']]
180
+                    ->getContainer()
181
+                    ->registerCapability($registration['capability']);
182
+            } catch (Throwable $e) {
183
+                $appId = $registration['appId'];
184
+                $this->logger->logException($e, [
185
+                    'message' => "Error during capability registration of $appId: " . $e->getMessage(),
186
+                    'level' => ILogger::ERROR,
187
+                ]);
188
+            }
189
+        }
190
+    }
191
+
192
+    public function delegateEventListenerRegistrations(IEventDispatcher $eventDispatcher): void {
193
+        foreach ($this->eventListeners as $registration) {
194
+            try {
195
+                if (isset($registration['priority'])) {
196
+                    $eventDispatcher->addServiceListener(
197
+                        $registration['event'],
198
+                        $registration['listener'],
199
+                        $registration['priority']
200
+                    );
201
+                } else {
202
+                    $eventDispatcher->addListener(
203
+                        $registration['event'],
204
+                        $registration['listener']
205
+                    );
206
+                }
207
+            } catch (Throwable $e) {
208
+                $appId = $registration['appId'];
209
+                $this->logger->logException($e, [
210
+                    'message' => "Error during event listener registration of $appId: " . $e->getMessage(),
211
+                    'level' => ILogger::ERROR,
212
+                ]);
213
+            }
214
+        }
215
+    }
216
+
217
+    /**
218
+     * @param App[] $apps
219
+     */
220
+    public function delegateContainerRegistrations(array $apps): void {
221
+        foreach ($this->services as $registration) {
222
+            try {
223
+                /**
224
+                 * Register the service and convert the callable into a \Closure if necessary
225
+                 */
226
+                $apps[$registration['appId']]
227
+                    ->getContainer()
228
+                    ->registerService(
229
+                        $registration['name'],
230
+                        Closure::fromCallable($registration['factory']),
231
+                        $registration['shared'] ?? true
232
+                    );
233
+            } catch (Throwable $e) {
234
+                $appId = $registration['appId'];
235
+                $this->logger->logException($e, [
236
+                    'message' => "Error during service registration of $appId: " . $e->getMessage(),
237
+                    'level' => ILogger::ERROR,
238
+                ]);
239
+            }
240
+        }
241
+
242
+        foreach ($this->aliases as $registration) {
243
+            try {
244
+                $apps[$registration['appId']]
245
+                    ->getContainer()
246
+                    ->registerAlias(
247
+                        $registration['alias'],
248
+                        $registration['target']
249
+                    );
250
+            } catch (Throwable $e) {
251
+                $appId = $registration['appId'];
252
+                $this->logger->logException($e, [
253
+                    'message' => "Error during service alias registration of $appId: " . $e->getMessage(),
254
+                    'level' => ILogger::ERROR,
255
+                ]);
256
+            }
257
+        }
258
+
259
+        foreach ($this->parameters as $registration) {
260
+            try {
261
+                $apps[$registration['appId']]
262
+                    ->getContainer()
263
+                    ->registerParameter(
264
+                        $registration['name'],
265
+                        $registration['value']
266
+                    );
267
+            } catch (Throwable $e) {
268
+                $appId = $registration['appId'];
269
+                $this->logger->logException($e, [
270
+                    'message' => "Error during service alias registration of $appId: " . $e->getMessage(),
271
+                    'level' => ILogger::ERROR,
272
+                ]);
273
+            }
274
+        }
275
+    }
276
+
277
+    /**
278
+     * @param App[] $apps
279
+     */
280
+    public function delegateMiddlewareRegistrations(array $apps): void {
281
+        foreach ($this->middlewares as $middleware) {
282
+            try {
283
+                $apps[$middleware['appId']]
284
+                    ->getContainer()
285
+                    ->registerMiddleWare($middleware['class']);
286
+            } catch (Throwable $e) {
287
+                $appId = $middleware['appId'];
288
+                $this->logger->logException($e, [
289
+                    'message' => "Error during capability registration of $appId: " . $e->getMessage(),
290
+                    'level' => ILogger::ERROR,
291
+                ]);
292
+            }
293
+        }
294
+    }
295 295
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		$this->logger = $logger;
60 60
 	}
61 61
 
62
-	public function for(string $appId): IRegistrationContext {
62
+	public function for (string $appId): IRegistrationContext {
63 63
 		return new class($appId, $this) implements IRegistrationContext {
64 64
 			/** @var string */
65 65
 			private $appId;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 			} catch (Throwable $e) {
183 183
 				$appId = $registration['appId'];
184 184
 				$this->logger->logException($e, [
185
-					'message' => "Error during capability registration of $appId: " . $e->getMessage(),
185
+					'message' => "Error during capability registration of $appId: ".$e->getMessage(),
186 186
 					'level' => ILogger::ERROR,
187 187
 				]);
188 188
 			}
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 			} catch (Throwable $e) {
208 208
 				$appId = $registration['appId'];
209 209
 				$this->logger->logException($e, [
210
-					'message' => "Error during event listener registration of $appId: " . $e->getMessage(),
210
+					'message' => "Error during event listener registration of $appId: ".$e->getMessage(),
211 211
 					'level' => ILogger::ERROR,
212 212
 				]);
213 213
 			}
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 			} catch (Throwable $e) {
234 234
 				$appId = $registration['appId'];
235 235
 				$this->logger->logException($e, [
236
-					'message' => "Error during service registration of $appId: " . $e->getMessage(),
236
+					'message' => "Error during service registration of $appId: ".$e->getMessage(),
237 237
 					'level' => ILogger::ERROR,
238 238
 				]);
239 239
 			}
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 			} catch (Throwable $e) {
251 251
 				$appId = $registration['appId'];
252 252
 				$this->logger->logException($e, [
253
-					'message' => "Error during service alias registration of $appId: " . $e->getMessage(),
253
+					'message' => "Error during service alias registration of $appId: ".$e->getMessage(),
254 254
 					'level' => ILogger::ERROR,
255 255
 				]);
256 256
 			}
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 			} catch (Throwable $e) {
268 268
 				$appId = $registration['appId'];
269 269
 				$this->logger->logException($e, [
270
-					'message' => "Error during service alias registration of $appId: " . $e->getMessage(),
270
+					'message' => "Error during service alias registration of $appId: ".$e->getMessage(),
271 271
 					'level' => ILogger::ERROR,
272 272
 				]);
273 273
 			}
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 			} catch (Throwable $e) {
287 287
 				$appId = $middleware['appId'];
288 288
 				$this->logger->logException($e, [
289
-					'message' => "Error during capability registration of $appId: " . $e->getMessage(),
289
+					'message' => "Error during capability registration of $appId: ".$e->getMessage(),
290 290
 					'level' => ILogger::ERROR,
291 291
 				]);
292 292
 			}
Please login to merge, or discard this patch.
lib/private/AppFramework/Bootstrap/BootContext.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -31,18 +31,18 @@
 block discarded – undo
31 31
 
32 32
 class BootContext implements IBootContext {
33 33
 
34
-	/** @var IAppContainer */
35
-	private $appContainer;
34
+    /** @var IAppContainer */
35
+    private $appContainer;
36 36
 
37
-	public function __construct(IAppContainer $appContainer) {
38
-		$this->appContainer = $appContainer;
39
-	}
37
+    public function __construct(IAppContainer $appContainer) {
38
+        $this->appContainer = $appContainer;
39
+    }
40 40
 
41
-	public function getAppContainer(): IAppContainer {
42
-		return $this->appContainer;
43
-	}
41
+    public function getAppContainer(): IAppContainer {
42
+        return $this->appContainer;
43
+    }
44 44
 
45
-	public function getServerContainer(): IServerContainer {
46
-		return $this->appContainer->getServer();
47
-	}
45
+    public function getServerContainer(): IServerContainer {
46
+        return $this->appContainer->getServer();
47
+    }
48 48
 }
Please login to merge, or discard this patch.
lib/private/AppFramework/Bootstrap/Coordinator.php 2 patches
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -38,93 +38,93 @@
 block discarded – undo
38 38
 
39 39
 class Coordinator {
40 40
 
41
-	/** @var IServerContainer */
42
-	private $serverContainer;
41
+    /** @var IServerContainer */
42
+    private $serverContainer;
43 43
 
44
-	/** @var IEventDispatcher */
45
-	private $eventDispatcher;
44
+    /** @var IEventDispatcher */
45
+    private $eventDispatcher;
46 46
 
47
-	/** @var ILogger */
48
-	private $logger;
47
+    /** @var ILogger */
48
+    private $logger;
49 49
 
50
-	public function __construct(IServerContainer $container,
51
-								IEventDispatcher $eventListener,
52
-								ILogger $logger) {
53
-		$this->serverContainer = $container;
54
-		$this->eventDispatcher = $eventListener;
55
-		$this->logger = $logger;
56
-	}
50
+    public function __construct(IServerContainer $container,
51
+                                IEventDispatcher $eventListener,
52
+                                ILogger $logger) {
53
+        $this->serverContainer = $container;
54
+        $this->eventDispatcher = $eventListener;
55
+        $this->logger = $logger;
56
+    }
57 57
 
58
-	public function runRegistration(): void {
59
-		$context = new RegistrationContext($this->logger);
60
-		$apps = [];
61
-		foreach (OC_App::getEnabledApps() as $appId) {
62
-			/*
58
+    public function runRegistration(): void {
59
+        $context = new RegistrationContext($this->logger);
60
+        $apps = [];
61
+        foreach (OC_App::getEnabledApps() as $appId) {
62
+            /*
63 63
 			 * First, we have to enable the app's autoloader
64 64
 			 *
65 65
 			 * @todo use $this->appManager->getAppPath($appId) here
66 66
 			 */
67
-			$path = OC_App::getAppPath($appId);
68
-			if ($path === false) {
69
-				// Ignore
70
-				continue;
71
-			}
72
-			OC_App::registerAutoloading($appId, $path);
67
+            $path = OC_App::getAppPath($appId);
68
+            if ($path === false) {
69
+                // Ignore
70
+                continue;
71
+            }
72
+            OC_App::registerAutoloading($appId, $path);
73 73
 
74
-			/*
74
+            /*
75 75
 			 * Next we check if there is an application class and it implements
76 76
 			 * the \OCP\AppFramework\Bootstrap\IBootstrap interface
77 77
 			 */
78
-			$appNameSpace = App::buildAppNamespace($appId);
79
-			$applicationClassName = $appNameSpace . '\\AppInfo\\Application';
80
-			if (class_exists($applicationClassName) && in_array(IBootstrap::class, class_implements($applicationClassName), true)) {
81
-				try {
82
-					/** @var IBootstrap|App $application */
83
-					$apps[$appId] = $application = $this->serverContainer->query($applicationClassName);
84
-					$application->register($context->for($appId));
85
-				} catch (QueryException $e) {
86
-					// Weird, but ok
87
-				}
88
-			}
89
-		}
78
+            $appNameSpace = App::buildAppNamespace($appId);
79
+            $applicationClassName = $appNameSpace . '\\AppInfo\\Application';
80
+            if (class_exists($applicationClassName) && in_array(IBootstrap::class, class_implements($applicationClassName), true)) {
81
+                try {
82
+                    /** @var IBootstrap|App $application */
83
+                    $apps[$appId] = $application = $this->serverContainer->query($applicationClassName);
84
+                    $application->register($context->for($appId));
85
+                } catch (QueryException $e) {
86
+                    // Weird, but ok
87
+                }
88
+            }
89
+        }
90 90
 
91
-		/**
92
-		 * Now that all register methods have been called, we can delegate the registrations
93
-		 * to the actual services
94
-		 */
95
-		$context->delegateCapabilityRegistrations($apps);
96
-		$context->delegateEventListenerRegistrations($this->eventDispatcher);
97
-		$context->delegateContainerRegistrations($apps);
98
-		$context->delegateMiddlewareRegistrations($apps);
99
-	}
91
+        /**
92
+         * Now that all register methods have been called, we can delegate the registrations
93
+         * to the actual services
94
+         */
95
+        $context->delegateCapabilityRegistrations($apps);
96
+        $context->delegateEventListenerRegistrations($this->eventDispatcher);
97
+        $context->delegateContainerRegistrations($apps);
98
+        $context->delegateMiddlewareRegistrations($apps);
99
+    }
100 100
 
101
-	public function bootApp(string $appId): void {
102
-		$appNameSpace = App::buildAppNamespace($appId);
103
-		$applicationClassName = $appNameSpace . '\\AppInfo\\Application';
104
-		if (!class_exists($applicationClassName)) {
105
-			// Nothing to boot
106
-			return;
107
-		}
101
+    public function bootApp(string $appId): void {
102
+        $appNameSpace = App::buildAppNamespace($appId);
103
+        $applicationClassName = $appNameSpace . '\\AppInfo\\Application';
104
+        if (!class_exists($applicationClassName)) {
105
+            // Nothing to boot
106
+            return;
107
+        }
108 108
 
109
-		/*
109
+        /*
110 110
 		 * Now it is time to fetch an instance of the App class. For classes
111 111
 		 * that implement \OCP\AppFramework\Bootstrap\IBootstrap this means
112 112
 		 * the instance was already created for register, but any other
113 113
 		 * (legacy) code will now do their magic via the constructor.
114 114
 		 */
115
-		try {
116
-			/** @var App $application */
117
-			$application = $this->serverContainer->query($applicationClassName);
118
-			if ($application instanceof IBootstrap) {
119
-				/** @var BootContext $context */
120
-				$context = new BootContext($application->getContainer());
121
-				$application->boot($context);
122
-			}
123
-		} catch (QueryException $e) {
124
-			$this->logger->logException($e, [
125
-				'message' => "Could not boot $appId" . $e->getMessage(),
126
-			]);
127
-			return;
128
-		}
129
-	}
115
+        try {
116
+            /** @var App $application */
117
+            $application = $this->serverContainer->query($applicationClassName);
118
+            if ($application instanceof IBootstrap) {
119
+                /** @var BootContext $context */
120
+                $context = new BootContext($application->getContainer());
121
+                $application->boot($context);
122
+            }
123
+        } catch (QueryException $e) {
124
+            $this->logger->logException($e, [
125
+                'message' => "Could not boot $appId" . $e->getMessage(),
126
+            ]);
127
+            return;
128
+        }
129
+    }
130 130
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 			 * the \OCP\AppFramework\Bootstrap\IBootstrap interface
77 77
 			 */
78 78
 			$appNameSpace = App::buildAppNamespace($appId);
79
-			$applicationClassName = $appNameSpace . '\\AppInfo\\Application';
79
+			$applicationClassName = $appNameSpace.'\\AppInfo\\Application';
80 80
 			if (class_exists($applicationClassName) && in_array(IBootstrap::class, class_implements($applicationClassName), true)) {
81 81
 				try {
82 82
 					/** @var IBootstrap|App $application */
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 
101 101
 	public function bootApp(string $appId): void {
102 102
 		$appNameSpace = App::buildAppNamespace($appId);
103
-		$applicationClassName = $appNameSpace . '\\AppInfo\\Application';
103
+		$applicationClassName = $appNameSpace.'\\AppInfo\\Application';
104 104
 		if (!class_exists($applicationClassName)) {
105 105
 			// Nothing to boot
106 106
 			return;
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 			}
123 123
 		} catch (QueryException $e) {
124 124
 			$this->logger->logException($e, [
125
-				'message' => "Could not boot $appId" . $e->getMessage(),
125
+				'message' => "Could not boot $appId".$e->getMessage(),
126 126
 			]);
127 127
 			return;
128 128
 		}
Please login to merge, or discard this patch.
lib/private/legacy/OC_App.php 2 patches
Indentation   +1055 added lines, -1055 removed lines patch added patch discarded remove patch
@@ -65,1059 +65,1059 @@
 block discarded – undo
65 65
  * upgrading and removing apps.
66 66
  */
67 67
 class OC_App {
68
-	private static $adminForms = [];
69
-	private static $personalForms = [];
70
-	private static $appTypes = [];
71
-	private static $loadedApps = [];
72
-	private static $altLogin = [];
73
-	private static $alreadyRegistered = [];
74
-	public const supportedApp = 300;
75
-	public const officialApp = 200;
76
-
77
-	/**
78
-	 * clean the appId
79
-	 *
80
-	 * @param string $app AppId that needs to be cleaned
81
-	 * @return string
82
-	 */
83
-	public static function cleanAppId(string $app): string {
84
-		return str_replace(['\0', '/', '\\', '..'], '', $app);
85
-	}
86
-
87
-	/**
88
-	 * Check if an app is loaded
89
-	 *
90
-	 * @param string $app
91
-	 * @return bool
92
-	 */
93
-	public static function isAppLoaded(string $app): bool {
94
-		return in_array($app, self::$loadedApps, true);
95
-	}
96
-
97
-	/**
98
-	 * loads all apps
99
-	 *
100
-	 * @param string[] $types
101
-	 * @return bool
102
-	 *
103
-	 * This function walks through the ownCloud directory and loads all apps
104
-	 * it can find. A directory contains an app if the file /appinfo/info.xml
105
-	 * exists.
106
-	 *
107
-	 * if $types is set to non-empty array, only apps of those types will be loaded
108
-	 */
109
-	public static function loadApps(array $types = []): bool {
110
-		if ((bool) \OC::$server->getSystemConfig()->getValue('maintenance', false)) {
111
-			return false;
112
-		}
113
-		// Load the enabled apps here
114
-		$apps = self::getEnabledApps();
115
-
116
-		// Add each apps' folder as allowed class path
117
-		foreach ($apps as $app) {
118
-			$path = self::getAppPath($app);
119
-			if ($path !== false) {
120
-				self::registerAutoloading($app, $path);
121
-			}
122
-		}
123
-
124
-		// prevent app.php from printing output
125
-		ob_start();
126
-		foreach ($apps as $app) {
127
-			if (($types === [] or self::isType($app, $types)) && !in_array($app, self::$loadedApps)) {
128
-				self::loadApp($app);
129
-			}
130
-		}
131
-		ob_end_clean();
132
-
133
-		return true;
134
-	}
135
-
136
-	/**
137
-	 * load a single app
138
-	 *
139
-	 * @param string $app
140
-	 * @throws Exception
141
-	 */
142
-	public static function loadApp(string $app) {
143
-		self::$loadedApps[] = $app;
144
-		$appPath = self::getAppPath($app);
145
-		if ($appPath === false) {
146
-			return;
147
-		}
148
-
149
-		// in case someone calls loadApp() directly
150
-		self::registerAutoloading($app, $appPath);
151
-
152
-		/** @var \OC\AppFramework\Bootstrap\Coordinator $coordinator */
153
-		$coordinator = \OC::$server->query(\OC\AppFramework\Bootstrap\Coordinator::class);
154
-		$coordinator->bootApp($app);
155
-		if (is_file($appPath . '/appinfo/app.php')) {
156
-			\OC::$server->getEventLogger()->start('load_app_' . $app, 'Load app: ' . $app);
157
-			try {
158
-				self::requireAppFile($app);
159
-			} catch (Throwable $ex) {
160
-				if ($ex instanceof ServerNotAvailableException) {
161
-					throw $ex;
162
-				}
163
-				if (!\OC::$server->getAppManager()->isShipped($app) && !self::isType($app, ['authentication'])) {
164
-					\OC::$server->getLogger()->logException($ex, [
165
-						'message' => "App $app threw an error during app.php load and will be disabled: " . $ex->getMessage(),
166
-					]);
167
-
168
-					// Only disable apps which are not shipped and that are not authentication apps
169
-					\OC::$server->getAppManager()->disableApp($app, true);
170
-				} else {
171
-					\OC::$server->getLogger()->logException($ex, [
172
-						'message' => "App $app threw an error during app.php load: " . $ex->getMessage(),
173
-					]);
174
-				}
175
-			}
176
-			\OC::$server->getEventLogger()->end('load_app_' . $app);
177
-		}
178
-
179
-		$info = self::getAppInfo($app);
180
-		if (!empty($info['activity']['filters'])) {
181
-			foreach ($info['activity']['filters'] as $filter) {
182
-				\OC::$server->getActivityManager()->registerFilter($filter);
183
-			}
184
-		}
185
-		if (!empty($info['activity']['settings'])) {
186
-			foreach ($info['activity']['settings'] as $setting) {
187
-				\OC::$server->getActivityManager()->registerSetting($setting);
188
-			}
189
-		}
190
-		if (!empty($info['activity']['providers'])) {
191
-			foreach ($info['activity']['providers'] as $provider) {
192
-				\OC::$server->getActivityManager()->registerProvider($provider);
193
-			}
194
-		}
195
-
196
-		if (!empty($info['settings']['admin'])) {
197
-			foreach ($info['settings']['admin'] as $setting) {
198
-				\OC::$server->getSettingsManager()->registerSetting('admin', $setting);
199
-			}
200
-		}
201
-		if (!empty($info['settings']['admin-section'])) {
202
-			foreach ($info['settings']['admin-section'] as $section) {
203
-				\OC::$server->getSettingsManager()->registerSection('admin', $section);
204
-			}
205
-		}
206
-		if (!empty($info['settings']['personal'])) {
207
-			foreach ($info['settings']['personal'] as $setting) {
208
-				\OC::$server->getSettingsManager()->registerSetting('personal', $setting);
209
-			}
210
-		}
211
-		if (!empty($info['settings']['personal-section'])) {
212
-			foreach ($info['settings']['personal-section'] as $section) {
213
-				\OC::$server->getSettingsManager()->registerSection('personal', $section);
214
-			}
215
-		}
216
-
217
-		if (!empty($info['collaboration']['plugins'])) {
218
-			// deal with one or many plugin entries
219
-			$plugins = isset($info['collaboration']['plugins']['plugin']['@value']) ?
220
-				[$info['collaboration']['plugins']['plugin']] : $info['collaboration']['plugins']['plugin'];
221
-			foreach ($plugins as $plugin) {
222
-				if ($plugin['@attributes']['type'] === 'collaborator-search') {
223
-					$pluginInfo = [
224
-						'shareType' => $plugin['@attributes']['share-type'],
225
-						'class' => $plugin['@value'],
226
-					];
227
-					\OC::$server->getCollaboratorSearch()->registerPlugin($pluginInfo);
228
-				} elseif ($plugin['@attributes']['type'] === 'autocomplete-sort') {
229
-					\OC::$server->getAutoCompleteManager()->registerSorter($plugin['@value']);
230
-				}
231
-			}
232
-		}
233
-	}
234
-
235
-	/**
236
-	 * @internal
237
-	 * @param string $app
238
-	 * @param string $path
239
-	 * @param bool $force
240
-	 */
241
-	public static function registerAutoloading(string $app, string $path, bool $force = false) {
242
-		$key = $app . '-' . $path;
243
-		if (!$force && isset(self::$alreadyRegistered[$key])) {
244
-			return;
245
-		}
246
-
247
-		self::$alreadyRegistered[$key] = true;
248
-
249
-		// Register on PSR-4 composer autoloader
250
-		$appNamespace = \OC\AppFramework\App::buildAppNamespace($app);
251
-		\OC::$server->registerNamespace($app, $appNamespace);
252
-
253
-		if (file_exists($path . '/composer/autoload.php')) {
254
-			require_once $path . '/composer/autoload.php';
255
-		} else {
256
-			\OC::$composerAutoloader->addPsr4($appNamespace . '\\', $path . '/lib/', true);
257
-			// Register on legacy autoloader
258
-			\OC::$loader->addValidRoot($path);
259
-		}
260
-
261
-		// Register Test namespace only when testing
262
-		if (defined('PHPUNIT_RUN') || defined('CLI_TEST_RUN')) {
263
-			\OC::$composerAutoloader->addPsr4($appNamespace . '\\Tests\\', $path . '/tests/', true);
264
-		}
265
-	}
266
-
267
-	/**
268
-	 * Load app.php from the given app
269
-	 *
270
-	 * @param string $app app name
271
-	 * @throws Error
272
-	 */
273
-	private static function requireAppFile(string $app) {
274
-		// encapsulated here to avoid variable scope conflicts
275
-		require_once $app . '/appinfo/app.php';
276
-	}
277
-
278
-	/**
279
-	 * check if an app is of a specific type
280
-	 *
281
-	 * @param string $app
282
-	 * @param array $types
283
-	 * @return bool
284
-	 */
285
-	public static function isType(string $app, array $types): bool {
286
-		$appTypes = self::getAppTypes($app);
287
-		foreach ($types as $type) {
288
-			if (array_search($type, $appTypes) !== false) {
289
-				return true;
290
-			}
291
-		}
292
-		return false;
293
-	}
294
-
295
-	/**
296
-	 * get the types of an app
297
-	 *
298
-	 * @param string $app
299
-	 * @return array
300
-	 */
301
-	private static function getAppTypes(string $app): array {
302
-		//load the cache
303
-		if (count(self::$appTypes) == 0) {
304
-			self::$appTypes = \OC::$server->getAppConfig()->getValues(false, 'types');
305
-		}
306
-
307
-		if (isset(self::$appTypes[$app])) {
308
-			return explode(',', self::$appTypes[$app]);
309
-		}
310
-
311
-		return [];
312
-	}
313
-
314
-	/**
315
-	 * read app types from info.xml and cache them in the database
316
-	 */
317
-	public static function setAppTypes(string $app) {
318
-		$appManager = \OC::$server->getAppManager();
319
-		$appData = $appManager->getAppInfo($app);
320
-		if (!is_array($appData)) {
321
-			return;
322
-		}
323
-
324
-		if (isset($appData['types'])) {
325
-			$appTypes = implode(',', $appData['types']);
326
-		} else {
327
-			$appTypes = '';
328
-			$appData['types'] = [];
329
-		}
330
-
331
-		$config = \OC::$server->getConfig();
332
-		$config->setAppValue($app, 'types', $appTypes);
333
-
334
-		if ($appManager->hasProtectedAppType($appData['types'])) {
335
-			$enabled = $config->getAppValue($app, 'enabled', 'yes');
336
-			if ($enabled !== 'yes' && $enabled !== 'no') {
337
-				$config->setAppValue($app, 'enabled', 'yes');
338
-			}
339
-		}
340
-	}
341
-
342
-	/**
343
-	 * Returns apps enabled for the current user.
344
-	 *
345
-	 * @param bool $forceRefresh whether to refresh the cache
346
-	 * @param bool $all whether to return apps for all users, not only the
347
-	 * currently logged in one
348
-	 * @return string[]
349
-	 */
350
-	public static function getEnabledApps(bool $forceRefresh = false, bool $all = false): array {
351
-		if (!\OC::$server->getSystemConfig()->getValue('installed', false)) {
352
-			return [];
353
-		}
354
-		// in incognito mode or when logged out, $user will be false,
355
-		// which is also the case during an upgrade
356
-		$appManager = \OC::$server->getAppManager();
357
-		if ($all) {
358
-			$user = null;
359
-		} else {
360
-			$user = \OC::$server->getUserSession()->getUser();
361
-		}
362
-
363
-		if (is_null($user)) {
364
-			$apps = $appManager->getInstalledApps();
365
-		} else {
366
-			$apps = $appManager->getEnabledAppsForUser($user);
367
-		}
368
-		$apps = array_filter($apps, function ($app) {
369
-			return $app !== 'files';//we add this manually
370
-		});
371
-		sort($apps);
372
-		array_unshift($apps, 'files');
373
-		return $apps;
374
-	}
375
-
376
-	/**
377
-	 * checks whether or not an app is enabled
378
-	 *
379
-	 * @param string $app app
380
-	 * @return bool
381
-	 * @deprecated 13.0.0 use \OC::$server->getAppManager()->isEnabledForUser($appId)
382
-	 *
383
-	 * This function checks whether or not an app is enabled.
384
-	 */
385
-	public static function isEnabled(string $app): bool {
386
-		return \OC::$server->getAppManager()->isEnabledForUser($app);
387
-	}
388
-
389
-	/**
390
-	 * enables an app
391
-	 *
392
-	 * @param string $appId
393
-	 * @param array $groups (optional) when set, only these groups will have access to the app
394
-	 * @throws \Exception
395
-	 * @return void
396
-	 *
397
-	 * This function set an app as enabled in appconfig.
398
-	 */
399
-	public function enable(string $appId,
400
-						   array $groups = []) {
401
-
402
-		// Check if app is already downloaded
403
-		/** @var Installer $installer */
404
-		$installer = \OC::$server->query(Installer::class);
405
-		$isDownloaded = $installer->isDownloaded($appId);
406
-
407
-		if (!$isDownloaded) {
408
-			$installer->downloadApp($appId);
409
-		}
410
-
411
-		$installer->installApp($appId);
412
-
413
-		$appManager = \OC::$server->getAppManager();
414
-		if ($groups !== []) {
415
-			$groupManager = \OC::$server->getGroupManager();
416
-			$groupsList = [];
417
-			foreach ($groups as $group) {
418
-				$groupItem = $groupManager->get($group);
419
-				if ($groupItem instanceof \OCP\IGroup) {
420
-					$groupsList[] = $groupManager->get($group);
421
-				}
422
-			}
423
-			$appManager->enableAppForGroups($appId, $groupsList);
424
-		} else {
425
-			$appManager->enableApp($appId);
426
-		}
427
-	}
428
-
429
-	/**
430
-	 * Get the path where to install apps
431
-	 *
432
-	 * @return string|false
433
-	 */
434
-	public static function getInstallPath() {
435
-		if (\OC::$server->getSystemConfig()->getValue('appstoreenabled', true) == false) {
436
-			return false;
437
-		}
438
-
439
-		foreach (OC::$APPSROOTS as $dir) {
440
-			if (isset($dir['writable']) && $dir['writable'] === true) {
441
-				return $dir['path'];
442
-			}
443
-		}
444
-
445
-		\OCP\Util::writeLog('core', 'No application directories are marked as writable.', ILogger::ERROR);
446
-		return null;
447
-	}
448
-
449
-
450
-	/**
451
-	 * search for an app in all app-directories
452
-	 *
453
-	 * @param string $appId
454
-	 * @return false|string
455
-	 */
456
-	public static function findAppInDirectories(string $appId) {
457
-		$sanitizedAppId = self::cleanAppId($appId);
458
-		if ($sanitizedAppId !== $appId) {
459
-			return false;
460
-		}
461
-		static $app_dir = [];
462
-
463
-		if (isset($app_dir[$appId])) {
464
-			return $app_dir[$appId];
465
-		}
466
-
467
-		$possibleApps = [];
468
-		foreach (OC::$APPSROOTS as $dir) {
469
-			if (file_exists($dir['path'] . '/' . $appId)) {
470
-				$possibleApps[] = $dir;
471
-			}
472
-		}
473
-
474
-		if (empty($possibleApps)) {
475
-			return false;
476
-		} elseif (count($possibleApps) === 1) {
477
-			$dir = array_shift($possibleApps);
478
-			$app_dir[$appId] = $dir;
479
-			return $dir;
480
-		} else {
481
-			$versionToLoad = [];
482
-			foreach ($possibleApps as $possibleApp) {
483
-				$version = self::getAppVersionByPath($possibleApp['path'] . '/' . $appId);
484
-				if (empty($versionToLoad) || version_compare($version, $versionToLoad['version'], '>')) {
485
-					$versionToLoad = [
486
-						'dir' => $possibleApp,
487
-						'version' => $version,
488
-					];
489
-				}
490
-			}
491
-			$app_dir[$appId] = $versionToLoad['dir'];
492
-			return $versionToLoad['dir'];
493
-			//TODO - write test
494
-		}
495
-	}
496
-
497
-	/**
498
-	 * Get the directory for the given app.
499
-	 * If the app is defined in multiple directories, the first one is taken. (false if not found)
500
-	 *
501
-	 * @param string $appId
502
-	 * @return string|false
503
-	 * @deprecated 11.0.0 use \OC::$server->getAppManager()->getAppPath()
504
-	 */
505
-	public static function getAppPath(string $appId) {
506
-		if ($appId === null || trim($appId) === '') {
507
-			return false;
508
-		}
509
-
510
-		if (($dir = self::findAppInDirectories($appId)) != false) {
511
-			return $dir['path'] . '/' . $appId;
512
-		}
513
-		return false;
514
-	}
515
-
516
-	/**
517
-	 * Get the path for the given app on the access
518
-	 * If the app is defined in multiple directories, the first one is taken. (false if not found)
519
-	 *
520
-	 * @param string $appId
521
-	 * @return string|false
522
-	 * @deprecated 18.0.0 use \OC::$server->getAppManager()->getAppWebPath()
523
-	 */
524
-	public static function getAppWebPath(string $appId) {
525
-		if (($dir = self::findAppInDirectories($appId)) != false) {
526
-			return OC::$WEBROOT . $dir['url'] . '/' . $appId;
527
-		}
528
-		return false;
529
-	}
530
-
531
-	/**
532
-	 * get the last version of the app from appinfo/info.xml
533
-	 *
534
-	 * @param string $appId
535
-	 * @param bool $useCache
536
-	 * @return string
537
-	 * @deprecated 14.0.0 use \OC::$server->getAppManager()->getAppVersion()
538
-	 */
539
-	public static function getAppVersion(string $appId, bool $useCache = true): string {
540
-		return \OC::$server->getAppManager()->getAppVersion($appId, $useCache);
541
-	}
542
-
543
-	/**
544
-	 * get app's version based on it's path
545
-	 *
546
-	 * @param string $path
547
-	 * @return string
548
-	 */
549
-	public static function getAppVersionByPath(string $path): string {
550
-		$infoFile = $path . '/appinfo/info.xml';
551
-		$appData = \OC::$server->getAppManager()->getAppInfo($infoFile, true);
552
-		return isset($appData['version']) ? $appData['version'] : '';
553
-	}
554
-
555
-
556
-	/**
557
-	 * Read all app metadata from the info.xml file
558
-	 *
559
-	 * @param string $appId id of the app or the path of the info.xml file
560
-	 * @param bool $path
561
-	 * @param string $lang
562
-	 * @return array|null
563
-	 * @note all data is read from info.xml, not just pre-defined fields
564
-	 * @deprecated 14.0.0 use \OC::$server->getAppManager()->getAppInfo()
565
-	 */
566
-	public static function getAppInfo(string $appId, bool $path = false, string $lang = null) {
567
-		return \OC::$server->getAppManager()->getAppInfo($appId, $path, $lang);
568
-	}
569
-
570
-	/**
571
-	 * Returns the navigation
572
-	 *
573
-	 * @return array
574
-	 * @deprecated 14.0.0 use \OC::$server->getNavigationManager()->getAll()
575
-	 *
576
-	 * This function returns an array containing all entries added. The
577
-	 * entries are sorted by the key 'order' ascending. Additional to the keys
578
-	 * given for each app the following keys exist:
579
-	 *   - active: boolean, signals if the user is on this navigation entry
580
-	 */
581
-	public static function getNavigation(): array {
582
-		return OC::$server->getNavigationManager()->getAll();
583
-	}
584
-
585
-	/**
586
-	 * Returns the Settings Navigation
587
-	 *
588
-	 * @return string[]
589
-	 * @deprecated 14.0.0 use \OC::$server->getNavigationManager()->getAll('settings')
590
-	 *
591
-	 * This function returns an array containing all settings pages added. The
592
-	 * entries are sorted by the key 'order' ascending.
593
-	 */
594
-	public static function getSettingsNavigation(): array {
595
-		return OC::$server->getNavigationManager()->getAll('settings');
596
-	}
597
-
598
-	/**
599
-	 * get the id of loaded app
600
-	 *
601
-	 * @return string
602
-	 */
603
-	public static function getCurrentApp(): string {
604
-		$request = \OC::$server->getRequest();
605
-		$script = substr($request->getScriptName(), strlen(OC::$WEBROOT) + 1);
606
-		$topFolder = substr($script, 0, strpos($script, '/') ?: 0);
607
-		if (empty($topFolder)) {
608
-			$path_info = $request->getPathInfo();
609
-			if ($path_info) {
610
-				$topFolder = substr($path_info, 1, strpos($path_info, '/', 1) - 1);
611
-			}
612
-		}
613
-		if ($topFolder == 'apps') {
614
-			$length = strlen($topFolder);
615
-			return substr($script, $length + 1, strpos($script, '/', $length + 1) - $length - 1) ?: '';
616
-		} else {
617
-			return $topFolder;
618
-		}
619
-	}
620
-
621
-	/**
622
-	 * @param string $type
623
-	 * @return array
624
-	 */
625
-	public static function getForms(string $type): array {
626
-		$forms = [];
627
-		switch ($type) {
628
-			case 'admin':
629
-				$source = self::$adminForms;
630
-				break;
631
-			case 'personal':
632
-				$source = self::$personalForms;
633
-				break;
634
-			default:
635
-				return [];
636
-		}
637
-		foreach ($source as $form) {
638
-			$forms[] = include $form;
639
-		}
640
-		return $forms;
641
-	}
642
-
643
-	/**
644
-	 * register an admin form to be shown
645
-	 *
646
-	 * @param string $app
647
-	 * @param string $page
648
-	 */
649
-	public static function registerAdmin(string $app, string $page) {
650
-		self::$adminForms[] = $app . '/' . $page . '.php';
651
-	}
652
-
653
-	/**
654
-	 * register a personal form to be shown
655
-	 * @param string $app
656
-	 * @param string $page
657
-	 */
658
-	public static function registerPersonal(string $app, string $page) {
659
-		self::$personalForms[] = $app . '/' . $page . '.php';
660
-	}
661
-
662
-	/**
663
-	 * @param array $entry
664
-	 */
665
-	public static function registerLogIn(array $entry) {
666
-		self::$altLogin[] = $entry;
667
-	}
668
-
669
-	/**
670
-	 * @return array
671
-	 */
672
-	public static function getAlternativeLogIns(): array {
673
-		return self::$altLogin;
674
-	}
675
-
676
-	/**
677
-	 * get a list of all apps in the apps folder
678
-	 *
679
-	 * @return string[] an array of app names (string IDs)
680
-	 * @todo: change the name of this method to getInstalledApps, which is more accurate
681
-	 */
682
-	public static function getAllApps(): array {
683
-		$apps = [];
684
-
685
-		foreach (OC::$APPSROOTS as $apps_dir) {
686
-			if (!is_readable($apps_dir['path'])) {
687
-				\OCP\Util::writeLog('core', 'unable to read app folder : ' . $apps_dir['path'], ILogger::WARN);
688
-				continue;
689
-			}
690
-			$dh = opendir($apps_dir['path']);
691
-
692
-			if (is_resource($dh)) {
693
-				while (($file = readdir($dh)) !== false) {
694
-					if ($file[0] != '.' and is_dir($apps_dir['path'] . '/' . $file) and is_file($apps_dir['path'] . '/' . $file . '/appinfo/info.xml')) {
695
-						$apps[] = $file;
696
-					}
697
-				}
698
-			}
699
-		}
700
-
701
-		$apps = array_unique($apps);
702
-
703
-		return $apps;
704
-	}
705
-
706
-	/**
707
-	 * List all apps, this is used in apps.php
708
-	 *
709
-	 * @return array
710
-	 */
711
-	public function listAllApps(): array {
712
-		$installedApps = OC_App::getAllApps();
713
-
714
-		$appManager = \OC::$server->getAppManager();
715
-		//we don't want to show configuration for these
716
-		$blacklist = $appManager->getAlwaysEnabledApps();
717
-		$appList = [];
718
-		$langCode = \OC::$server->getL10N('core')->getLanguageCode();
719
-		$urlGenerator = \OC::$server->getURLGenerator();
720
-		/** @var \OCP\Support\Subscription\IRegistry $subscriptionRegistry */
721
-		$subscriptionRegistry = \OC::$server->query(\OCP\Support\Subscription\IRegistry::class);
722
-		$supportedApps = $subscriptionRegistry->delegateGetSupportedApps();
723
-
724
-		foreach ($installedApps as $app) {
725
-			if (array_search($app, $blacklist) === false) {
726
-				$info = OC_App::getAppInfo($app, false, $langCode);
727
-				if (!is_array($info)) {
728
-					\OCP\Util::writeLog('core', 'Could not read app info file for app "' . $app . '"', ILogger::ERROR);
729
-					continue;
730
-				}
731
-
732
-				if (!isset($info['name'])) {
733
-					\OCP\Util::writeLog('core', 'App id "' . $app . '" has no name in appinfo', ILogger::ERROR);
734
-					continue;
735
-				}
736
-
737
-				$enabled = \OC::$server->getConfig()->getAppValue($app, 'enabled', 'no');
738
-				$info['groups'] = null;
739
-				if ($enabled === 'yes') {
740
-					$active = true;
741
-				} elseif ($enabled === 'no') {
742
-					$active = false;
743
-				} else {
744
-					$active = true;
745
-					$info['groups'] = $enabled;
746
-				}
747
-
748
-				$info['active'] = $active;
749
-
750
-				if ($appManager->isShipped($app)) {
751
-					$info['internal'] = true;
752
-					$info['level'] = self::officialApp;
753
-					$info['removable'] = false;
754
-				} else {
755
-					$info['internal'] = false;
756
-					$info['removable'] = true;
757
-				}
758
-
759
-				if (in_array($app, $supportedApps)) {
760
-					$info['level'] = self::supportedApp;
761
-				}
762
-
763
-				$appPath = self::getAppPath($app);
764
-				if ($appPath !== false) {
765
-					$appIcon = $appPath . '/img/' . $app . '.svg';
766
-					if (file_exists($appIcon)) {
767
-						$info['preview'] = $urlGenerator->imagePath($app, $app . '.svg');
768
-						$info['previewAsIcon'] = true;
769
-					} else {
770
-						$appIcon = $appPath . '/img/app.svg';
771
-						if (file_exists($appIcon)) {
772
-							$info['preview'] = $urlGenerator->imagePath($app, 'app.svg');
773
-							$info['previewAsIcon'] = true;
774
-						}
775
-					}
776
-				}
777
-				// fix documentation
778
-				if (isset($info['documentation']) && is_array($info['documentation'])) {
779
-					foreach ($info['documentation'] as $key => $url) {
780
-						// If it is not an absolute URL we assume it is a key
781
-						// i.e. admin-ldap will get converted to go.php?to=admin-ldap
782
-						if (stripos($url, 'https://') !== 0 && stripos($url, 'http://') !== 0) {
783
-							$url = $urlGenerator->linkToDocs($url);
784
-						}
785
-
786
-						$info['documentation'][$key] = $url;
787
-					}
788
-				}
789
-
790
-				$info['version'] = OC_App::getAppVersion($app);
791
-				$appList[] = $info;
792
-			}
793
-		}
794
-
795
-		return $appList;
796
-	}
797
-
798
-	public static function shouldUpgrade(string $app): bool {
799
-		$versions = self::getAppVersions();
800
-		$currentVersion = OC_App::getAppVersion($app);
801
-		if ($currentVersion && isset($versions[$app])) {
802
-			$installedVersion = $versions[$app];
803
-			if (!version_compare($currentVersion, $installedVersion, '=')) {
804
-				return true;
805
-			}
806
-		}
807
-		return false;
808
-	}
809
-
810
-	/**
811
-	 * Adjust the number of version parts of $version1 to match
812
-	 * the number of version parts of $version2.
813
-	 *
814
-	 * @param string $version1 version to adjust
815
-	 * @param string $version2 version to take the number of parts from
816
-	 * @return string shortened $version1
817
-	 */
818
-	private static function adjustVersionParts(string $version1, string $version2): string {
819
-		$version1 = explode('.', $version1);
820
-		$version2 = explode('.', $version2);
821
-		// reduce $version1 to match the number of parts in $version2
822
-		while (count($version1) > count($version2)) {
823
-			array_pop($version1);
824
-		}
825
-		// if $version1 does not have enough parts, add some
826
-		while (count($version1) < count($version2)) {
827
-			$version1[] = '0';
828
-		}
829
-		return implode('.', $version1);
830
-	}
831
-
832
-	/**
833
-	 * Check whether the current ownCloud version matches the given
834
-	 * application's version requirements.
835
-	 *
836
-	 * The comparison is made based on the number of parts that the
837
-	 * app info version has. For example for ownCloud 6.0.3 if the
838
-	 * app info version is expecting version 6.0, the comparison is
839
-	 * made on the first two parts of the ownCloud version.
840
-	 * This means that it's possible to specify "requiremin" => 6
841
-	 * and "requiremax" => 6 and it will still match ownCloud 6.0.3.
842
-	 *
843
-	 * @param string $ocVersion ownCloud version to check against
844
-	 * @param array $appInfo app info (from xml)
845
-	 *
846
-	 * @return boolean true if compatible, otherwise false
847
-	 */
848
-	public static function isAppCompatible(string $ocVersion, array $appInfo, bool $ignoreMax = false): bool {
849
-		$requireMin = '';
850
-		$requireMax = '';
851
-		if (isset($appInfo['dependencies']['nextcloud']['@attributes']['min-version'])) {
852
-			$requireMin = $appInfo['dependencies']['nextcloud']['@attributes']['min-version'];
853
-		} elseif (isset($appInfo['dependencies']['owncloud']['@attributes']['min-version'])) {
854
-			$requireMin = $appInfo['dependencies']['owncloud']['@attributes']['min-version'];
855
-		} elseif (isset($appInfo['requiremin'])) {
856
-			$requireMin = $appInfo['requiremin'];
857
-		} elseif (isset($appInfo['require'])) {
858
-			$requireMin = $appInfo['require'];
859
-		}
860
-
861
-		if (isset($appInfo['dependencies']['nextcloud']['@attributes']['max-version'])) {
862
-			$requireMax = $appInfo['dependencies']['nextcloud']['@attributes']['max-version'];
863
-		} elseif (isset($appInfo['dependencies']['owncloud']['@attributes']['max-version'])) {
864
-			$requireMax = $appInfo['dependencies']['owncloud']['@attributes']['max-version'];
865
-		} elseif (isset($appInfo['requiremax'])) {
866
-			$requireMax = $appInfo['requiremax'];
867
-		}
868
-
869
-		if (!empty($requireMin)
870
-			&& version_compare(self::adjustVersionParts($ocVersion, $requireMin), $requireMin, '<')
871
-		) {
872
-			return false;
873
-		}
874
-
875
-		if (!$ignoreMax && !empty($requireMax)
876
-			&& version_compare(self::adjustVersionParts($ocVersion, $requireMax), $requireMax, '>')
877
-		) {
878
-			return false;
879
-		}
880
-
881
-		return true;
882
-	}
883
-
884
-	/**
885
-	 * get the installed version of all apps
886
-	 */
887
-	public static function getAppVersions() {
888
-		static $versions;
889
-
890
-		if (!$versions) {
891
-			$appConfig = \OC::$server->getAppConfig();
892
-			$versions = $appConfig->getValues(false, 'installed_version');
893
-		}
894
-		return $versions;
895
-	}
896
-
897
-	/**
898
-	 * update the database for the app and call the update script
899
-	 *
900
-	 * @param string $appId
901
-	 * @return bool
902
-	 */
903
-	public static function updateApp(string $appId): bool {
904
-		$appPath = self::getAppPath($appId);
905
-		if ($appPath === false) {
906
-			return false;
907
-		}
908
-
909
-		\OC::$server->getAppManager()->clearAppsCache();
910
-		$appData = self::getAppInfo($appId);
911
-
912
-		self::registerAutoloading($appId, $appPath, true);
913
-		self::executeRepairSteps($appId, $appData['repair-steps']['pre-migration']);
914
-
915
-		if (file_exists($appPath . '/appinfo/database.xml')) {
916
-			OC_DB::updateDbFromStructure($appPath . '/appinfo/database.xml');
917
-		} else {
918
-			$ms = new MigrationService($appId, \OC::$server->getDatabaseConnection());
919
-			$ms->migrate();
920
-		}
921
-
922
-		self::executeRepairSteps($appId, $appData['repair-steps']['post-migration']);
923
-		self::setupLiveMigrations($appId, $appData['repair-steps']['live-migration']);
924
-		// update appversion in app manager
925
-		\OC::$server->getAppManager()->clearAppsCache();
926
-		\OC::$server->getAppManager()->getAppVersion($appId, false);
927
-
928
-		// run upgrade code
929
-		if (file_exists($appPath . '/appinfo/update.php')) {
930
-			self::loadApp($appId);
931
-			include $appPath . '/appinfo/update.php';
932
-		}
933
-		self::setupBackgroundJobs($appData['background-jobs']);
934
-
935
-		//set remote/public handlers
936
-		if (array_key_exists('ocsid', $appData)) {
937
-			\OC::$server->getConfig()->setAppValue($appId, 'ocsid', $appData['ocsid']);
938
-		} elseif (\OC::$server->getConfig()->getAppValue($appId, 'ocsid', null) !== null) {
939
-			\OC::$server->getConfig()->deleteAppValue($appId, 'ocsid');
940
-		}
941
-		foreach ($appData['remote'] as $name => $path) {
942
-			\OC::$server->getConfig()->setAppValue('core', 'remote_' . $name, $appId . '/' . $path);
943
-		}
944
-		foreach ($appData['public'] as $name => $path) {
945
-			\OC::$server->getConfig()->setAppValue('core', 'public_' . $name, $appId . '/' . $path);
946
-		}
947
-
948
-		self::setAppTypes($appId);
949
-
950
-		$version = \OC_App::getAppVersion($appId);
951
-		\OC::$server->getConfig()->setAppValue($appId, 'installed_version', $version);
952
-
953
-		\OC::$server->getEventDispatcher()->dispatch(ManagerEvent::EVENT_APP_UPDATE, new ManagerEvent(
954
-			ManagerEvent::EVENT_APP_UPDATE, $appId
955
-		));
956
-
957
-		return true;
958
-	}
959
-
960
-	/**
961
-	 * @param string $appId
962
-	 * @param string[] $steps
963
-	 * @throws \OC\NeedsUpdateException
964
-	 */
965
-	public static function executeRepairSteps(string $appId, array $steps) {
966
-		if (empty($steps)) {
967
-			return;
968
-		}
969
-		// load the app
970
-		self::loadApp($appId);
971
-
972
-		$dispatcher = OC::$server->getEventDispatcher();
973
-
974
-		// load the steps
975
-		$r = new Repair([], $dispatcher);
976
-		foreach ($steps as $step) {
977
-			try {
978
-				$r->addStep($step);
979
-			} catch (Exception $ex) {
980
-				$r->emit('\OC\Repair', 'error', [$ex->getMessage()]);
981
-				\OC::$server->getLogger()->logException($ex);
982
-			}
983
-		}
984
-		// run the steps
985
-		$r->run();
986
-	}
987
-
988
-	public static function setupBackgroundJobs(array $jobs) {
989
-		$queue = \OC::$server->getJobList();
990
-		foreach ($jobs as $job) {
991
-			$queue->add($job);
992
-		}
993
-	}
994
-
995
-	/**
996
-	 * @param string $appId
997
-	 * @param string[] $steps
998
-	 */
999
-	private static function setupLiveMigrations(string $appId, array $steps) {
1000
-		$queue = \OC::$server->getJobList();
1001
-		foreach ($steps as $step) {
1002
-			$queue->add('OC\Migration\BackgroundRepair', [
1003
-				'app' => $appId,
1004
-				'step' => $step]);
1005
-		}
1006
-	}
1007
-
1008
-	/**
1009
-	 * @param string $appId
1010
-	 * @return \OC\Files\View|false
1011
-	 */
1012
-	public static function getStorage(string $appId) {
1013
-		if (\OC::$server->getAppManager()->isEnabledForUser($appId)) { //sanity check
1014
-			if (\OC::$server->getUserSession()->isLoggedIn()) {
1015
-				$view = new \OC\Files\View('/' . OC_User::getUser());
1016
-				if (!$view->file_exists($appId)) {
1017
-					$view->mkdir($appId);
1018
-				}
1019
-				return new \OC\Files\View('/' . OC_User::getUser() . '/' . $appId);
1020
-			} else {
1021
-				\OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ', user not logged in', ILogger::ERROR);
1022
-				return false;
1023
-			}
1024
-		} else {
1025
-			\OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ' not enabled', ILogger::ERROR);
1026
-			return false;
1027
-		}
1028
-	}
1029
-
1030
-	protected static function findBestL10NOption(array $options, string $lang): string {
1031
-		// only a single option
1032
-		if (isset($options['@value'])) {
1033
-			return $options['@value'];
1034
-		}
1035
-
1036
-		$fallback = $similarLangFallback = $englishFallback = false;
1037
-
1038
-		$lang = strtolower($lang);
1039
-		$similarLang = $lang;
1040
-		if (strpos($similarLang, '_')) {
1041
-			// For "de_DE" we want to find "de" and the other way around
1042
-			$similarLang = substr($lang, 0, strpos($lang, '_'));
1043
-		}
1044
-
1045
-		foreach ($options as $option) {
1046
-			if (is_array($option)) {
1047
-				if ($fallback === false) {
1048
-					$fallback = $option['@value'];
1049
-				}
1050
-
1051
-				if (!isset($option['@attributes']['lang'])) {
1052
-					continue;
1053
-				}
1054
-
1055
-				$attributeLang = strtolower($option['@attributes']['lang']);
1056
-				if ($attributeLang === $lang) {
1057
-					return $option['@value'];
1058
-				}
1059
-
1060
-				if ($attributeLang === $similarLang) {
1061
-					$similarLangFallback = $option['@value'];
1062
-				} elseif (strpos($attributeLang, $similarLang . '_') === 0) {
1063
-					if ($similarLangFallback === false) {
1064
-						$similarLangFallback =  $option['@value'];
1065
-					}
1066
-				}
1067
-			} else {
1068
-				$englishFallback = $option;
1069
-			}
1070
-		}
1071
-
1072
-		if ($similarLangFallback !== false) {
1073
-			return $similarLangFallback;
1074
-		} elseif ($englishFallback !== false) {
1075
-			return $englishFallback;
1076
-		}
1077
-		return (string) $fallback;
1078
-	}
1079
-
1080
-	/**
1081
-	 * parses the app data array and enhanced the 'description' value
1082
-	 *
1083
-	 * @param array $data the app data
1084
-	 * @param string $lang
1085
-	 * @return array improved app data
1086
-	 */
1087
-	public static function parseAppInfo(array $data, $lang = null): array {
1088
-		if ($lang && isset($data['name']) && is_array($data['name'])) {
1089
-			$data['name'] = self::findBestL10NOption($data['name'], $lang);
1090
-		}
1091
-		if ($lang && isset($data['summary']) && is_array($data['summary'])) {
1092
-			$data['summary'] = self::findBestL10NOption($data['summary'], $lang);
1093
-		}
1094
-		if ($lang && isset($data['description']) && is_array($data['description'])) {
1095
-			$data['description'] = trim(self::findBestL10NOption($data['description'], $lang));
1096
-		} elseif (isset($data['description']) && is_string($data['description'])) {
1097
-			$data['description'] = trim($data['description']);
1098
-		} else {
1099
-			$data['description'] = '';
1100
-		}
1101
-
1102
-		return $data;
1103
-	}
1104
-
1105
-	/**
1106
-	 * @param \OCP\IConfig $config
1107
-	 * @param \OCP\IL10N $l
1108
-	 * @param array $info
1109
-	 * @throws \Exception
1110
-	 */
1111
-	public static function checkAppDependencies(\OCP\IConfig $config, \OCP\IL10N $l, array $info, bool $ignoreMax) {
1112
-		$dependencyAnalyzer = new DependencyAnalyzer(new Platform($config), $l);
1113
-		$missing = $dependencyAnalyzer->analyze($info, $ignoreMax);
1114
-		if (!empty($missing)) {
1115
-			$missingMsg = implode(PHP_EOL, $missing);
1116
-			throw new \Exception(
1117
-				$l->t('App "%1$s" cannot be installed because the following dependencies are not fulfilled: %2$s',
1118
-					[$info['name'], $missingMsg]
1119
-				)
1120
-			);
1121
-		}
1122
-	}
68
+    private static $adminForms = [];
69
+    private static $personalForms = [];
70
+    private static $appTypes = [];
71
+    private static $loadedApps = [];
72
+    private static $altLogin = [];
73
+    private static $alreadyRegistered = [];
74
+    public const supportedApp = 300;
75
+    public const officialApp = 200;
76
+
77
+    /**
78
+     * clean the appId
79
+     *
80
+     * @param string $app AppId that needs to be cleaned
81
+     * @return string
82
+     */
83
+    public static function cleanAppId(string $app): string {
84
+        return str_replace(['\0', '/', '\\', '..'], '', $app);
85
+    }
86
+
87
+    /**
88
+     * Check if an app is loaded
89
+     *
90
+     * @param string $app
91
+     * @return bool
92
+     */
93
+    public static function isAppLoaded(string $app): bool {
94
+        return in_array($app, self::$loadedApps, true);
95
+    }
96
+
97
+    /**
98
+     * loads all apps
99
+     *
100
+     * @param string[] $types
101
+     * @return bool
102
+     *
103
+     * This function walks through the ownCloud directory and loads all apps
104
+     * it can find. A directory contains an app if the file /appinfo/info.xml
105
+     * exists.
106
+     *
107
+     * if $types is set to non-empty array, only apps of those types will be loaded
108
+     */
109
+    public static function loadApps(array $types = []): bool {
110
+        if ((bool) \OC::$server->getSystemConfig()->getValue('maintenance', false)) {
111
+            return false;
112
+        }
113
+        // Load the enabled apps here
114
+        $apps = self::getEnabledApps();
115
+
116
+        // Add each apps' folder as allowed class path
117
+        foreach ($apps as $app) {
118
+            $path = self::getAppPath($app);
119
+            if ($path !== false) {
120
+                self::registerAutoloading($app, $path);
121
+            }
122
+        }
123
+
124
+        // prevent app.php from printing output
125
+        ob_start();
126
+        foreach ($apps as $app) {
127
+            if (($types === [] or self::isType($app, $types)) && !in_array($app, self::$loadedApps)) {
128
+                self::loadApp($app);
129
+            }
130
+        }
131
+        ob_end_clean();
132
+
133
+        return true;
134
+    }
135
+
136
+    /**
137
+     * load a single app
138
+     *
139
+     * @param string $app
140
+     * @throws Exception
141
+     */
142
+    public static function loadApp(string $app) {
143
+        self::$loadedApps[] = $app;
144
+        $appPath = self::getAppPath($app);
145
+        if ($appPath === false) {
146
+            return;
147
+        }
148
+
149
+        // in case someone calls loadApp() directly
150
+        self::registerAutoloading($app, $appPath);
151
+
152
+        /** @var \OC\AppFramework\Bootstrap\Coordinator $coordinator */
153
+        $coordinator = \OC::$server->query(\OC\AppFramework\Bootstrap\Coordinator::class);
154
+        $coordinator->bootApp($app);
155
+        if (is_file($appPath . '/appinfo/app.php')) {
156
+            \OC::$server->getEventLogger()->start('load_app_' . $app, 'Load app: ' . $app);
157
+            try {
158
+                self::requireAppFile($app);
159
+            } catch (Throwable $ex) {
160
+                if ($ex instanceof ServerNotAvailableException) {
161
+                    throw $ex;
162
+                }
163
+                if (!\OC::$server->getAppManager()->isShipped($app) && !self::isType($app, ['authentication'])) {
164
+                    \OC::$server->getLogger()->logException($ex, [
165
+                        'message' => "App $app threw an error during app.php load and will be disabled: " . $ex->getMessage(),
166
+                    ]);
167
+
168
+                    // Only disable apps which are not shipped and that are not authentication apps
169
+                    \OC::$server->getAppManager()->disableApp($app, true);
170
+                } else {
171
+                    \OC::$server->getLogger()->logException($ex, [
172
+                        'message' => "App $app threw an error during app.php load: " . $ex->getMessage(),
173
+                    ]);
174
+                }
175
+            }
176
+            \OC::$server->getEventLogger()->end('load_app_' . $app);
177
+        }
178
+
179
+        $info = self::getAppInfo($app);
180
+        if (!empty($info['activity']['filters'])) {
181
+            foreach ($info['activity']['filters'] as $filter) {
182
+                \OC::$server->getActivityManager()->registerFilter($filter);
183
+            }
184
+        }
185
+        if (!empty($info['activity']['settings'])) {
186
+            foreach ($info['activity']['settings'] as $setting) {
187
+                \OC::$server->getActivityManager()->registerSetting($setting);
188
+            }
189
+        }
190
+        if (!empty($info['activity']['providers'])) {
191
+            foreach ($info['activity']['providers'] as $provider) {
192
+                \OC::$server->getActivityManager()->registerProvider($provider);
193
+            }
194
+        }
195
+
196
+        if (!empty($info['settings']['admin'])) {
197
+            foreach ($info['settings']['admin'] as $setting) {
198
+                \OC::$server->getSettingsManager()->registerSetting('admin', $setting);
199
+            }
200
+        }
201
+        if (!empty($info['settings']['admin-section'])) {
202
+            foreach ($info['settings']['admin-section'] as $section) {
203
+                \OC::$server->getSettingsManager()->registerSection('admin', $section);
204
+            }
205
+        }
206
+        if (!empty($info['settings']['personal'])) {
207
+            foreach ($info['settings']['personal'] as $setting) {
208
+                \OC::$server->getSettingsManager()->registerSetting('personal', $setting);
209
+            }
210
+        }
211
+        if (!empty($info['settings']['personal-section'])) {
212
+            foreach ($info['settings']['personal-section'] as $section) {
213
+                \OC::$server->getSettingsManager()->registerSection('personal', $section);
214
+            }
215
+        }
216
+
217
+        if (!empty($info['collaboration']['plugins'])) {
218
+            // deal with one or many plugin entries
219
+            $plugins = isset($info['collaboration']['plugins']['plugin']['@value']) ?
220
+                [$info['collaboration']['plugins']['plugin']] : $info['collaboration']['plugins']['plugin'];
221
+            foreach ($plugins as $plugin) {
222
+                if ($plugin['@attributes']['type'] === 'collaborator-search') {
223
+                    $pluginInfo = [
224
+                        'shareType' => $plugin['@attributes']['share-type'],
225
+                        'class' => $plugin['@value'],
226
+                    ];
227
+                    \OC::$server->getCollaboratorSearch()->registerPlugin($pluginInfo);
228
+                } elseif ($plugin['@attributes']['type'] === 'autocomplete-sort') {
229
+                    \OC::$server->getAutoCompleteManager()->registerSorter($plugin['@value']);
230
+                }
231
+            }
232
+        }
233
+    }
234
+
235
+    /**
236
+     * @internal
237
+     * @param string $app
238
+     * @param string $path
239
+     * @param bool $force
240
+     */
241
+    public static function registerAutoloading(string $app, string $path, bool $force = false) {
242
+        $key = $app . '-' . $path;
243
+        if (!$force && isset(self::$alreadyRegistered[$key])) {
244
+            return;
245
+        }
246
+
247
+        self::$alreadyRegistered[$key] = true;
248
+
249
+        // Register on PSR-4 composer autoloader
250
+        $appNamespace = \OC\AppFramework\App::buildAppNamespace($app);
251
+        \OC::$server->registerNamespace($app, $appNamespace);
252
+
253
+        if (file_exists($path . '/composer/autoload.php')) {
254
+            require_once $path . '/composer/autoload.php';
255
+        } else {
256
+            \OC::$composerAutoloader->addPsr4($appNamespace . '\\', $path . '/lib/', true);
257
+            // Register on legacy autoloader
258
+            \OC::$loader->addValidRoot($path);
259
+        }
260
+
261
+        // Register Test namespace only when testing
262
+        if (defined('PHPUNIT_RUN') || defined('CLI_TEST_RUN')) {
263
+            \OC::$composerAutoloader->addPsr4($appNamespace . '\\Tests\\', $path . '/tests/', true);
264
+        }
265
+    }
266
+
267
+    /**
268
+     * Load app.php from the given app
269
+     *
270
+     * @param string $app app name
271
+     * @throws Error
272
+     */
273
+    private static function requireAppFile(string $app) {
274
+        // encapsulated here to avoid variable scope conflicts
275
+        require_once $app . '/appinfo/app.php';
276
+    }
277
+
278
+    /**
279
+     * check if an app is of a specific type
280
+     *
281
+     * @param string $app
282
+     * @param array $types
283
+     * @return bool
284
+     */
285
+    public static function isType(string $app, array $types): bool {
286
+        $appTypes = self::getAppTypes($app);
287
+        foreach ($types as $type) {
288
+            if (array_search($type, $appTypes) !== false) {
289
+                return true;
290
+            }
291
+        }
292
+        return false;
293
+    }
294
+
295
+    /**
296
+     * get the types of an app
297
+     *
298
+     * @param string $app
299
+     * @return array
300
+     */
301
+    private static function getAppTypes(string $app): array {
302
+        //load the cache
303
+        if (count(self::$appTypes) == 0) {
304
+            self::$appTypes = \OC::$server->getAppConfig()->getValues(false, 'types');
305
+        }
306
+
307
+        if (isset(self::$appTypes[$app])) {
308
+            return explode(',', self::$appTypes[$app]);
309
+        }
310
+
311
+        return [];
312
+    }
313
+
314
+    /**
315
+     * read app types from info.xml and cache them in the database
316
+     */
317
+    public static function setAppTypes(string $app) {
318
+        $appManager = \OC::$server->getAppManager();
319
+        $appData = $appManager->getAppInfo($app);
320
+        if (!is_array($appData)) {
321
+            return;
322
+        }
323
+
324
+        if (isset($appData['types'])) {
325
+            $appTypes = implode(',', $appData['types']);
326
+        } else {
327
+            $appTypes = '';
328
+            $appData['types'] = [];
329
+        }
330
+
331
+        $config = \OC::$server->getConfig();
332
+        $config->setAppValue($app, 'types', $appTypes);
333
+
334
+        if ($appManager->hasProtectedAppType($appData['types'])) {
335
+            $enabled = $config->getAppValue($app, 'enabled', 'yes');
336
+            if ($enabled !== 'yes' && $enabled !== 'no') {
337
+                $config->setAppValue($app, 'enabled', 'yes');
338
+            }
339
+        }
340
+    }
341
+
342
+    /**
343
+     * Returns apps enabled for the current user.
344
+     *
345
+     * @param bool $forceRefresh whether to refresh the cache
346
+     * @param bool $all whether to return apps for all users, not only the
347
+     * currently logged in one
348
+     * @return string[]
349
+     */
350
+    public static function getEnabledApps(bool $forceRefresh = false, bool $all = false): array {
351
+        if (!\OC::$server->getSystemConfig()->getValue('installed', false)) {
352
+            return [];
353
+        }
354
+        // in incognito mode or when logged out, $user will be false,
355
+        // which is also the case during an upgrade
356
+        $appManager = \OC::$server->getAppManager();
357
+        if ($all) {
358
+            $user = null;
359
+        } else {
360
+            $user = \OC::$server->getUserSession()->getUser();
361
+        }
362
+
363
+        if (is_null($user)) {
364
+            $apps = $appManager->getInstalledApps();
365
+        } else {
366
+            $apps = $appManager->getEnabledAppsForUser($user);
367
+        }
368
+        $apps = array_filter($apps, function ($app) {
369
+            return $app !== 'files';//we add this manually
370
+        });
371
+        sort($apps);
372
+        array_unshift($apps, 'files');
373
+        return $apps;
374
+    }
375
+
376
+    /**
377
+     * checks whether or not an app is enabled
378
+     *
379
+     * @param string $app app
380
+     * @return bool
381
+     * @deprecated 13.0.0 use \OC::$server->getAppManager()->isEnabledForUser($appId)
382
+     *
383
+     * This function checks whether or not an app is enabled.
384
+     */
385
+    public static function isEnabled(string $app): bool {
386
+        return \OC::$server->getAppManager()->isEnabledForUser($app);
387
+    }
388
+
389
+    /**
390
+     * enables an app
391
+     *
392
+     * @param string $appId
393
+     * @param array $groups (optional) when set, only these groups will have access to the app
394
+     * @throws \Exception
395
+     * @return void
396
+     *
397
+     * This function set an app as enabled in appconfig.
398
+     */
399
+    public function enable(string $appId,
400
+                            array $groups = []) {
401
+
402
+        // Check if app is already downloaded
403
+        /** @var Installer $installer */
404
+        $installer = \OC::$server->query(Installer::class);
405
+        $isDownloaded = $installer->isDownloaded($appId);
406
+
407
+        if (!$isDownloaded) {
408
+            $installer->downloadApp($appId);
409
+        }
410
+
411
+        $installer->installApp($appId);
412
+
413
+        $appManager = \OC::$server->getAppManager();
414
+        if ($groups !== []) {
415
+            $groupManager = \OC::$server->getGroupManager();
416
+            $groupsList = [];
417
+            foreach ($groups as $group) {
418
+                $groupItem = $groupManager->get($group);
419
+                if ($groupItem instanceof \OCP\IGroup) {
420
+                    $groupsList[] = $groupManager->get($group);
421
+                }
422
+            }
423
+            $appManager->enableAppForGroups($appId, $groupsList);
424
+        } else {
425
+            $appManager->enableApp($appId);
426
+        }
427
+    }
428
+
429
+    /**
430
+     * Get the path where to install apps
431
+     *
432
+     * @return string|false
433
+     */
434
+    public static function getInstallPath() {
435
+        if (\OC::$server->getSystemConfig()->getValue('appstoreenabled', true) == false) {
436
+            return false;
437
+        }
438
+
439
+        foreach (OC::$APPSROOTS as $dir) {
440
+            if (isset($dir['writable']) && $dir['writable'] === true) {
441
+                return $dir['path'];
442
+            }
443
+        }
444
+
445
+        \OCP\Util::writeLog('core', 'No application directories are marked as writable.', ILogger::ERROR);
446
+        return null;
447
+    }
448
+
449
+
450
+    /**
451
+     * search for an app in all app-directories
452
+     *
453
+     * @param string $appId
454
+     * @return false|string
455
+     */
456
+    public static function findAppInDirectories(string $appId) {
457
+        $sanitizedAppId = self::cleanAppId($appId);
458
+        if ($sanitizedAppId !== $appId) {
459
+            return false;
460
+        }
461
+        static $app_dir = [];
462
+
463
+        if (isset($app_dir[$appId])) {
464
+            return $app_dir[$appId];
465
+        }
466
+
467
+        $possibleApps = [];
468
+        foreach (OC::$APPSROOTS as $dir) {
469
+            if (file_exists($dir['path'] . '/' . $appId)) {
470
+                $possibleApps[] = $dir;
471
+            }
472
+        }
473
+
474
+        if (empty($possibleApps)) {
475
+            return false;
476
+        } elseif (count($possibleApps) === 1) {
477
+            $dir = array_shift($possibleApps);
478
+            $app_dir[$appId] = $dir;
479
+            return $dir;
480
+        } else {
481
+            $versionToLoad = [];
482
+            foreach ($possibleApps as $possibleApp) {
483
+                $version = self::getAppVersionByPath($possibleApp['path'] . '/' . $appId);
484
+                if (empty($versionToLoad) || version_compare($version, $versionToLoad['version'], '>')) {
485
+                    $versionToLoad = [
486
+                        'dir' => $possibleApp,
487
+                        'version' => $version,
488
+                    ];
489
+                }
490
+            }
491
+            $app_dir[$appId] = $versionToLoad['dir'];
492
+            return $versionToLoad['dir'];
493
+            //TODO - write test
494
+        }
495
+    }
496
+
497
+    /**
498
+     * Get the directory for the given app.
499
+     * If the app is defined in multiple directories, the first one is taken. (false if not found)
500
+     *
501
+     * @param string $appId
502
+     * @return string|false
503
+     * @deprecated 11.0.0 use \OC::$server->getAppManager()->getAppPath()
504
+     */
505
+    public static function getAppPath(string $appId) {
506
+        if ($appId === null || trim($appId) === '') {
507
+            return false;
508
+        }
509
+
510
+        if (($dir = self::findAppInDirectories($appId)) != false) {
511
+            return $dir['path'] . '/' . $appId;
512
+        }
513
+        return false;
514
+    }
515
+
516
+    /**
517
+     * Get the path for the given app on the access
518
+     * If the app is defined in multiple directories, the first one is taken. (false if not found)
519
+     *
520
+     * @param string $appId
521
+     * @return string|false
522
+     * @deprecated 18.0.0 use \OC::$server->getAppManager()->getAppWebPath()
523
+     */
524
+    public static function getAppWebPath(string $appId) {
525
+        if (($dir = self::findAppInDirectories($appId)) != false) {
526
+            return OC::$WEBROOT . $dir['url'] . '/' . $appId;
527
+        }
528
+        return false;
529
+    }
530
+
531
+    /**
532
+     * get the last version of the app from appinfo/info.xml
533
+     *
534
+     * @param string $appId
535
+     * @param bool $useCache
536
+     * @return string
537
+     * @deprecated 14.0.0 use \OC::$server->getAppManager()->getAppVersion()
538
+     */
539
+    public static function getAppVersion(string $appId, bool $useCache = true): string {
540
+        return \OC::$server->getAppManager()->getAppVersion($appId, $useCache);
541
+    }
542
+
543
+    /**
544
+     * get app's version based on it's path
545
+     *
546
+     * @param string $path
547
+     * @return string
548
+     */
549
+    public static function getAppVersionByPath(string $path): string {
550
+        $infoFile = $path . '/appinfo/info.xml';
551
+        $appData = \OC::$server->getAppManager()->getAppInfo($infoFile, true);
552
+        return isset($appData['version']) ? $appData['version'] : '';
553
+    }
554
+
555
+
556
+    /**
557
+     * Read all app metadata from the info.xml file
558
+     *
559
+     * @param string $appId id of the app or the path of the info.xml file
560
+     * @param bool $path
561
+     * @param string $lang
562
+     * @return array|null
563
+     * @note all data is read from info.xml, not just pre-defined fields
564
+     * @deprecated 14.0.0 use \OC::$server->getAppManager()->getAppInfo()
565
+     */
566
+    public static function getAppInfo(string $appId, bool $path = false, string $lang = null) {
567
+        return \OC::$server->getAppManager()->getAppInfo($appId, $path, $lang);
568
+    }
569
+
570
+    /**
571
+     * Returns the navigation
572
+     *
573
+     * @return array
574
+     * @deprecated 14.0.0 use \OC::$server->getNavigationManager()->getAll()
575
+     *
576
+     * This function returns an array containing all entries added. The
577
+     * entries are sorted by the key 'order' ascending. Additional to the keys
578
+     * given for each app the following keys exist:
579
+     *   - active: boolean, signals if the user is on this navigation entry
580
+     */
581
+    public static function getNavigation(): array {
582
+        return OC::$server->getNavigationManager()->getAll();
583
+    }
584
+
585
+    /**
586
+     * Returns the Settings Navigation
587
+     *
588
+     * @return string[]
589
+     * @deprecated 14.0.0 use \OC::$server->getNavigationManager()->getAll('settings')
590
+     *
591
+     * This function returns an array containing all settings pages added. The
592
+     * entries are sorted by the key 'order' ascending.
593
+     */
594
+    public static function getSettingsNavigation(): array {
595
+        return OC::$server->getNavigationManager()->getAll('settings');
596
+    }
597
+
598
+    /**
599
+     * get the id of loaded app
600
+     *
601
+     * @return string
602
+     */
603
+    public static function getCurrentApp(): string {
604
+        $request = \OC::$server->getRequest();
605
+        $script = substr($request->getScriptName(), strlen(OC::$WEBROOT) + 1);
606
+        $topFolder = substr($script, 0, strpos($script, '/') ?: 0);
607
+        if (empty($topFolder)) {
608
+            $path_info = $request->getPathInfo();
609
+            if ($path_info) {
610
+                $topFolder = substr($path_info, 1, strpos($path_info, '/', 1) - 1);
611
+            }
612
+        }
613
+        if ($topFolder == 'apps') {
614
+            $length = strlen($topFolder);
615
+            return substr($script, $length + 1, strpos($script, '/', $length + 1) - $length - 1) ?: '';
616
+        } else {
617
+            return $topFolder;
618
+        }
619
+    }
620
+
621
+    /**
622
+     * @param string $type
623
+     * @return array
624
+     */
625
+    public static function getForms(string $type): array {
626
+        $forms = [];
627
+        switch ($type) {
628
+            case 'admin':
629
+                $source = self::$adminForms;
630
+                break;
631
+            case 'personal':
632
+                $source = self::$personalForms;
633
+                break;
634
+            default:
635
+                return [];
636
+        }
637
+        foreach ($source as $form) {
638
+            $forms[] = include $form;
639
+        }
640
+        return $forms;
641
+    }
642
+
643
+    /**
644
+     * register an admin form to be shown
645
+     *
646
+     * @param string $app
647
+     * @param string $page
648
+     */
649
+    public static function registerAdmin(string $app, string $page) {
650
+        self::$adminForms[] = $app . '/' . $page . '.php';
651
+    }
652
+
653
+    /**
654
+     * register a personal form to be shown
655
+     * @param string $app
656
+     * @param string $page
657
+     */
658
+    public static function registerPersonal(string $app, string $page) {
659
+        self::$personalForms[] = $app . '/' . $page . '.php';
660
+    }
661
+
662
+    /**
663
+     * @param array $entry
664
+     */
665
+    public static function registerLogIn(array $entry) {
666
+        self::$altLogin[] = $entry;
667
+    }
668
+
669
+    /**
670
+     * @return array
671
+     */
672
+    public static function getAlternativeLogIns(): array {
673
+        return self::$altLogin;
674
+    }
675
+
676
+    /**
677
+     * get a list of all apps in the apps folder
678
+     *
679
+     * @return string[] an array of app names (string IDs)
680
+     * @todo: change the name of this method to getInstalledApps, which is more accurate
681
+     */
682
+    public static function getAllApps(): array {
683
+        $apps = [];
684
+
685
+        foreach (OC::$APPSROOTS as $apps_dir) {
686
+            if (!is_readable($apps_dir['path'])) {
687
+                \OCP\Util::writeLog('core', 'unable to read app folder : ' . $apps_dir['path'], ILogger::WARN);
688
+                continue;
689
+            }
690
+            $dh = opendir($apps_dir['path']);
691
+
692
+            if (is_resource($dh)) {
693
+                while (($file = readdir($dh)) !== false) {
694
+                    if ($file[0] != '.' and is_dir($apps_dir['path'] . '/' . $file) and is_file($apps_dir['path'] . '/' . $file . '/appinfo/info.xml')) {
695
+                        $apps[] = $file;
696
+                    }
697
+                }
698
+            }
699
+        }
700
+
701
+        $apps = array_unique($apps);
702
+
703
+        return $apps;
704
+    }
705
+
706
+    /**
707
+     * List all apps, this is used in apps.php
708
+     *
709
+     * @return array
710
+     */
711
+    public function listAllApps(): array {
712
+        $installedApps = OC_App::getAllApps();
713
+
714
+        $appManager = \OC::$server->getAppManager();
715
+        //we don't want to show configuration for these
716
+        $blacklist = $appManager->getAlwaysEnabledApps();
717
+        $appList = [];
718
+        $langCode = \OC::$server->getL10N('core')->getLanguageCode();
719
+        $urlGenerator = \OC::$server->getURLGenerator();
720
+        /** @var \OCP\Support\Subscription\IRegistry $subscriptionRegistry */
721
+        $subscriptionRegistry = \OC::$server->query(\OCP\Support\Subscription\IRegistry::class);
722
+        $supportedApps = $subscriptionRegistry->delegateGetSupportedApps();
723
+
724
+        foreach ($installedApps as $app) {
725
+            if (array_search($app, $blacklist) === false) {
726
+                $info = OC_App::getAppInfo($app, false, $langCode);
727
+                if (!is_array($info)) {
728
+                    \OCP\Util::writeLog('core', 'Could not read app info file for app "' . $app . '"', ILogger::ERROR);
729
+                    continue;
730
+                }
731
+
732
+                if (!isset($info['name'])) {
733
+                    \OCP\Util::writeLog('core', 'App id "' . $app . '" has no name in appinfo', ILogger::ERROR);
734
+                    continue;
735
+                }
736
+
737
+                $enabled = \OC::$server->getConfig()->getAppValue($app, 'enabled', 'no');
738
+                $info['groups'] = null;
739
+                if ($enabled === 'yes') {
740
+                    $active = true;
741
+                } elseif ($enabled === 'no') {
742
+                    $active = false;
743
+                } else {
744
+                    $active = true;
745
+                    $info['groups'] = $enabled;
746
+                }
747
+
748
+                $info['active'] = $active;
749
+
750
+                if ($appManager->isShipped($app)) {
751
+                    $info['internal'] = true;
752
+                    $info['level'] = self::officialApp;
753
+                    $info['removable'] = false;
754
+                } else {
755
+                    $info['internal'] = false;
756
+                    $info['removable'] = true;
757
+                }
758
+
759
+                if (in_array($app, $supportedApps)) {
760
+                    $info['level'] = self::supportedApp;
761
+                }
762
+
763
+                $appPath = self::getAppPath($app);
764
+                if ($appPath !== false) {
765
+                    $appIcon = $appPath . '/img/' . $app . '.svg';
766
+                    if (file_exists($appIcon)) {
767
+                        $info['preview'] = $urlGenerator->imagePath($app, $app . '.svg');
768
+                        $info['previewAsIcon'] = true;
769
+                    } else {
770
+                        $appIcon = $appPath . '/img/app.svg';
771
+                        if (file_exists($appIcon)) {
772
+                            $info['preview'] = $urlGenerator->imagePath($app, 'app.svg');
773
+                            $info['previewAsIcon'] = true;
774
+                        }
775
+                    }
776
+                }
777
+                // fix documentation
778
+                if (isset($info['documentation']) && is_array($info['documentation'])) {
779
+                    foreach ($info['documentation'] as $key => $url) {
780
+                        // If it is not an absolute URL we assume it is a key
781
+                        // i.e. admin-ldap will get converted to go.php?to=admin-ldap
782
+                        if (stripos($url, 'https://') !== 0 && stripos($url, 'http://') !== 0) {
783
+                            $url = $urlGenerator->linkToDocs($url);
784
+                        }
785
+
786
+                        $info['documentation'][$key] = $url;
787
+                    }
788
+                }
789
+
790
+                $info['version'] = OC_App::getAppVersion($app);
791
+                $appList[] = $info;
792
+            }
793
+        }
794
+
795
+        return $appList;
796
+    }
797
+
798
+    public static function shouldUpgrade(string $app): bool {
799
+        $versions = self::getAppVersions();
800
+        $currentVersion = OC_App::getAppVersion($app);
801
+        if ($currentVersion && isset($versions[$app])) {
802
+            $installedVersion = $versions[$app];
803
+            if (!version_compare($currentVersion, $installedVersion, '=')) {
804
+                return true;
805
+            }
806
+        }
807
+        return false;
808
+    }
809
+
810
+    /**
811
+     * Adjust the number of version parts of $version1 to match
812
+     * the number of version parts of $version2.
813
+     *
814
+     * @param string $version1 version to adjust
815
+     * @param string $version2 version to take the number of parts from
816
+     * @return string shortened $version1
817
+     */
818
+    private static function adjustVersionParts(string $version1, string $version2): string {
819
+        $version1 = explode('.', $version1);
820
+        $version2 = explode('.', $version2);
821
+        // reduce $version1 to match the number of parts in $version2
822
+        while (count($version1) > count($version2)) {
823
+            array_pop($version1);
824
+        }
825
+        // if $version1 does not have enough parts, add some
826
+        while (count($version1) < count($version2)) {
827
+            $version1[] = '0';
828
+        }
829
+        return implode('.', $version1);
830
+    }
831
+
832
+    /**
833
+     * Check whether the current ownCloud version matches the given
834
+     * application's version requirements.
835
+     *
836
+     * The comparison is made based on the number of parts that the
837
+     * app info version has. For example for ownCloud 6.0.3 if the
838
+     * app info version is expecting version 6.0, the comparison is
839
+     * made on the first two parts of the ownCloud version.
840
+     * This means that it's possible to specify "requiremin" => 6
841
+     * and "requiremax" => 6 and it will still match ownCloud 6.0.3.
842
+     *
843
+     * @param string $ocVersion ownCloud version to check against
844
+     * @param array $appInfo app info (from xml)
845
+     *
846
+     * @return boolean true if compatible, otherwise false
847
+     */
848
+    public static function isAppCompatible(string $ocVersion, array $appInfo, bool $ignoreMax = false): bool {
849
+        $requireMin = '';
850
+        $requireMax = '';
851
+        if (isset($appInfo['dependencies']['nextcloud']['@attributes']['min-version'])) {
852
+            $requireMin = $appInfo['dependencies']['nextcloud']['@attributes']['min-version'];
853
+        } elseif (isset($appInfo['dependencies']['owncloud']['@attributes']['min-version'])) {
854
+            $requireMin = $appInfo['dependencies']['owncloud']['@attributes']['min-version'];
855
+        } elseif (isset($appInfo['requiremin'])) {
856
+            $requireMin = $appInfo['requiremin'];
857
+        } elseif (isset($appInfo['require'])) {
858
+            $requireMin = $appInfo['require'];
859
+        }
860
+
861
+        if (isset($appInfo['dependencies']['nextcloud']['@attributes']['max-version'])) {
862
+            $requireMax = $appInfo['dependencies']['nextcloud']['@attributes']['max-version'];
863
+        } elseif (isset($appInfo['dependencies']['owncloud']['@attributes']['max-version'])) {
864
+            $requireMax = $appInfo['dependencies']['owncloud']['@attributes']['max-version'];
865
+        } elseif (isset($appInfo['requiremax'])) {
866
+            $requireMax = $appInfo['requiremax'];
867
+        }
868
+
869
+        if (!empty($requireMin)
870
+            && version_compare(self::adjustVersionParts($ocVersion, $requireMin), $requireMin, '<')
871
+        ) {
872
+            return false;
873
+        }
874
+
875
+        if (!$ignoreMax && !empty($requireMax)
876
+            && version_compare(self::adjustVersionParts($ocVersion, $requireMax), $requireMax, '>')
877
+        ) {
878
+            return false;
879
+        }
880
+
881
+        return true;
882
+    }
883
+
884
+    /**
885
+     * get the installed version of all apps
886
+     */
887
+    public static function getAppVersions() {
888
+        static $versions;
889
+
890
+        if (!$versions) {
891
+            $appConfig = \OC::$server->getAppConfig();
892
+            $versions = $appConfig->getValues(false, 'installed_version');
893
+        }
894
+        return $versions;
895
+    }
896
+
897
+    /**
898
+     * update the database for the app and call the update script
899
+     *
900
+     * @param string $appId
901
+     * @return bool
902
+     */
903
+    public static function updateApp(string $appId): bool {
904
+        $appPath = self::getAppPath($appId);
905
+        if ($appPath === false) {
906
+            return false;
907
+        }
908
+
909
+        \OC::$server->getAppManager()->clearAppsCache();
910
+        $appData = self::getAppInfo($appId);
911
+
912
+        self::registerAutoloading($appId, $appPath, true);
913
+        self::executeRepairSteps($appId, $appData['repair-steps']['pre-migration']);
914
+
915
+        if (file_exists($appPath . '/appinfo/database.xml')) {
916
+            OC_DB::updateDbFromStructure($appPath . '/appinfo/database.xml');
917
+        } else {
918
+            $ms = new MigrationService($appId, \OC::$server->getDatabaseConnection());
919
+            $ms->migrate();
920
+        }
921
+
922
+        self::executeRepairSteps($appId, $appData['repair-steps']['post-migration']);
923
+        self::setupLiveMigrations($appId, $appData['repair-steps']['live-migration']);
924
+        // update appversion in app manager
925
+        \OC::$server->getAppManager()->clearAppsCache();
926
+        \OC::$server->getAppManager()->getAppVersion($appId, false);
927
+
928
+        // run upgrade code
929
+        if (file_exists($appPath . '/appinfo/update.php')) {
930
+            self::loadApp($appId);
931
+            include $appPath . '/appinfo/update.php';
932
+        }
933
+        self::setupBackgroundJobs($appData['background-jobs']);
934
+
935
+        //set remote/public handlers
936
+        if (array_key_exists('ocsid', $appData)) {
937
+            \OC::$server->getConfig()->setAppValue($appId, 'ocsid', $appData['ocsid']);
938
+        } elseif (\OC::$server->getConfig()->getAppValue($appId, 'ocsid', null) !== null) {
939
+            \OC::$server->getConfig()->deleteAppValue($appId, 'ocsid');
940
+        }
941
+        foreach ($appData['remote'] as $name => $path) {
942
+            \OC::$server->getConfig()->setAppValue('core', 'remote_' . $name, $appId . '/' . $path);
943
+        }
944
+        foreach ($appData['public'] as $name => $path) {
945
+            \OC::$server->getConfig()->setAppValue('core', 'public_' . $name, $appId . '/' . $path);
946
+        }
947
+
948
+        self::setAppTypes($appId);
949
+
950
+        $version = \OC_App::getAppVersion($appId);
951
+        \OC::$server->getConfig()->setAppValue($appId, 'installed_version', $version);
952
+
953
+        \OC::$server->getEventDispatcher()->dispatch(ManagerEvent::EVENT_APP_UPDATE, new ManagerEvent(
954
+            ManagerEvent::EVENT_APP_UPDATE, $appId
955
+        ));
956
+
957
+        return true;
958
+    }
959
+
960
+    /**
961
+     * @param string $appId
962
+     * @param string[] $steps
963
+     * @throws \OC\NeedsUpdateException
964
+     */
965
+    public static function executeRepairSteps(string $appId, array $steps) {
966
+        if (empty($steps)) {
967
+            return;
968
+        }
969
+        // load the app
970
+        self::loadApp($appId);
971
+
972
+        $dispatcher = OC::$server->getEventDispatcher();
973
+
974
+        // load the steps
975
+        $r = new Repair([], $dispatcher);
976
+        foreach ($steps as $step) {
977
+            try {
978
+                $r->addStep($step);
979
+            } catch (Exception $ex) {
980
+                $r->emit('\OC\Repair', 'error', [$ex->getMessage()]);
981
+                \OC::$server->getLogger()->logException($ex);
982
+            }
983
+        }
984
+        // run the steps
985
+        $r->run();
986
+    }
987
+
988
+    public static function setupBackgroundJobs(array $jobs) {
989
+        $queue = \OC::$server->getJobList();
990
+        foreach ($jobs as $job) {
991
+            $queue->add($job);
992
+        }
993
+    }
994
+
995
+    /**
996
+     * @param string $appId
997
+     * @param string[] $steps
998
+     */
999
+    private static function setupLiveMigrations(string $appId, array $steps) {
1000
+        $queue = \OC::$server->getJobList();
1001
+        foreach ($steps as $step) {
1002
+            $queue->add('OC\Migration\BackgroundRepair', [
1003
+                'app' => $appId,
1004
+                'step' => $step]);
1005
+        }
1006
+    }
1007
+
1008
+    /**
1009
+     * @param string $appId
1010
+     * @return \OC\Files\View|false
1011
+     */
1012
+    public static function getStorage(string $appId) {
1013
+        if (\OC::$server->getAppManager()->isEnabledForUser($appId)) { //sanity check
1014
+            if (\OC::$server->getUserSession()->isLoggedIn()) {
1015
+                $view = new \OC\Files\View('/' . OC_User::getUser());
1016
+                if (!$view->file_exists($appId)) {
1017
+                    $view->mkdir($appId);
1018
+                }
1019
+                return new \OC\Files\View('/' . OC_User::getUser() . '/' . $appId);
1020
+            } else {
1021
+                \OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ', user not logged in', ILogger::ERROR);
1022
+                return false;
1023
+            }
1024
+        } else {
1025
+            \OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ' not enabled', ILogger::ERROR);
1026
+            return false;
1027
+        }
1028
+    }
1029
+
1030
+    protected static function findBestL10NOption(array $options, string $lang): string {
1031
+        // only a single option
1032
+        if (isset($options['@value'])) {
1033
+            return $options['@value'];
1034
+        }
1035
+
1036
+        $fallback = $similarLangFallback = $englishFallback = false;
1037
+
1038
+        $lang = strtolower($lang);
1039
+        $similarLang = $lang;
1040
+        if (strpos($similarLang, '_')) {
1041
+            // For "de_DE" we want to find "de" and the other way around
1042
+            $similarLang = substr($lang, 0, strpos($lang, '_'));
1043
+        }
1044
+
1045
+        foreach ($options as $option) {
1046
+            if (is_array($option)) {
1047
+                if ($fallback === false) {
1048
+                    $fallback = $option['@value'];
1049
+                }
1050
+
1051
+                if (!isset($option['@attributes']['lang'])) {
1052
+                    continue;
1053
+                }
1054
+
1055
+                $attributeLang = strtolower($option['@attributes']['lang']);
1056
+                if ($attributeLang === $lang) {
1057
+                    return $option['@value'];
1058
+                }
1059
+
1060
+                if ($attributeLang === $similarLang) {
1061
+                    $similarLangFallback = $option['@value'];
1062
+                } elseif (strpos($attributeLang, $similarLang . '_') === 0) {
1063
+                    if ($similarLangFallback === false) {
1064
+                        $similarLangFallback =  $option['@value'];
1065
+                    }
1066
+                }
1067
+            } else {
1068
+                $englishFallback = $option;
1069
+            }
1070
+        }
1071
+
1072
+        if ($similarLangFallback !== false) {
1073
+            return $similarLangFallback;
1074
+        } elseif ($englishFallback !== false) {
1075
+            return $englishFallback;
1076
+        }
1077
+        return (string) $fallback;
1078
+    }
1079
+
1080
+    /**
1081
+     * parses the app data array and enhanced the 'description' value
1082
+     *
1083
+     * @param array $data the app data
1084
+     * @param string $lang
1085
+     * @return array improved app data
1086
+     */
1087
+    public static function parseAppInfo(array $data, $lang = null): array {
1088
+        if ($lang && isset($data['name']) && is_array($data['name'])) {
1089
+            $data['name'] = self::findBestL10NOption($data['name'], $lang);
1090
+        }
1091
+        if ($lang && isset($data['summary']) && is_array($data['summary'])) {
1092
+            $data['summary'] = self::findBestL10NOption($data['summary'], $lang);
1093
+        }
1094
+        if ($lang && isset($data['description']) && is_array($data['description'])) {
1095
+            $data['description'] = trim(self::findBestL10NOption($data['description'], $lang));
1096
+        } elseif (isset($data['description']) && is_string($data['description'])) {
1097
+            $data['description'] = trim($data['description']);
1098
+        } else {
1099
+            $data['description'] = '';
1100
+        }
1101
+
1102
+        return $data;
1103
+    }
1104
+
1105
+    /**
1106
+     * @param \OCP\IConfig $config
1107
+     * @param \OCP\IL10N $l
1108
+     * @param array $info
1109
+     * @throws \Exception
1110
+     */
1111
+    public static function checkAppDependencies(\OCP\IConfig $config, \OCP\IL10N $l, array $info, bool $ignoreMax) {
1112
+        $dependencyAnalyzer = new DependencyAnalyzer(new Platform($config), $l);
1113
+        $missing = $dependencyAnalyzer->analyze($info, $ignoreMax);
1114
+        if (!empty($missing)) {
1115
+            $missingMsg = implode(PHP_EOL, $missing);
1116
+            throw new \Exception(
1117
+                $l->t('App "%1$s" cannot be installed because the following dependencies are not fulfilled: %2$s',
1118
+                    [$info['name'], $missingMsg]
1119
+                )
1120
+            );
1121
+        }
1122
+    }
1123 1123
 }
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -152,8 +152,8 @@  discard block
 block discarded – undo
152 152
 		/** @var \OC\AppFramework\Bootstrap\Coordinator $coordinator */
153 153
 		$coordinator = \OC::$server->query(\OC\AppFramework\Bootstrap\Coordinator::class);
154 154
 		$coordinator->bootApp($app);
155
-		if (is_file($appPath . '/appinfo/app.php')) {
156
-			\OC::$server->getEventLogger()->start('load_app_' . $app, 'Load app: ' . $app);
155
+		if (is_file($appPath.'/appinfo/app.php')) {
156
+			\OC::$server->getEventLogger()->start('load_app_'.$app, 'Load app: '.$app);
157 157
 			try {
158 158
 				self::requireAppFile($app);
159 159
 			} catch (Throwable $ex) {
@@ -162,18 +162,18 @@  discard block
 block discarded – undo
162 162
 				}
163 163
 				if (!\OC::$server->getAppManager()->isShipped($app) && !self::isType($app, ['authentication'])) {
164 164
 					\OC::$server->getLogger()->logException($ex, [
165
-						'message' => "App $app threw an error during app.php load and will be disabled: " . $ex->getMessage(),
165
+						'message' => "App $app threw an error during app.php load and will be disabled: ".$ex->getMessage(),
166 166
 					]);
167 167
 
168 168
 					// Only disable apps which are not shipped and that are not authentication apps
169 169
 					\OC::$server->getAppManager()->disableApp($app, true);
170 170
 				} else {
171 171
 					\OC::$server->getLogger()->logException($ex, [
172
-						'message' => "App $app threw an error during app.php load: " . $ex->getMessage(),
172
+						'message' => "App $app threw an error during app.php load: ".$ex->getMessage(),
173 173
 					]);
174 174
 				}
175 175
 			}
176
-			\OC::$server->getEventLogger()->end('load_app_' . $app);
176
+			\OC::$server->getEventLogger()->end('load_app_'.$app);
177 177
 		}
178 178
 
179 179
 		$info = self::getAppInfo($app);
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 	 * @param bool $force
240 240
 	 */
241 241
 	public static function registerAutoloading(string $app, string $path, bool $force = false) {
242
-		$key = $app . '-' . $path;
242
+		$key = $app.'-'.$path;
243 243
 		if (!$force && isset(self::$alreadyRegistered[$key])) {
244 244
 			return;
245 245
 		}
@@ -250,17 +250,17 @@  discard block
 block discarded – undo
250 250
 		$appNamespace = \OC\AppFramework\App::buildAppNamespace($app);
251 251
 		\OC::$server->registerNamespace($app, $appNamespace);
252 252
 
253
-		if (file_exists($path . '/composer/autoload.php')) {
254
-			require_once $path . '/composer/autoload.php';
253
+		if (file_exists($path.'/composer/autoload.php')) {
254
+			require_once $path.'/composer/autoload.php';
255 255
 		} else {
256
-			\OC::$composerAutoloader->addPsr4($appNamespace . '\\', $path . '/lib/', true);
256
+			\OC::$composerAutoloader->addPsr4($appNamespace.'\\', $path.'/lib/', true);
257 257
 			// Register on legacy autoloader
258 258
 			\OC::$loader->addValidRoot($path);
259 259
 		}
260 260
 
261 261
 		// Register Test namespace only when testing
262 262
 		if (defined('PHPUNIT_RUN') || defined('CLI_TEST_RUN')) {
263
-			\OC::$composerAutoloader->addPsr4($appNamespace . '\\Tests\\', $path . '/tests/', true);
263
+			\OC::$composerAutoloader->addPsr4($appNamespace.'\\Tests\\', $path.'/tests/', true);
264 264
 		}
265 265
 	}
266 266
 
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 	 */
273 273
 	private static function requireAppFile(string $app) {
274 274
 		// encapsulated here to avoid variable scope conflicts
275
-		require_once $app . '/appinfo/app.php';
275
+		require_once $app.'/appinfo/app.php';
276 276
 	}
277 277
 
278 278
 	/**
@@ -365,8 +365,8 @@  discard block
 block discarded – undo
365 365
 		} else {
366 366
 			$apps = $appManager->getEnabledAppsForUser($user);
367 367
 		}
368
-		$apps = array_filter($apps, function ($app) {
369
-			return $app !== 'files';//we add this manually
368
+		$apps = array_filter($apps, function($app) {
369
+			return $app !== 'files'; //we add this manually
370 370
 		});
371 371
 		sort($apps);
372 372
 		array_unshift($apps, 'files');
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 
467 467
 		$possibleApps = [];
468 468
 		foreach (OC::$APPSROOTS as $dir) {
469
-			if (file_exists($dir['path'] . '/' . $appId)) {
469
+			if (file_exists($dir['path'].'/'.$appId)) {
470 470
 				$possibleApps[] = $dir;
471 471
 			}
472 472
 		}
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
 		} else {
481 481
 			$versionToLoad = [];
482 482
 			foreach ($possibleApps as $possibleApp) {
483
-				$version = self::getAppVersionByPath($possibleApp['path'] . '/' . $appId);
483
+				$version = self::getAppVersionByPath($possibleApp['path'].'/'.$appId);
484 484
 				if (empty($versionToLoad) || version_compare($version, $versionToLoad['version'], '>')) {
485 485
 					$versionToLoad = [
486 486
 						'dir' => $possibleApp,
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 		}
509 509
 
510 510
 		if (($dir = self::findAppInDirectories($appId)) != false) {
511
-			return $dir['path'] . '/' . $appId;
511
+			return $dir['path'].'/'.$appId;
512 512
 		}
513 513
 		return false;
514 514
 	}
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 	 */
524 524
 	public static function getAppWebPath(string $appId) {
525 525
 		if (($dir = self::findAppInDirectories($appId)) != false) {
526
-			return OC::$WEBROOT . $dir['url'] . '/' . $appId;
526
+			return OC::$WEBROOT.$dir['url'].'/'.$appId;
527 527
 		}
528 528
 		return false;
529 529
 	}
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 	 * @return string
548 548
 	 */
549 549
 	public static function getAppVersionByPath(string $path): string {
550
-		$infoFile = $path . '/appinfo/info.xml';
550
+		$infoFile = $path.'/appinfo/info.xml';
551 551
 		$appData = \OC::$server->getAppManager()->getAppInfo($infoFile, true);
552 552
 		return isset($appData['version']) ? $appData['version'] : '';
553 553
 	}
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
 	 * @param string $page
648 648
 	 */
649 649
 	public static function registerAdmin(string $app, string $page) {
650
-		self::$adminForms[] = $app . '/' . $page . '.php';
650
+		self::$adminForms[] = $app.'/'.$page.'.php';
651 651
 	}
652 652
 
653 653
 	/**
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
 	 * @param string $page
657 657
 	 */
658 658
 	public static function registerPersonal(string $app, string $page) {
659
-		self::$personalForms[] = $app . '/' . $page . '.php';
659
+		self::$personalForms[] = $app.'/'.$page.'.php';
660 660
 	}
661 661
 
662 662
 	/**
@@ -684,14 +684,14 @@  discard block
 block discarded – undo
684 684
 
685 685
 		foreach (OC::$APPSROOTS as $apps_dir) {
686 686
 			if (!is_readable($apps_dir['path'])) {
687
-				\OCP\Util::writeLog('core', 'unable to read app folder : ' . $apps_dir['path'], ILogger::WARN);
687
+				\OCP\Util::writeLog('core', 'unable to read app folder : '.$apps_dir['path'], ILogger::WARN);
688 688
 				continue;
689 689
 			}
690 690
 			$dh = opendir($apps_dir['path']);
691 691
 
692 692
 			if (is_resource($dh)) {
693 693
 				while (($file = readdir($dh)) !== false) {
694
-					if ($file[0] != '.' and is_dir($apps_dir['path'] . '/' . $file) and is_file($apps_dir['path'] . '/' . $file . '/appinfo/info.xml')) {
694
+					if ($file[0] != '.' and is_dir($apps_dir['path'].'/'.$file) and is_file($apps_dir['path'].'/'.$file.'/appinfo/info.xml')) {
695 695
 						$apps[] = $file;
696 696
 					}
697 697
 				}
@@ -725,12 +725,12 @@  discard block
 block discarded – undo
725 725
 			if (array_search($app, $blacklist) === false) {
726 726
 				$info = OC_App::getAppInfo($app, false, $langCode);
727 727
 				if (!is_array($info)) {
728
-					\OCP\Util::writeLog('core', 'Could not read app info file for app "' . $app . '"', ILogger::ERROR);
728
+					\OCP\Util::writeLog('core', 'Could not read app info file for app "'.$app.'"', ILogger::ERROR);
729 729
 					continue;
730 730
 				}
731 731
 
732 732
 				if (!isset($info['name'])) {
733
-					\OCP\Util::writeLog('core', 'App id "' . $app . '" has no name in appinfo', ILogger::ERROR);
733
+					\OCP\Util::writeLog('core', 'App id "'.$app.'" has no name in appinfo', ILogger::ERROR);
734 734
 					continue;
735 735
 				}
736 736
 
@@ -762,12 +762,12 @@  discard block
 block discarded – undo
762 762
 
763 763
 				$appPath = self::getAppPath($app);
764 764
 				if ($appPath !== false) {
765
-					$appIcon = $appPath . '/img/' . $app . '.svg';
765
+					$appIcon = $appPath.'/img/'.$app.'.svg';
766 766
 					if (file_exists($appIcon)) {
767
-						$info['preview'] = $urlGenerator->imagePath($app, $app . '.svg');
767
+						$info['preview'] = $urlGenerator->imagePath($app, $app.'.svg');
768 768
 						$info['previewAsIcon'] = true;
769 769
 					} else {
770
-						$appIcon = $appPath . '/img/app.svg';
770
+						$appIcon = $appPath.'/img/app.svg';
771 771
 						if (file_exists($appIcon)) {
772 772
 							$info['preview'] = $urlGenerator->imagePath($app, 'app.svg');
773 773
 							$info['previewAsIcon'] = true;
@@ -912,8 +912,8 @@  discard block
 block discarded – undo
912 912
 		self::registerAutoloading($appId, $appPath, true);
913 913
 		self::executeRepairSteps($appId, $appData['repair-steps']['pre-migration']);
914 914
 
915
-		if (file_exists($appPath . '/appinfo/database.xml')) {
916
-			OC_DB::updateDbFromStructure($appPath . '/appinfo/database.xml');
915
+		if (file_exists($appPath.'/appinfo/database.xml')) {
916
+			OC_DB::updateDbFromStructure($appPath.'/appinfo/database.xml');
917 917
 		} else {
918 918
 			$ms = new MigrationService($appId, \OC::$server->getDatabaseConnection());
919 919
 			$ms->migrate();
@@ -926,9 +926,9 @@  discard block
 block discarded – undo
926 926
 		\OC::$server->getAppManager()->getAppVersion($appId, false);
927 927
 
928 928
 		// run upgrade code
929
-		if (file_exists($appPath . '/appinfo/update.php')) {
929
+		if (file_exists($appPath.'/appinfo/update.php')) {
930 930
 			self::loadApp($appId);
931
-			include $appPath . '/appinfo/update.php';
931
+			include $appPath.'/appinfo/update.php';
932 932
 		}
933 933
 		self::setupBackgroundJobs($appData['background-jobs']);
934 934
 
@@ -939,10 +939,10 @@  discard block
 block discarded – undo
939 939
 			\OC::$server->getConfig()->deleteAppValue($appId, 'ocsid');
940 940
 		}
941 941
 		foreach ($appData['remote'] as $name => $path) {
942
-			\OC::$server->getConfig()->setAppValue('core', 'remote_' . $name, $appId . '/' . $path);
942
+			\OC::$server->getConfig()->setAppValue('core', 'remote_'.$name, $appId.'/'.$path);
943 943
 		}
944 944
 		foreach ($appData['public'] as $name => $path) {
945
-			\OC::$server->getConfig()->setAppValue('core', 'public_' . $name, $appId . '/' . $path);
945
+			\OC::$server->getConfig()->setAppValue('core', 'public_'.$name, $appId.'/'.$path);
946 946
 		}
947 947
 
948 948
 		self::setAppTypes($appId);
@@ -1012,17 +1012,17 @@  discard block
 block discarded – undo
1012 1012
 	public static function getStorage(string $appId) {
1013 1013
 		if (\OC::$server->getAppManager()->isEnabledForUser($appId)) { //sanity check
1014 1014
 			if (\OC::$server->getUserSession()->isLoggedIn()) {
1015
-				$view = new \OC\Files\View('/' . OC_User::getUser());
1015
+				$view = new \OC\Files\View('/'.OC_User::getUser());
1016 1016
 				if (!$view->file_exists($appId)) {
1017 1017
 					$view->mkdir($appId);
1018 1018
 				}
1019
-				return new \OC\Files\View('/' . OC_User::getUser() . '/' . $appId);
1019
+				return new \OC\Files\View('/'.OC_User::getUser().'/'.$appId);
1020 1020
 			} else {
1021
-				\OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ', user not logged in', ILogger::ERROR);
1021
+				\OCP\Util::writeLog('core', 'Can\'t get app storage, app '.$appId.', user not logged in', ILogger::ERROR);
1022 1022
 				return false;
1023 1023
 			}
1024 1024
 		} else {
1025
-			\OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ' not enabled', ILogger::ERROR);
1025
+			\OCP\Util::writeLog('core', 'Can\'t get app storage, app '.$appId.' not enabled', ILogger::ERROR);
1026 1026
 			return false;
1027 1027
 		}
1028 1028
 	}
@@ -1059,9 +1059,9 @@  discard block
 block discarded – undo
1059 1059
 
1060 1060
 				if ($attributeLang === $similarLang) {
1061 1061
 					$similarLangFallback = $option['@value'];
1062
-				} elseif (strpos($attributeLang, $similarLang . '_') === 0) {
1062
+				} elseif (strpos($attributeLang, $similarLang.'_') === 0) {
1063 1063
 					if ($similarLangFallback === false) {
1064
-						$similarLangFallback =  $option['@value'];
1064
+						$similarLangFallback = $option['@value'];
1065 1065
 					}
1066 1066
 				}
1067 1067
 			} else {
Please login to merge, or discard this patch.