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