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