@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @param array $urlParams |
75 | 75 | * @param ServerContainer $server |
76 | 76 | */ |
77 | - public function __construct($appName, $urlParams = array(), ServerContainer $server = null){ |
|
77 | + public function __construct($appName, $urlParams = array(), ServerContainer $server = null) { |
|
78 | 78 | parent::__construct(); |
79 | 79 | $this['AppName'] = $appName; |
80 | 80 | $this['urlParams'] = $urlParams; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | /** |
95 | 95 | * Core services |
96 | 96 | */ |
97 | - $this->registerService(IOutput::class, function($c){ |
|
97 | + $this->registerService(IOutput::class, function($c) { |
|
98 | 98 | return new Output($this->getServer()->getWebRoot()); |
99 | 99 | }); |
100 | 100 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | return $this->getServer()->getUserFolder(); |
103 | 103 | }); |
104 | 104 | |
105 | - $this->registerService(IAppData::class, function (SimpleContainer $c) { |
|
105 | + $this->registerService(IAppData::class, function(SimpleContainer $c) { |
|
106 | 106 | return $this->getServer()->getAppDataDir($c->query('AppName')); |
107 | 107 | }); |
108 | 108 | |
@@ -123,25 +123,25 @@ discard block |
||
123 | 123 | |
124 | 124 | $this->registerAlias(\OC\User\Session::class, \OCP\IUserSession::class); |
125 | 125 | |
126 | - $this->registerService(IServerContainer::class, function ($c) { |
|
126 | + $this->registerService(IServerContainer::class, function($c) { |
|
127 | 127 | return $this->getServer(); |
128 | 128 | }); |
129 | 129 | $this->registerAlias('ServerContainer', IServerContainer::class); |
130 | 130 | |
131 | - $this->registerService(\OCP\WorkflowEngine\IManager::class, function ($c) { |
|
131 | + $this->registerService(\OCP\WorkflowEngine\IManager::class, function($c) { |
|
132 | 132 | return $c->query('OCA\WorkflowEngine\Manager'); |
133 | 133 | }); |
134 | 134 | |
135 | - $this->registerService(\OCP\AppFramework\IAppContainer::class, function ($c) { |
|
135 | + $this->registerService(\OCP\AppFramework\IAppContainer::class, function($c) { |
|
136 | 136 | return $c; |
137 | 137 | }); |
138 | 138 | |
139 | 139 | // commonly used attributes |
140 | - $this->registerService('UserId', function ($c) { |
|
140 | + $this->registerService('UserId', function($c) { |
|
141 | 141 | return $c->query('OCP\\IUserSession')->getSession()->get('user_id'); |
142 | 142 | }); |
143 | 143 | |
144 | - $this->registerService('WebRoot', function ($c) { |
|
144 | + $this->registerService('WebRoot', function($c) { |
|
145 | 145 | return $c->query('ServerContainer')->getWebRoot(); |
146 | 146 | }); |
147 | 147 | |
@@ -149,11 +149,11 @@ discard block |
||
149 | 149 | return Util::getDefaultEmailAddress('no-reply'); |
150 | 150 | }); |
151 | 151 | |
152 | - $this->registerService('OC_Defaults', function ($c) { |
|
152 | + $this->registerService('OC_Defaults', function($c) { |
|
153 | 153 | return $c->getServer()->getThemingDefaults(); |
154 | 154 | }); |
155 | 155 | |
156 | - $this->registerService('OCP\Encryption\IManager', function ($c) { |
|
156 | + $this->registerService('OCP\Encryption\IManager', function($c) { |
|
157 | 157 | return $this->getServer()->getEncryptionManager(); |
158 | 158 | }); |
159 | 159 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | return $c->query(Validator::class); |
162 | 162 | }); |
163 | 163 | |
164 | - $this->registerService(\OC\Security\IdentityProof\Manager::class, function ($c) { |
|
164 | + $this->registerService(\OC\Security\IdentityProof\Manager::class, function($c) { |
|
165 | 165 | return new \OC\Security\IdentityProof\Manager( |
166 | 166 | $this->getServer()->getAppDataDir('identityproof'), |
167 | 167 | $this->getServer()->getCrypto() |
@@ -172,15 +172,15 @@ discard block |
||
172 | 172 | /** |
173 | 173 | * App Framework APIs |
174 | 174 | */ |
175 | - $this->registerService('API', function($c){ |
|
175 | + $this->registerService('API', function($c) { |
|
176 | 176 | $c->query('OCP\\ILogger')->debug( |
177 | - 'Accessing the API class is deprecated! Use the appropriate ' . |
|
177 | + 'Accessing the API class is deprecated! Use the appropriate '. |
|
178 | 178 | 'services instead!' |
179 | 179 | ); |
180 | 180 | return new API($c['AppName']); |
181 | 181 | }); |
182 | 182 | |
183 | - $this->registerService('Protocol', function($c){ |
|
183 | + $this->registerService('Protocol', function($c) { |
|
184 | 184 | /** @var \OC\Server $server */ |
185 | 185 | $server = $c->query('ServerContainer'); |
186 | 186 | $protocol = $server->getRequest()->getHttpProtocol(); |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | ); |
247 | 247 | }); |
248 | 248 | |
249 | - $this->registerService('TwoFactorMiddleware', function (SimpleContainer $c) use ($app) { |
|
249 | + $this->registerService('TwoFactorMiddleware', function(SimpleContainer $c) use ($app) { |
|
250 | 250 | $twoFactorManager = $c->getServer()->getTwoFactorAuthManager(); |
251 | 251 | $userSession = $app->getServer()->getUserSession(); |
252 | 252 | $session = $app->getServer()->getSession(); |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | return new TwoFactorMiddleware($twoFactorManager, $userSession, $session, $urlGenerator, $reflector, $request); |
257 | 257 | }); |
258 | 258 | |
259 | - $this->registerService('OCSMiddleware', function (SimpleContainer $c) { |
|
259 | + $this->registerService('OCSMiddleware', function(SimpleContainer $c) { |
|
260 | 260 | return new OCSMiddleware( |
261 | 261 | $c['Request'] |
262 | 262 | ); |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | $dispatcher->registerMiddleware($c['SecurityMiddleware']); |
271 | 271 | $dispatcher->registerMiddleWare($c['TwoFactorMiddleware']); |
272 | 272 | |
273 | - foreach($middleWares as $middleWare) { |
|
273 | + foreach ($middleWares as $middleWare) { |
|
274 | 274 | $dispatcher->registerMiddleware($c[$middleWare]); |
275 | 275 | } |
276 | 276 | |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | * @return mixed |
343 | 343 | */ |
344 | 344 | function log($message, $level) { |
345 | - switch($level){ |
|
345 | + switch ($level) { |
|
346 | 346 | case 'debug': |
347 | 347 | $level = \OCP\Util::DEBUG; |
348 | 348 | break; |
@@ -60,337 +60,337 @@ |
||
60 | 60 | |
61 | 61 | class DIContainer extends SimpleContainer implements IAppContainer { |
62 | 62 | |
63 | - /** |
|
64 | - * @var array |
|
65 | - */ |
|
66 | - private $middleWares = array(); |
|
67 | - |
|
68 | - /** @var ServerContainer */ |
|
69 | - private $server; |
|
70 | - |
|
71 | - /** |
|
72 | - * Put your class dependencies in here |
|
73 | - * @param string $appName the name of the app |
|
74 | - * @param array $urlParams |
|
75 | - * @param ServerContainer $server |
|
76 | - */ |
|
77 | - public function __construct($appName, $urlParams = array(), ServerContainer $server = null){ |
|
78 | - parent::__construct(); |
|
79 | - $this['AppName'] = $appName; |
|
80 | - $this['urlParams'] = $urlParams; |
|
81 | - |
|
82 | - /** @var \OC\ServerContainer $server */ |
|
83 | - if ($server === null) { |
|
84 | - $server = \OC::$server; |
|
85 | - } |
|
86 | - $this->server = $server; |
|
87 | - $this->server->registerAppContainer($appName, $this); |
|
88 | - |
|
89 | - // aliases |
|
90 | - $this->registerAlias('appName', 'AppName'); |
|
91 | - $this->registerAlias('webRoot', 'WebRoot'); |
|
92 | - $this->registerAlias('userId', 'UserId'); |
|
93 | - |
|
94 | - /** |
|
95 | - * Core services |
|
96 | - */ |
|
97 | - $this->registerService(IOutput::class, function($c){ |
|
98 | - return new Output($this->getServer()->getWebRoot()); |
|
99 | - }); |
|
100 | - |
|
101 | - $this->registerService(Folder::class, function() { |
|
102 | - return $this->getServer()->getUserFolder(); |
|
103 | - }); |
|
104 | - |
|
105 | - $this->registerService(IAppData::class, function (SimpleContainer $c) { |
|
106 | - return $this->getServer()->getAppDataDir($c->query('AppName')); |
|
107 | - }); |
|
108 | - |
|
109 | - $this->registerService(IL10N::class, function($c) { |
|
110 | - return $this->getServer()->getL10N($c->query('AppName')); |
|
111 | - }); |
|
112 | - |
|
113 | - $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
114 | - $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
115 | - |
|
116 | - $this->registerService(IRequest::class, function() { |
|
117 | - return $this->getServer()->query(IRequest::class); |
|
118 | - }); |
|
119 | - $this->registerAlias('Request', IRequest::class); |
|
120 | - |
|
121 | - $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
122 | - $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
123 | - |
|
124 | - $this->registerAlias(\OC\User\Session::class, \OCP\IUserSession::class); |
|
125 | - |
|
126 | - $this->registerService(IServerContainer::class, function ($c) { |
|
127 | - return $this->getServer(); |
|
128 | - }); |
|
129 | - $this->registerAlias('ServerContainer', IServerContainer::class); |
|
130 | - |
|
131 | - $this->registerService(\OCP\WorkflowEngine\IManager::class, function ($c) { |
|
132 | - return $c->query('OCA\WorkflowEngine\Manager'); |
|
133 | - }); |
|
134 | - |
|
135 | - $this->registerService(\OCP\AppFramework\IAppContainer::class, function ($c) { |
|
136 | - return $c; |
|
137 | - }); |
|
138 | - |
|
139 | - // commonly used attributes |
|
140 | - $this->registerService('UserId', function ($c) { |
|
141 | - return $c->query('OCP\\IUserSession')->getSession()->get('user_id'); |
|
142 | - }); |
|
143 | - |
|
144 | - $this->registerService('WebRoot', function ($c) { |
|
145 | - return $c->query('ServerContainer')->getWebRoot(); |
|
146 | - }); |
|
147 | - |
|
148 | - $this->registerService('fromMailAddress', function() { |
|
149 | - return Util::getDefaultEmailAddress('no-reply'); |
|
150 | - }); |
|
151 | - |
|
152 | - $this->registerService('OC_Defaults', function ($c) { |
|
153 | - return $c->getServer()->getThemingDefaults(); |
|
154 | - }); |
|
155 | - |
|
156 | - $this->registerService('OCP\Encryption\IManager', function ($c) { |
|
157 | - return $this->getServer()->getEncryptionManager(); |
|
158 | - }); |
|
159 | - |
|
160 | - $this->registerService(IValidator::class, function($c) { |
|
161 | - return $c->query(Validator::class); |
|
162 | - }); |
|
163 | - |
|
164 | - $this->registerService(\OC\Security\IdentityProof\Manager::class, function ($c) { |
|
165 | - return new \OC\Security\IdentityProof\Manager( |
|
166 | - $this->getServer()->getAppDataDir('identityproof'), |
|
167 | - $this->getServer()->getCrypto() |
|
168 | - ); |
|
169 | - }); |
|
170 | - |
|
171 | - |
|
172 | - /** |
|
173 | - * App Framework APIs |
|
174 | - */ |
|
175 | - $this->registerService('API', function($c){ |
|
176 | - $c->query('OCP\\ILogger')->debug( |
|
177 | - 'Accessing the API class is deprecated! Use the appropriate ' . |
|
178 | - 'services instead!' |
|
179 | - ); |
|
180 | - return new API($c['AppName']); |
|
181 | - }); |
|
182 | - |
|
183 | - $this->registerService('Protocol', function($c){ |
|
184 | - /** @var \OC\Server $server */ |
|
185 | - $server = $c->query('ServerContainer'); |
|
186 | - $protocol = $server->getRequest()->getHttpProtocol(); |
|
187 | - return new Http($_SERVER, $protocol); |
|
188 | - }); |
|
189 | - |
|
190 | - $this->registerService('Dispatcher', function($c) { |
|
191 | - return new Dispatcher( |
|
192 | - $c['Protocol'], |
|
193 | - $c['MiddlewareDispatcher'], |
|
194 | - $c['ControllerMethodReflector'], |
|
195 | - $c['Request'] |
|
196 | - ); |
|
197 | - }); |
|
198 | - |
|
199 | - /** |
|
200 | - * App Framework default arguments |
|
201 | - */ |
|
202 | - $this->registerParameter('corsMethods', 'PUT, POST, GET, DELETE, PATCH'); |
|
203 | - $this->registerParameter('corsAllowedHeaders', 'Authorization, Content-Type, Accept'); |
|
204 | - $this->registerParameter('corsMaxAge', 1728000); |
|
205 | - |
|
206 | - /** |
|
207 | - * Middleware |
|
208 | - */ |
|
209 | - $app = $this; |
|
210 | - $this->registerService('SecurityMiddleware', function($c) use ($app){ |
|
211 | - /** @var \OC\Server $server */ |
|
212 | - $server = $app->getServer(); |
|
213 | - |
|
214 | - return new SecurityMiddleware( |
|
215 | - $c['Request'], |
|
216 | - $c['ControllerMethodReflector'], |
|
217 | - $server->getNavigationManager(), |
|
218 | - $server->getURLGenerator(), |
|
219 | - $server->getLogger(), |
|
220 | - $server->getSession(), |
|
221 | - $c['AppName'], |
|
222 | - $app->isLoggedIn(), |
|
223 | - $app->isAdminUser(), |
|
224 | - $server->getContentSecurityPolicyManager(), |
|
225 | - $server->getCsrfTokenManager(), |
|
226 | - $server->getContentSecurityPolicyNonceManager(), |
|
227 | - $server->getBruteForceThrottler() |
|
228 | - ); |
|
229 | - |
|
230 | - }); |
|
231 | - |
|
232 | - $this->registerService('CORSMiddleware', function($c) { |
|
233 | - return new CORSMiddleware( |
|
234 | - $c['Request'], |
|
235 | - $c['ControllerMethodReflector'], |
|
236 | - $c->query(IUserSession::class), |
|
237 | - $c->getServer()->getBruteForceThrottler() |
|
238 | - ); |
|
239 | - }); |
|
240 | - |
|
241 | - $this->registerService('SessionMiddleware', function($c) use ($app) { |
|
242 | - return new SessionMiddleware( |
|
243 | - $c['Request'], |
|
244 | - $c['ControllerMethodReflector'], |
|
245 | - $app->getServer()->getSession() |
|
246 | - ); |
|
247 | - }); |
|
248 | - |
|
249 | - $this->registerService('TwoFactorMiddleware', function (SimpleContainer $c) use ($app) { |
|
250 | - $twoFactorManager = $c->getServer()->getTwoFactorAuthManager(); |
|
251 | - $userSession = $app->getServer()->getUserSession(); |
|
252 | - $session = $app->getServer()->getSession(); |
|
253 | - $urlGenerator = $app->getServer()->getURLGenerator(); |
|
254 | - $reflector = $c['ControllerMethodReflector']; |
|
255 | - $request = $app->getServer()->getRequest(); |
|
256 | - return new TwoFactorMiddleware($twoFactorManager, $userSession, $session, $urlGenerator, $reflector, $request); |
|
257 | - }); |
|
258 | - |
|
259 | - $this->registerService('OCSMiddleware', function (SimpleContainer $c) { |
|
260 | - return new OCSMiddleware( |
|
261 | - $c['Request'] |
|
262 | - ); |
|
263 | - }); |
|
264 | - |
|
265 | - $middleWares = &$this->middleWares; |
|
266 | - $this->registerService('MiddlewareDispatcher', function($c) use (&$middleWares) { |
|
267 | - $dispatcher = new MiddlewareDispatcher(); |
|
268 | - $dispatcher->registerMiddleware($c['CORSMiddleware']); |
|
269 | - $dispatcher->registerMiddleware($c['OCSMiddleware']); |
|
270 | - $dispatcher->registerMiddleware($c['SecurityMiddleware']); |
|
271 | - $dispatcher->registerMiddleWare($c['TwoFactorMiddleware']); |
|
272 | - |
|
273 | - foreach($middleWares as $middleWare) { |
|
274 | - $dispatcher->registerMiddleware($c[$middleWare]); |
|
275 | - } |
|
276 | - |
|
277 | - $dispatcher->registerMiddleware($c['SessionMiddleware']); |
|
278 | - return $dispatcher; |
|
279 | - }); |
|
280 | - |
|
281 | - } |
|
282 | - |
|
283 | - |
|
284 | - /** |
|
285 | - * @deprecated implements only deprecated methods |
|
286 | - * @return IApi |
|
287 | - */ |
|
288 | - function getCoreApi() |
|
289 | - { |
|
290 | - return $this->query('API'); |
|
291 | - } |
|
292 | - |
|
293 | - /** |
|
294 | - * @return \OCP\IServerContainer |
|
295 | - */ |
|
296 | - function getServer() |
|
297 | - { |
|
298 | - return $this->server; |
|
299 | - } |
|
300 | - |
|
301 | - /** |
|
302 | - * @param string $middleWare |
|
303 | - * @return boolean|null |
|
304 | - */ |
|
305 | - function registerMiddleWare($middleWare) { |
|
306 | - array_push($this->middleWares, $middleWare); |
|
307 | - } |
|
308 | - |
|
309 | - /** |
|
310 | - * used to return the appname of the set application |
|
311 | - * @return string the name of your application |
|
312 | - */ |
|
313 | - function getAppName() { |
|
314 | - return $this->query('AppName'); |
|
315 | - } |
|
316 | - |
|
317 | - /** |
|
318 | - * @deprecated use IUserSession->isLoggedIn() |
|
319 | - * @return boolean |
|
320 | - */ |
|
321 | - function isLoggedIn() { |
|
322 | - return \OC::$server->getUserSession()->isLoggedIn(); |
|
323 | - } |
|
324 | - |
|
325 | - /** |
|
326 | - * @deprecated use IGroupManager->isAdmin($userId) |
|
327 | - * @return boolean |
|
328 | - */ |
|
329 | - function isAdminUser() { |
|
330 | - $uid = $this->getUserId(); |
|
331 | - return \OC_User::isAdminUser($uid); |
|
332 | - } |
|
333 | - |
|
334 | - private function getUserId() { |
|
335 | - return $this->getServer()->getSession()->get('user_id'); |
|
336 | - } |
|
337 | - |
|
338 | - /** |
|
339 | - * @deprecated use the ILogger instead |
|
340 | - * @param string $message |
|
341 | - * @param string $level |
|
342 | - * @return mixed |
|
343 | - */ |
|
344 | - function log($message, $level) { |
|
345 | - switch($level){ |
|
346 | - case 'debug': |
|
347 | - $level = \OCP\Util::DEBUG; |
|
348 | - break; |
|
349 | - case 'info': |
|
350 | - $level = \OCP\Util::INFO; |
|
351 | - break; |
|
352 | - case 'warn': |
|
353 | - $level = \OCP\Util::WARN; |
|
354 | - break; |
|
355 | - case 'fatal': |
|
356 | - $level = \OCP\Util::FATAL; |
|
357 | - break; |
|
358 | - default: |
|
359 | - $level = \OCP\Util::ERROR; |
|
360 | - break; |
|
361 | - } |
|
362 | - \OCP\Util::writeLog($this->getAppName(), $message, $level); |
|
363 | - } |
|
364 | - |
|
365 | - /** |
|
366 | - * Register a capability |
|
367 | - * |
|
368 | - * @param string $serviceName e.g. 'OCA\Files\Capabilities' |
|
369 | - */ |
|
370 | - public function registerCapability($serviceName) { |
|
371 | - $this->query('OC\CapabilitiesManager')->registerCapability(function() use ($serviceName) { |
|
372 | - return $this->query($serviceName); |
|
373 | - }); |
|
374 | - } |
|
375 | - |
|
376 | - public function query($name) { |
|
377 | - $name = $this->sanitizeName($name); |
|
378 | - |
|
379 | - if ($this->offsetExists($name)) { |
|
380 | - return parent::query($name); |
|
381 | - } else { |
|
382 | - if (strpos($name, 'OCA\\') === 0 && substr_count($name, '\\') >= 2) { |
|
383 | - $segments = explode('\\', $name); |
|
384 | - if (strtolower($segments[1]) === strtolower($this['AppName'])) { |
|
385 | - return parent::query($name); |
|
386 | - } |
|
387 | - } else if ($this['AppName'] === 'settings' && strpos($name, 'OC\\Settings\\') === 0) { |
|
388 | - return parent::query($name); |
|
389 | - } else if ($this['AppName'] === 'core' && strpos($name, 'OC\\Core\\') === 0) { |
|
390 | - return parent::query($name); |
|
391 | - } |
|
392 | - } |
|
393 | - |
|
394 | - return $this->getServer()->query($name); |
|
395 | - } |
|
63 | + /** |
|
64 | + * @var array |
|
65 | + */ |
|
66 | + private $middleWares = array(); |
|
67 | + |
|
68 | + /** @var ServerContainer */ |
|
69 | + private $server; |
|
70 | + |
|
71 | + /** |
|
72 | + * Put your class dependencies in here |
|
73 | + * @param string $appName the name of the app |
|
74 | + * @param array $urlParams |
|
75 | + * @param ServerContainer $server |
|
76 | + */ |
|
77 | + public function __construct($appName, $urlParams = array(), ServerContainer $server = null){ |
|
78 | + parent::__construct(); |
|
79 | + $this['AppName'] = $appName; |
|
80 | + $this['urlParams'] = $urlParams; |
|
81 | + |
|
82 | + /** @var \OC\ServerContainer $server */ |
|
83 | + if ($server === null) { |
|
84 | + $server = \OC::$server; |
|
85 | + } |
|
86 | + $this->server = $server; |
|
87 | + $this->server->registerAppContainer($appName, $this); |
|
88 | + |
|
89 | + // aliases |
|
90 | + $this->registerAlias('appName', 'AppName'); |
|
91 | + $this->registerAlias('webRoot', 'WebRoot'); |
|
92 | + $this->registerAlias('userId', 'UserId'); |
|
93 | + |
|
94 | + /** |
|
95 | + * Core services |
|
96 | + */ |
|
97 | + $this->registerService(IOutput::class, function($c){ |
|
98 | + return new Output($this->getServer()->getWebRoot()); |
|
99 | + }); |
|
100 | + |
|
101 | + $this->registerService(Folder::class, function() { |
|
102 | + return $this->getServer()->getUserFolder(); |
|
103 | + }); |
|
104 | + |
|
105 | + $this->registerService(IAppData::class, function (SimpleContainer $c) { |
|
106 | + return $this->getServer()->getAppDataDir($c->query('AppName')); |
|
107 | + }); |
|
108 | + |
|
109 | + $this->registerService(IL10N::class, function($c) { |
|
110 | + return $this->getServer()->getL10N($c->query('AppName')); |
|
111 | + }); |
|
112 | + |
|
113 | + $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
114 | + $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
115 | + |
|
116 | + $this->registerService(IRequest::class, function() { |
|
117 | + return $this->getServer()->query(IRequest::class); |
|
118 | + }); |
|
119 | + $this->registerAlias('Request', IRequest::class); |
|
120 | + |
|
121 | + $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
122 | + $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
123 | + |
|
124 | + $this->registerAlias(\OC\User\Session::class, \OCP\IUserSession::class); |
|
125 | + |
|
126 | + $this->registerService(IServerContainer::class, function ($c) { |
|
127 | + return $this->getServer(); |
|
128 | + }); |
|
129 | + $this->registerAlias('ServerContainer', IServerContainer::class); |
|
130 | + |
|
131 | + $this->registerService(\OCP\WorkflowEngine\IManager::class, function ($c) { |
|
132 | + return $c->query('OCA\WorkflowEngine\Manager'); |
|
133 | + }); |
|
134 | + |
|
135 | + $this->registerService(\OCP\AppFramework\IAppContainer::class, function ($c) { |
|
136 | + return $c; |
|
137 | + }); |
|
138 | + |
|
139 | + // commonly used attributes |
|
140 | + $this->registerService('UserId', function ($c) { |
|
141 | + return $c->query('OCP\\IUserSession')->getSession()->get('user_id'); |
|
142 | + }); |
|
143 | + |
|
144 | + $this->registerService('WebRoot', function ($c) { |
|
145 | + return $c->query('ServerContainer')->getWebRoot(); |
|
146 | + }); |
|
147 | + |
|
148 | + $this->registerService('fromMailAddress', function() { |
|
149 | + return Util::getDefaultEmailAddress('no-reply'); |
|
150 | + }); |
|
151 | + |
|
152 | + $this->registerService('OC_Defaults', function ($c) { |
|
153 | + return $c->getServer()->getThemingDefaults(); |
|
154 | + }); |
|
155 | + |
|
156 | + $this->registerService('OCP\Encryption\IManager', function ($c) { |
|
157 | + return $this->getServer()->getEncryptionManager(); |
|
158 | + }); |
|
159 | + |
|
160 | + $this->registerService(IValidator::class, function($c) { |
|
161 | + return $c->query(Validator::class); |
|
162 | + }); |
|
163 | + |
|
164 | + $this->registerService(\OC\Security\IdentityProof\Manager::class, function ($c) { |
|
165 | + return new \OC\Security\IdentityProof\Manager( |
|
166 | + $this->getServer()->getAppDataDir('identityproof'), |
|
167 | + $this->getServer()->getCrypto() |
|
168 | + ); |
|
169 | + }); |
|
170 | + |
|
171 | + |
|
172 | + /** |
|
173 | + * App Framework APIs |
|
174 | + */ |
|
175 | + $this->registerService('API', function($c){ |
|
176 | + $c->query('OCP\\ILogger')->debug( |
|
177 | + 'Accessing the API class is deprecated! Use the appropriate ' . |
|
178 | + 'services instead!' |
|
179 | + ); |
|
180 | + return new API($c['AppName']); |
|
181 | + }); |
|
182 | + |
|
183 | + $this->registerService('Protocol', function($c){ |
|
184 | + /** @var \OC\Server $server */ |
|
185 | + $server = $c->query('ServerContainer'); |
|
186 | + $protocol = $server->getRequest()->getHttpProtocol(); |
|
187 | + return new Http($_SERVER, $protocol); |
|
188 | + }); |
|
189 | + |
|
190 | + $this->registerService('Dispatcher', function($c) { |
|
191 | + return new Dispatcher( |
|
192 | + $c['Protocol'], |
|
193 | + $c['MiddlewareDispatcher'], |
|
194 | + $c['ControllerMethodReflector'], |
|
195 | + $c['Request'] |
|
196 | + ); |
|
197 | + }); |
|
198 | + |
|
199 | + /** |
|
200 | + * App Framework default arguments |
|
201 | + */ |
|
202 | + $this->registerParameter('corsMethods', 'PUT, POST, GET, DELETE, PATCH'); |
|
203 | + $this->registerParameter('corsAllowedHeaders', 'Authorization, Content-Type, Accept'); |
|
204 | + $this->registerParameter('corsMaxAge', 1728000); |
|
205 | + |
|
206 | + /** |
|
207 | + * Middleware |
|
208 | + */ |
|
209 | + $app = $this; |
|
210 | + $this->registerService('SecurityMiddleware', function($c) use ($app){ |
|
211 | + /** @var \OC\Server $server */ |
|
212 | + $server = $app->getServer(); |
|
213 | + |
|
214 | + return new SecurityMiddleware( |
|
215 | + $c['Request'], |
|
216 | + $c['ControllerMethodReflector'], |
|
217 | + $server->getNavigationManager(), |
|
218 | + $server->getURLGenerator(), |
|
219 | + $server->getLogger(), |
|
220 | + $server->getSession(), |
|
221 | + $c['AppName'], |
|
222 | + $app->isLoggedIn(), |
|
223 | + $app->isAdminUser(), |
|
224 | + $server->getContentSecurityPolicyManager(), |
|
225 | + $server->getCsrfTokenManager(), |
|
226 | + $server->getContentSecurityPolicyNonceManager(), |
|
227 | + $server->getBruteForceThrottler() |
|
228 | + ); |
|
229 | + |
|
230 | + }); |
|
231 | + |
|
232 | + $this->registerService('CORSMiddleware', function($c) { |
|
233 | + return new CORSMiddleware( |
|
234 | + $c['Request'], |
|
235 | + $c['ControllerMethodReflector'], |
|
236 | + $c->query(IUserSession::class), |
|
237 | + $c->getServer()->getBruteForceThrottler() |
|
238 | + ); |
|
239 | + }); |
|
240 | + |
|
241 | + $this->registerService('SessionMiddleware', function($c) use ($app) { |
|
242 | + return new SessionMiddleware( |
|
243 | + $c['Request'], |
|
244 | + $c['ControllerMethodReflector'], |
|
245 | + $app->getServer()->getSession() |
|
246 | + ); |
|
247 | + }); |
|
248 | + |
|
249 | + $this->registerService('TwoFactorMiddleware', function (SimpleContainer $c) use ($app) { |
|
250 | + $twoFactorManager = $c->getServer()->getTwoFactorAuthManager(); |
|
251 | + $userSession = $app->getServer()->getUserSession(); |
|
252 | + $session = $app->getServer()->getSession(); |
|
253 | + $urlGenerator = $app->getServer()->getURLGenerator(); |
|
254 | + $reflector = $c['ControllerMethodReflector']; |
|
255 | + $request = $app->getServer()->getRequest(); |
|
256 | + return new TwoFactorMiddleware($twoFactorManager, $userSession, $session, $urlGenerator, $reflector, $request); |
|
257 | + }); |
|
258 | + |
|
259 | + $this->registerService('OCSMiddleware', function (SimpleContainer $c) { |
|
260 | + return new OCSMiddleware( |
|
261 | + $c['Request'] |
|
262 | + ); |
|
263 | + }); |
|
264 | + |
|
265 | + $middleWares = &$this->middleWares; |
|
266 | + $this->registerService('MiddlewareDispatcher', function($c) use (&$middleWares) { |
|
267 | + $dispatcher = new MiddlewareDispatcher(); |
|
268 | + $dispatcher->registerMiddleware($c['CORSMiddleware']); |
|
269 | + $dispatcher->registerMiddleware($c['OCSMiddleware']); |
|
270 | + $dispatcher->registerMiddleware($c['SecurityMiddleware']); |
|
271 | + $dispatcher->registerMiddleWare($c['TwoFactorMiddleware']); |
|
272 | + |
|
273 | + foreach($middleWares as $middleWare) { |
|
274 | + $dispatcher->registerMiddleware($c[$middleWare]); |
|
275 | + } |
|
276 | + |
|
277 | + $dispatcher->registerMiddleware($c['SessionMiddleware']); |
|
278 | + return $dispatcher; |
|
279 | + }); |
|
280 | + |
|
281 | + } |
|
282 | + |
|
283 | + |
|
284 | + /** |
|
285 | + * @deprecated implements only deprecated methods |
|
286 | + * @return IApi |
|
287 | + */ |
|
288 | + function getCoreApi() |
|
289 | + { |
|
290 | + return $this->query('API'); |
|
291 | + } |
|
292 | + |
|
293 | + /** |
|
294 | + * @return \OCP\IServerContainer |
|
295 | + */ |
|
296 | + function getServer() |
|
297 | + { |
|
298 | + return $this->server; |
|
299 | + } |
|
300 | + |
|
301 | + /** |
|
302 | + * @param string $middleWare |
|
303 | + * @return boolean|null |
|
304 | + */ |
|
305 | + function registerMiddleWare($middleWare) { |
|
306 | + array_push($this->middleWares, $middleWare); |
|
307 | + } |
|
308 | + |
|
309 | + /** |
|
310 | + * used to return the appname of the set application |
|
311 | + * @return string the name of your application |
|
312 | + */ |
|
313 | + function getAppName() { |
|
314 | + return $this->query('AppName'); |
|
315 | + } |
|
316 | + |
|
317 | + /** |
|
318 | + * @deprecated use IUserSession->isLoggedIn() |
|
319 | + * @return boolean |
|
320 | + */ |
|
321 | + function isLoggedIn() { |
|
322 | + return \OC::$server->getUserSession()->isLoggedIn(); |
|
323 | + } |
|
324 | + |
|
325 | + /** |
|
326 | + * @deprecated use IGroupManager->isAdmin($userId) |
|
327 | + * @return boolean |
|
328 | + */ |
|
329 | + function isAdminUser() { |
|
330 | + $uid = $this->getUserId(); |
|
331 | + return \OC_User::isAdminUser($uid); |
|
332 | + } |
|
333 | + |
|
334 | + private function getUserId() { |
|
335 | + return $this->getServer()->getSession()->get('user_id'); |
|
336 | + } |
|
337 | + |
|
338 | + /** |
|
339 | + * @deprecated use the ILogger instead |
|
340 | + * @param string $message |
|
341 | + * @param string $level |
|
342 | + * @return mixed |
|
343 | + */ |
|
344 | + function log($message, $level) { |
|
345 | + switch($level){ |
|
346 | + case 'debug': |
|
347 | + $level = \OCP\Util::DEBUG; |
|
348 | + break; |
|
349 | + case 'info': |
|
350 | + $level = \OCP\Util::INFO; |
|
351 | + break; |
|
352 | + case 'warn': |
|
353 | + $level = \OCP\Util::WARN; |
|
354 | + break; |
|
355 | + case 'fatal': |
|
356 | + $level = \OCP\Util::FATAL; |
|
357 | + break; |
|
358 | + default: |
|
359 | + $level = \OCP\Util::ERROR; |
|
360 | + break; |
|
361 | + } |
|
362 | + \OCP\Util::writeLog($this->getAppName(), $message, $level); |
|
363 | + } |
|
364 | + |
|
365 | + /** |
|
366 | + * Register a capability |
|
367 | + * |
|
368 | + * @param string $serviceName e.g. 'OCA\Files\Capabilities' |
|
369 | + */ |
|
370 | + public function registerCapability($serviceName) { |
|
371 | + $this->query('OC\CapabilitiesManager')->registerCapability(function() use ($serviceName) { |
|
372 | + return $this->query($serviceName); |
|
373 | + }); |
|
374 | + } |
|
375 | + |
|
376 | + public function query($name) { |
|
377 | + $name = $this->sanitizeName($name); |
|
378 | + |
|
379 | + if ($this->offsetExists($name)) { |
|
380 | + return parent::query($name); |
|
381 | + } else { |
|
382 | + if (strpos($name, 'OCA\\') === 0 && substr_count($name, '\\') >= 2) { |
|
383 | + $segments = explode('\\', $name); |
|
384 | + if (strtolower($segments[1]) === strtolower($this['AppName'])) { |
|
385 | + return parent::query($name); |
|
386 | + } |
|
387 | + } else if ($this['AppName'] === 'settings' && strpos($name, 'OC\\Settings\\') === 0) { |
|
388 | + return parent::query($name); |
|
389 | + } else if ($this['AppName'] === 'core' && strpos($name, 'OC\\Core\\') === 0) { |
|
390 | + return parent::query($name); |
|
391 | + } |
|
392 | + } |
|
393 | + |
|
394 | + return $this->getServer()->query($name); |
|
395 | + } |
|
396 | 396 | } |
@@ -115,1594 +115,1594 @@ |
||
115 | 115 | * TODO: hookup all manager classes |
116 | 116 | */ |
117 | 117 | class Server extends ServerContainer implements IServerContainer { |
118 | - /** @var string */ |
|
119 | - private $webRoot; |
|
120 | - |
|
121 | - /** |
|
122 | - * @param string $webRoot |
|
123 | - * @param \OC\Config $config |
|
124 | - */ |
|
125 | - public function __construct($webRoot, \OC\Config $config) { |
|
126 | - parent::__construct(); |
|
127 | - $this->webRoot = $webRoot; |
|
128 | - |
|
129 | - $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
130 | - $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
131 | - |
|
132 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
133 | - return new PreviewManager( |
|
134 | - $c->getConfig(), |
|
135 | - $c->getRootFolder(), |
|
136 | - $c->getAppDataDir('preview'), |
|
137 | - $c->getEventDispatcher(), |
|
138 | - $c->getSession()->get('user_id') |
|
139 | - ); |
|
140 | - }); |
|
141 | - $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
142 | - |
|
143 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
144 | - return new \OC\Preview\Watcher( |
|
145 | - $c->getAppDataDir('preview') |
|
146 | - ); |
|
147 | - }); |
|
148 | - |
|
149 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
150 | - $view = new View(); |
|
151 | - $util = new Encryption\Util( |
|
152 | - $view, |
|
153 | - $c->getUserManager(), |
|
154 | - $c->getGroupManager(), |
|
155 | - $c->getConfig() |
|
156 | - ); |
|
157 | - return new Encryption\Manager( |
|
158 | - $c->getConfig(), |
|
159 | - $c->getLogger(), |
|
160 | - $c->getL10N('core'), |
|
161 | - new View(), |
|
162 | - $util, |
|
163 | - new ArrayCache() |
|
164 | - ); |
|
165 | - }); |
|
166 | - |
|
167 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
168 | - $util = new Encryption\Util( |
|
169 | - new View(), |
|
170 | - $c->getUserManager(), |
|
171 | - $c->getGroupManager(), |
|
172 | - $c->getConfig() |
|
173 | - ); |
|
174 | - return new Encryption\File($util); |
|
175 | - }); |
|
176 | - |
|
177 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
178 | - $view = new View(); |
|
179 | - $util = new Encryption\Util( |
|
180 | - $view, |
|
181 | - $c->getUserManager(), |
|
182 | - $c->getGroupManager(), |
|
183 | - $c->getConfig() |
|
184 | - ); |
|
185 | - |
|
186 | - return new Encryption\Keys\Storage($view, $util); |
|
187 | - }); |
|
188 | - $this->registerService('TagMapper', function (Server $c) { |
|
189 | - return new TagMapper($c->getDatabaseConnection()); |
|
190 | - }); |
|
191 | - |
|
192 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
193 | - $tagMapper = $c->query('TagMapper'); |
|
194 | - return new TagManager($tagMapper, $c->getUserSession()); |
|
195 | - }); |
|
196 | - $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
197 | - |
|
198 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
199 | - $config = $c->getConfig(); |
|
200 | - $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
|
201 | - /** @var \OC\SystemTag\ManagerFactory $factory */ |
|
202 | - $factory = new $factoryClass($this); |
|
203 | - return $factory; |
|
204 | - }); |
|
205 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
206 | - return $c->query('SystemTagManagerFactory')->getManager(); |
|
207 | - }); |
|
208 | - $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
209 | - |
|
210 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
211 | - return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
212 | - }); |
|
213 | - $this->registerService('RootFolder', function (Server $c) { |
|
214 | - $manager = \OC\Files\Filesystem::getMountManager(null); |
|
215 | - $view = new View(); |
|
216 | - $root = new Root( |
|
217 | - $manager, |
|
218 | - $view, |
|
219 | - null, |
|
220 | - $c->getUserMountCache(), |
|
221 | - $this->getLogger(), |
|
222 | - $this->getUserManager() |
|
223 | - ); |
|
224 | - $connector = new HookConnector($root, $view); |
|
225 | - $connector->viewToNode(); |
|
226 | - |
|
227 | - $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
228 | - $previewConnector->connectWatcher(); |
|
229 | - |
|
230 | - return $root; |
|
231 | - }); |
|
232 | - $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
233 | - |
|
234 | - $this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) { |
|
235 | - return new LazyRoot(function() use ($c) { |
|
236 | - return $c->query('RootFolder'); |
|
237 | - }); |
|
238 | - }); |
|
239 | - $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
240 | - |
|
241 | - $this->registerService(\OCP\IUserManager::class, function (Server $c) { |
|
242 | - $config = $c->getConfig(); |
|
243 | - return new \OC\User\Manager($config); |
|
244 | - }); |
|
245 | - $this->registerAlias('UserManager', \OCP\IUserManager::class); |
|
246 | - |
|
247 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
248 | - $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
249 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
250 | - \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
251 | - }); |
|
252 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
253 | - \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
254 | - }); |
|
255 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
256 | - \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
257 | - }); |
|
258 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
259 | - \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
260 | - }); |
|
261 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
262 | - \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
263 | - }); |
|
264 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
265 | - \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
266 | - //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
267 | - \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
268 | - }); |
|
269 | - return $groupManager; |
|
270 | - }); |
|
271 | - $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
272 | - |
|
273 | - $this->registerService(Store::class, function(Server $c) { |
|
274 | - $session = $c->getSession(); |
|
275 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
276 | - $tokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
277 | - } else { |
|
278 | - $tokenProvider = null; |
|
279 | - } |
|
280 | - $logger = $c->getLogger(); |
|
281 | - return new Store($session, $logger, $tokenProvider); |
|
282 | - }); |
|
283 | - $this->registerAlias(IStore::class, Store::class); |
|
284 | - $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
285 | - $dbConnection = $c->getDatabaseConnection(); |
|
286 | - return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
287 | - }); |
|
288 | - $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
289 | - $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
|
290 | - $crypto = $c->getCrypto(); |
|
291 | - $config = $c->getConfig(); |
|
292 | - $logger = $c->getLogger(); |
|
293 | - $timeFactory = new TimeFactory(); |
|
294 | - return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
|
295 | - }); |
|
296 | - $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
|
297 | - |
|
298 | - $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
299 | - $manager = $c->getUserManager(); |
|
300 | - $session = new \OC\Session\Memory(''); |
|
301 | - $timeFactory = new TimeFactory(); |
|
302 | - // Token providers might require a working database. This code |
|
303 | - // might however be called when ownCloud is not yet setup. |
|
304 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
305 | - $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
306 | - } else { |
|
307 | - $defaultTokenProvider = null; |
|
308 | - } |
|
309 | - |
|
310 | - $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom()); |
|
311 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
312 | - \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
313 | - }); |
|
314 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
315 | - /** @var $user \OC\User\User */ |
|
316 | - \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
317 | - }); |
|
318 | - $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
319 | - /** @var $user \OC\User\User */ |
|
320 | - \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
321 | - }); |
|
322 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
323 | - /** @var $user \OC\User\User */ |
|
324 | - \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
325 | - }); |
|
326 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
327 | - /** @var $user \OC\User\User */ |
|
328 | - \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
329 | - }); |
|
330 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
331 | - /** @var $user \OC\User\User */ |
|
332 | - \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
333 | - }); |
|
334 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
335 | - \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
336 | - }); |
|
337 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
338 | - /** @var $user \OC\User\User */ |
|
339 | - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
340 | - }); |
|
341 | - $userSession->listen('\OC\User', 'logout', function () { |
|
342 | - \OC_Hook::emit('OC_User', 'logout', array()); |
|
343 | - }); |
|
344 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) { |
|
345 | - /** @var $user \OC\User\User */ |
|
346 | - \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value)); |
|
347 | - }); |
|
348 | - return $userSession; |
|
349 | - }); |
|
350 | - $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
351 | - |
|
352 | - $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
353 | - return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
|
354 | - }); |
|
355 | - |
|
356 | - $this->registerService(\OCP\INavigationManager::class, function (Server $c) { |
|
357 | - return new \OC\NavigationManager($c->getAppManager(), |
|
358 | - $c->getURLGenerator(), |
|
359 | - $c->getL10NFactory(), |
|
360 | - $c->getUserSession(), |
|
361 | - $c->getGroupManager()); |
|
362 | - }); |
|
363 | - $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
364 | - |
|
365 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
366 | - return new \OC\AllConfig( |
|
367 | - $c->getSystemConfig() |
|
368 | - ); |
|
369 | - }); |
|
370 | - $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
371 | - $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
372 | - |
|
373 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
374 | - return new \OC\SystemConfig($config); |
|
375 | - }); |
|
376 | - |
|
377 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
378 | - return new \OC\AppConfig($c->getDatabaseConnection()); |
|
379 | - }); |
|
380 | - $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
381 | - $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
382 | - |
|
383 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
384 | - return new \OC\L10N\Factory( |
|
385 | - $c->getConfig(), |
|
386 | - $c->getRequest(), |
|
387 | - $c->getUserSession(), |
|
388 | - \OC::$SERVERROOT |
|
389 | - ); |
|
390 | - }); |
|
391 | - $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
392 | - |
|
393 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
394 | - $config = $c->getConfig(); |
|
395 | - $cacheFactory = $c->getMemCacheFactory(); |
|
396 | - return new \OC\URLGenerator( |
|
397 | - $config, |
|
398 | - $cacheFactory |
|
399 | - ); |
|
400 | - }); |
|
401 | - $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
402 | - |
|
403 | - $this->registerService('AppHelper', function ($c) { |
|
404 | - return new \OC\AppHelper(); |
|
405 | - }); |
|
406 | - $this->registerService('AppFetcher', function ($c) { |
|
407 | - return new AppFetcher( |
|
408 | - $this->getAppDataDir('appstore'), |
|
409 | - $this->getHTTPClientService(), |
|
410 | - $this->query(TimeFactory::class), |
|
411 | - $this->getConfig() |
|
412 | - ); |
|
413 | - }); |
|
414 | - $this->registerService('CategoryFetcher', function ($c) { |
|
415 | - return new CategoryFetcher( |
|
416 | - $this->getAppDataDir('appstore'), |
|
417 | - $this->getHTTPClientService(), |
|
418 | - $this->query(TimeFactory::class), |
|
419 | - $this->getConfig() |
|
420 | - ); |
|
421 | - }); |
|
422 | - |
|
423 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
424 | - return new Cache\File(); |
|
425 | - }); |
|
426 | - $this->registerAlias('UserCache', \OCP\ICache::class); |
|
427 | - |
|
428 | - $this->registerService(Factory::class, function (Server $c) { |
|
429 | - $config = $c->getConfig(); |
|
430 | - |
|
431 | - if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
432 | - $v = \OC_App::getAppVersions(); |
|
433 | - $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
434 | - $version = implode(',', $v); |
|
435 | - $instanceId = \OC_Util::getInstanceId(); |
|
436 | - $path = \OC::$SERVERROOT; |
|
437 | - $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
438 | - return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
439 | - $config->getSystemValue('memcache.local', null), |
|
440 | - $config->getSystemValue('memcache.distributed', null), |
|
441 | - $config->getSystemValue('memcache.locking', null) |
|
442 | - ); |
|
443 | - } |
|
444 | - |
|
445 | - return new \OC\Memcache\Factory('', $c->getLogger(), |
|
446 | - '\\OC\\Memcache\\ArrayCache', |
|
447 | - '\\OC\\Memcache\\ArrayCache', |
|
448 | - '\\OC\\Memcache\\ArrayCache' |
|
449 | - ); |
|
450 | - }); |
|
451 | - $this->registerAlias('MemCacheFactory', Factory::class); |
|
452 | - $this->registerAlias(ICacheFactory::class, Factory::class); |
|
453 | - |
|
454 | - $this->registerService('RedisFactory', function (Server $c) { |
|
455 | - $systemConfig = $c->getSystemConfig(); |
|
456 | - return new RedisFactory($systemConfig); |
|
457 | - }); |
|
458 | - |
|
459 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
460 | - return new \OC\Activity\Manager( |
|
461 | - $c->getRequest(), |
|
462 | - $c->getUserSession(), |
|
463 | - $c->getConfig(), |
|
464 | - $c->query(IValidator::class) |
|
465 | - ); |
|
466 | - }); |
|
467 | - $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
468 | - |
|
469 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
470 | - return new \OC\Activity\EventMerger( |
|
471 | - $c->getL10N('lib') |
|
472 | - ); |
|
473 | - }); |
|
474 | - $this->registerAlias(IValidator::class, Validator::class); |
|
475 | - |
|
476 | - $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
477 | - return new AvatarManager( |
|
478 | - $c->getUserManager(), |
|
479 | - $c->getAppDataDir('avatar'), |
|
480 | - $c->getL10N('lib'), |
|
481 | - $c->getLogger(), |
|
482 | - $c->getConfig() |
|
483 | - ); |
|
484 | - }); |
|
485 | - $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
486 | - |
|
487 | - $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
488 | - $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
489 | - $logger = Log::getLogClass($logType); |
|
490 | - call_user_func(array($logger, 'init')); |
|
491 | - |
|
492 | - return new Log($logger); |
|
493 | - }); |
|
494 | - $this->registerAlias('Logger', \OCP\ILogger::class); |
|
495 | - |
|
496 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
497 | - $config = $c->getConfig(); |
|
498 | - return new \OC\BackgroundJob\JobList( |
|
499 | - $c->getDatabaseConnection(), |
|
500 | - $config, |
|
501 | - new TimeFactory() |
|
502 | - ); |
|
503 | - }); |
|
504 | - $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
505 | - |
|
506 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
507 | - $cacheFactory = $c->getMemCacheFactory(); |
|
508 | - $logger = $c->getLogger(); |
|
509 | - if ($cacheFactory->isAvailable()) { |
|
510 | - $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger); |
|
511 | - } else { |
|
512 | - $router = new \OC\Route\Router($logger); |
|
513 | - } |
|
514 | - return $router; |
|
515 | - }); |
|
516 | - $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
517 | - |
|
518 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
519 | - return new Search(); |
|
520 | - }); |
|
521 | - $this->registerAlias('Search', \OCP\ISearch::class); |
|
522 | - |
|
523 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
524 | - return new SecureRandom(); |
|
525 | - }); |
|
526 | - $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
527 | - |
|
528 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
529 | - return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
530 | - }); |
|
531 | - $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
532 | - |
|
533 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
534 | - return new Hasher($c->getConfig()); |
|
535 | - }); |
|
536 | - $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
537 | - |
|
538 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
539 | - return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
540 | - }); |
|
541 | - $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
542 | - |
|
543 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
544 | - $systemConfig = $c->getSystemConfig(); |
|
545 | - $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
546 | - $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
547 | - if (!$factory->isValidType($type)) { |
|
548 | - throw new \OC\DatabaseException('Invalid database type'); |
|
549 | - } |
|
550 | - $connectionParams = $factory->createConnectionParams(); |
|
551 | - $connection = $factory->getConnection($type, $connectionParams); |
|
552 | - $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
553 | - return $connection; |
|
554 | - }); |
|
555 | - $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
556 | - |
|
557 | - $this->registerService('HTTPHelper', function (Server $c) { |
|
558 | - $config = $c->getConfig(); |
|
559 | - return new HTTPHelper( |
|
560 | - $config, |
|
561 | - $c->getHTTPClientService() |
|
562 | - ); |
|
563 | - }); |
|
564 | - |
|
565 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
566 | - $user = \OC_User::getUser(); |
|
567 | - $uid = $user ? $user : null; |
|
568 | - return new ClientService( |
|
569 | - $c->getConfig(), |
|
570 | - new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger()) |
|
571 | - ); |
|
572 | - }); |
|
573 | - $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
574 | - |
|
575 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
576 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
577 | - return new EventLogger(); |
|
578 | - } else { |
|
579 | - return new NullEventLogger(); |
|
580 | - } |
|
581 | - }); |
|
582 | - $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
583 | - |
|
584 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
585 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
586 | - return new QueryLogger(); |
|
587 | - } else { |
|
588 | - return new NullQueryLogger(); |
|
589 | - } |
|
590 | - }); |
|
591 | - $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
592 | - |
|
593 | - $this->registerService(TempManager::class, function (Server $c) { |
|
594 | - return new TempManager( |
|
595 | - $c->getLogger(), |
|
596 | - $c->getConfig() |
|
597 | - ); |
|
598 | - }); |
|
599 | - $this->registerAlias('TempManager', TempManager::class); |
|
600 | - $this->registerAlias(ITempManager::class, TempManager::class); |
|
601 | - |
|
602 | - $this->registerService(AppManager::class, function (Server $c) { |
|
603 | - return new \OC\App\AppManager( |
|
604 | - $c->getUserSession(), |
|
605 | - $c->getAppConfig(), |
|
606 | - $c->getGroupManager(), |
|
607 | - $c->getMemCacheFactory(), |
|
608 | - $c->getEventDispatcher() |
|
609 | - ); |
|
610 | - }); |
|
611 | - $this->registerAlias('AppManager', AppManager::class); |
|
612 | - $this->registerAlias(IAppManager::class, AppManager::class); |
|
613 | - |
|
614 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
615 | - return new DateTimeZone( |
|
616 | - $c->getConfig(), |
|
617 | - $c->getSession() |
|
618 | - ); |
|
619 | - }); |
|
620 | - $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
621 | - |
|
622 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
623 | - $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
624 | - |
|
625 | - return new DateTimeFormatter( |
|
626 | - $c->getDateTimeZone()->getTimeZone(), |
|
627 | - $c->getL10N('lib', $language) |
|
628 | - ); |
|
629 | - }); |
|
630 | - $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
631 | - |
|
632 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
633 | - $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
634 | - $listener = new UserMountCacheListener($mountCache); |
|
635 | - $listener->listen($c->getUserManager()); |
|
636 | - return $mountCache; |
|
637 | - }); |
|
638 | - $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
639 | - |
|
640 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
641 | - $loader = \OC\Files\Filesystem::getLoader(); |
|
642 | - $mountCache = $c->query('UserMountCache'); |
|
643 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
644 | - |
|
645 | - // builtin providers |
|
646 | - |
|
647 | - $config = $c->getConfig(); |
|
648 | - $manager->registerProvider(new CacheMountProvider($config)); |
|
649 | - $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
650 | - $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
651 | - |
|
652 | - return $manager; |
|
653 | - }); |
|
654 | - $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
655 | - |
|
656 | - $this->registerService('IniWrapper', function ($c) { |
|
657 | - return new IniGetWrapper(); |
|
658 | - }); |
|
659 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
660 | - $jobList = $c->getJobList(); |
|
661 | - return new AsyncBus($jobList); |
|
662 | - }); |
|
663 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
664 | - return new TrustedDomainHelper($this->getConfig()); |
|
665 | - }); |
|
666 | - $this->registerService('Throttler', function(Server $c) { |
|
667 | - return new Throttler( |
|
668 | - $c->getDatabaseConnection(), |
|
669 | - new TimeFactory(), |
|
670 | - $c->getLogger(), |
|
671 | - $c->getConfig() |
|
672 | - ); |
|
673 | - }); |
|
674 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
675 | - // IConfig and IAppManager requires a working database. This code |
|
676 | - // might however be called when ownCloud is not yet setup. |
|
677 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
678 | - $config = $c->getConfig(); |
|
679 | - $appManager = $c->getAppManager(); |
|
680 | - } else { |
|
681 | - $config = null; |
|
682 | - $appManager = null; |
|
683 | - } |
|
684 | - |
|
685 | - return new Checker( |
|
686 | - new EnvironmentHelper(), |
|
687 | - new FileAccessHelper(), |
|
688 | - new AppLocator(), |
|
689 | - $config, |
|
690 | - $c->getMemCacheFactory(), |
|
691 | - $appManager, |
|
692 | - $c->getTempManager() |
|
693 | - ); |
|
694 | - }); |
|
695 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
696 | - if (isset($this['urlParams'])) { |
|
697 | - $urlParams = $this['urlParams']; |
|
698 | - } else { |
|
699 | - $urlParams = []; |
|
700 | - } |
|
701 | - |
|
702 | - if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
703 | - && in_array('fakeinput', stream_get_wrappers()) |
|
704 | - ) { |
|
705 | - $stream = 'fakeinput://data'; |
|
706 | - } else { |
|
707 | - $stream = 'php://input'; |
|
708 | - } |
|
709 | - |
|
710 | - return new Request( |
|
711 | - [ |
|
712 | - 'get' => $_GET, |
|
713 | - 'post' => $_POST, |
|
714 | - 'files' => $_FILES, |
|
715 | - 'server' => $_SERVER, |
|
716 | - 'env' => $_ENV, |
|
717 | - 'cookies' => $_COOKIE, |
|
718 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
719 | - ? $_SERVER['REQUEST_METHOD'] |
|
720 | - : null, |
|
721 | - 'urlParams' => $urlParams, |
|
722 | - ], |
|
723 | - $this->getSecureRandom(), |
|
724 | - $this->getConfig(), |
|
725 | - $this->getCsrfTokenManager(), |
|
726 | - $stream |
|
727 | - ); |
|
728 | - }); |
|
729 | - $this->registerAlias('Request', \OCP\IRequest::class); |
|
730 | - |
|
731 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
732 | - return new Mailer( |
|
733 | - $c->getConfig(), |
|
734 | - $c->getLogger(), |
|
735 | - $c->getThemingDefaults() |
|
736 | - ); |
|
737 | - }); |
|
738 | - $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
739 | - |
|
740 | - $this->registerService('LDAPProvider', function(Server $c) { |
|
741 | - $config = $c->getConfig(); |
|
742 | - $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
743 | - if(is_null($factoryClass)) { |
|
744 | - throw new \Exception('ldapProviderFactory not set'); |
|
745 | - } |
|
746 | - /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
747 | - $factory = new $factoryClass($this); |
|
748 | - return $factory->getLDAPProvider(); |
|
749 | - }); |
|
750 | - $this->registerService('LockingProvider', function (Server $c) { |
|
751 | - $ini = $c->getIniWrapper(); |
|
752 | - $config = $c->getConfig(); |
|
753 | - $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
754 | - if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
755 | - /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
756 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
757 | - $memcache = $memcacheFactory->createLocking('lock'); |
|
758 | - if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
759 | - return new MemcacheLockingProvider($memcache, $ttl); |
|
760 | - } |
|
761 | - return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl); |
|
762 | - } |
|
763 | - return new NoopLockingProvider(); |
|
764 | - }); |
|
765 | - |
|
766 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
767 | - return new \OC\Files\Mount\Manager(); |
|
768 | - }); |
|
769 | - $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
770 | - |
|
771 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
772 | - return new \OC\Files\Type\Detection( |
|
773 | - $c->getURLGenerator(), |
|
774 | - \OC::$configDir, |
|
775 | - \OC::$SERVERROOT . '/resources/config/' |
|
776 | - ); |
|
777 | - }); |
|
778 | - $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
779 | - |
|
780 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
781 | - return new \OC\Files\Type\Loader( |
|
782 | - $c->getDatabaseConnection() |
|
783 | - ); |
|
784 | - }); |
|
785 | - $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
786 | - |
|
787 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
788 | - return new Manager( |
|
789 | - $c->query(IValidator::class) |
|
790 | - ); |
|
791 | - }); |
|
792 | - $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
793 | - |
|
794 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
795 | - $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
796 | - $manager->registerCapability(function () use ($c) { |
|
797 | - return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
798 | - }); |
|
799 | - return $manager; |
|
800 | - }); |
|
801 | - $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
802 | - |
|
803 | - $this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) { |
|
804 | - $config = $c->getConfig(); |
|
805 | - $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); |
|
806 | - /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
807 | - $factory = new $factoryClass($this); |
|
808 | - return $factory->getManager(); |
|
809 | - }); |
|
810 | - $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
811 | - |
|
812 | - $this->registerService('ThemingDefaults', function(Server $c) { |
|
813 | - /* |
|
118 | + /** @var string */ |
|
119 | + private $webRoot; |
|
120 | + |
|
121 | + /** |
|
122 | + * @param string $webRoot |
|
123 | + * @param \OC\Config $config |
|
124 | + */ |
|
125 | + public function __construct($webRoot, \OC\Config $config) { |
|
126 | + parent::__construct(); |
|
127 | + $this->webRoot = $webRoot; |
|
128 | + |
|
129 | + $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
130 | + $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
131 | + |
|
132 | + $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
133 | + return new PreviewManager( |
|
134 | + $c->getConfig(), |
|
135 | + $c->getRootFolder(), |
|
136 | + $c->getAppDataDir('preview'), |
|
137 | + $c->getEventDispatcher(), |
|
138 | + $c->getSession()->get('user_id') |
|
139 | + ); |
|
140 | + }); |
|
141 | + $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
142 | + |
|
143 | + $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
144 | + return new \OC\Preview\Watcher( |
|
145 | + $c->getAppDataDir('preview') |
|
146 | + ); |
|
147 | + }); |
|
148 | + |
|
149 | + $this->registerService('EncryptionManager', function (Server $c) { |
|
150 | + $view = new View(); |
|
151 | + $util = new Encryption\Util( |
|
152 | + $view, |
|
153 | + $c->getUserManager(), |
|
154 | + $c->getGroupManager(), |
|
155 | + $c->getConfig() |
|
156 | + ); |
|
157 | + return new Encryption\Manager( |
|
158 | + $c->getConfig(), |
|
159 | + $c->getLogger(), |
|
160 | + $c->getL10N('core'), |
|
161 | + new View(), |
|
162 | + $util, |
|
163 | + new ArrayCache() |
|
164 | + ); |
|
165 | + }); |
|
166 | + |
|
167 | + $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
168 | + $util = new Encryption\Util( |
|
169 | + new View(), |
|
170 | + $c->getUserManager(), |
|
171 | + $c->getGroupManager(), |
|
172 | + $c->getConfig() |
|
173 | + ); |
|
174 | + return new Encryption\File($util); |
|
175 | + }); |
|
176 | + |
|
177 | + $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
178 | + $view = new View(); |
|
179 | + $util = new Encryption\Util( |
|
180 | + $view, |
|
181 | + $c->getUserManager(), |
|
182 | + $c->getGroupManager(), |
|
183 | + $c->getConfig() |
|
184 | + ); |
|
185 | + |
|
186 | + return new Encryption\Keys\Storage($view, $util); |
|
187 | + }); |
|
188 | + $this->registerService('TagMapper', function (Server $c) { |
|
189 | + return new TagMapper($c->getDatabaseConnection()); |
|
190 | + }); |
|
191 | + |
|
192 | + $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
193 | + $tagMapper = $c->query('TagMapper'); |
|
194 | + return new TagManager($tagMapper, $c->getUserSession()); |
|
195 | + }); |
|
196 | + $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
197 | + |
|
198 | + $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
199 | + $config = $c->getConfig(); |
|
200 | + $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
|
201 | + /** @var \OC\SystemTag\ManagerFactory $factory */ |
|
202 | + $factory = new $factoryClass($this); |
|
203 | + return $factory; |
|
204 | + }); |
|
205 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
206 | + return $c->query('SystemTagManagerFactory')->getManager(); |
|
207 | + }); |
|
208 | + $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
209 | + |
|
210 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
211 | + return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
212 | + }); |
|
213 | + $this->registerService('RootFolder', function (Server $c) { |
|
214 | + $manager = \OC\Files\Filesystem::getMountManager(null); |
|
215 | + $view = new View(); |
|
216 | + $root = new Root( |
|
217 | + $manager, |
|
218 | + $view, |
|
219 | + null, |
|
220 | + $c->getUserMountCache(), |
|
221 | + $this->getLogger(), |
|
222 | + $this->getUserManager() |
|
223 | + ); |
|
224 | + $connector = new HookConnector($root, $view); |
|
225 | + $connector->viewToNode(); |
|
226 | + |
|
227 | + $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
228 | + $previewConnector->connectWatcher(); |
|
229 | + |
|
230 | + return $root; |
|
231 | + }); |
|
232 | + $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
233 | + |
|
234 | + $this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) { |
|
235 | + return new LazyRoot(function() use ($c) { |
|
236 | + return $c->query('RootFolder'); |
|
237 | + }); |
|
238 | + }); |
|
239 | + $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
240 | + |
|
241 | + $this->registerService(\OCP\IUserManager::class, function (Server $c) { |
|
242 | + $config = $c->getConfig(); |
|
243 | + return new \OC\User\Manager($config); |
|
244 | + }); |
|
245 | + $this->registerAlias('UserManager', \OCP\IUserManager::class); |
|
246 | + |
|
247 | + $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
248 | + $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
249 | + $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
250 | + \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
251 | + }); |
|
252 | + $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
253 | + \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
254 | + }); |
|
255 | + $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
256 | + \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
257 | + }); |
|
258 | + $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
259 | + \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
260 | + }); |
|
261 | + $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
262 | + \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
263 | + }); |
|
264 | + $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
265 | + \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
266 | + //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
267 | + \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
268 | + }); |
|
269 | + return $groupManager; |
|
270 | + }); |
|
271 | + $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
272 | + |
|
273 | + $this->registerService(Store::class, function(Server $c) { |
|
274 | + $session = $c->getSession(); |
|
275 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
276 | + $tokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
277 | + } else { |
|
278 | + $tokenProvider = null; |
|
279 | + } |
|
280 | + $logger = $c->getLogger(); |
|
281 | + return new Store($session, $logger, $tokenProvider); |
|
282 | + }); |
|
283 | + $this->registerAlias(IStore::class, Store::class); |
|
284 | + $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
285 | + $dbConnection = $c->getDatabaseConnection(); |
|
286 | + return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
287 | + }); |
|
288 | + $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
289 | + $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
|
290 | + $crypto = $c->getCrypto(); |
|
291 | + $config = $c->getConfig(); |
|
292 | + $logger = $c->getLogger(); |
|
293 | + $timeFactory = new TimeFactory(); |
|
294 | + return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
|
295 | + }); |
|
296 | + $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
|
297 | + |
|
298 | + $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
299 | + $manager = $c->getUserManager(); |
|
300 | + $session = new \OC\Session\Memory(''); |
|
301 | + $timeFactory = new TimeFactory(); |
|
302 | + // Token providers might require a working database. This code |
|
303 | + // might however be called when ownCloud is not yet setup. |
|
304 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
305 | + $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
306 | + } else { |
|
307 | + $defaultTokenProvider = null; |
|
308 | + } |
|
309 | + |
|
310 | + $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom()); |
|
311 | + $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
312 | + \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
313 | + }); |
|
314 | + $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
315 | + /** @var $user \OC\User\User */ |
|
316 | + \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
317 | + }); |
|
318 | + $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
319 | + /** @var $user \OC\User\User */ |
|
320 | + \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
321 | + }); |
|
322 | + $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
323 | + /** @var $user \OC\User\User */ |
|
324 | + \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
325 | + }); |
|
326 | + $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
327 | + /** @var $user \OC\User\User */ |
|
328 | + \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
329 | + }); |
|
330 | + $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
331 | + /** @var $user \OC\User\User */ |
|
332 | + \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
333 | + }); |
|
334 | + $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
335 | + \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
336 | + }); |
|
337 | + $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
338 | + /** @var $user \OC\User\User */ |
|
339 | + \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
340 | + }); |
|
341 | + $userSession->listen('\OC\User', 'logout', function () { |
|
342 | + \OC_Hook::emit('OC_User', 'logout', array()); |
|
343 | + }); |
|
344 | + $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) { |
|
345 | + /** @var $user \OC\User\User */ |
|
346 | + \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value)); |
|
347 | + }); |
|
348 | + return $userSession; |
|
349 | + }); |
|
350 | + $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
351 | + |
|
352 | + $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
353 | + return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
|
354 | + }); |
|
355 | + |
|
356 | + $this->registerService(\OCP\INavigationManager::class, function (Server $c) { |
|
357 | + return new \OC\NavigationManager($c->getAppManager(), |
|
358 | + $c->getURLGenerator(), |
|
359 | + $c->getL10NFactory(), |
|
360 | + $c->getUserSession(), |
|
361 | + $c->getGroupManager()); |
|
362 | + }); |
|
363 | + $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
364 | + |
|
365 | + $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
366 | + return new \OC\AllConfig( |
|
367 | + $c->getSystemConfig() |
|
368 | + ); |
|
369 | + }); |
|
370 | + $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
371 | + $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
372 | + |
|
373 | + $this->registerService('SystemConfig', function ($c) use ($config) { |
|
374 | + return new \OC\SystemConfig($config); |
|
375 | + }); |
|
376 | + |
|
377 | + $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
378 | + return new \OC\AppConfig($c->getDatabaseConnection()); |
|
379 | + }); |
|
380 | + $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
381 | + $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
382 | + |
|
383 | + $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
384 | + return new \OC\L10N\Factory( |
|
385 | + $c->getConfig(), |
|
386 | + $c->getRequest(), |
|
387 | + $c->getUserSession(), |
|
388 | + \OC::$SERVERROOT |
|
389 | + ); |
|
390 | + }); |
|
391 | + $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
392 | + |
|
393 | + $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
394 | + $config = $c->getConfig(); |
|
395 | + $cacheFactory = $c->getMemCacheFactory(); |
|
396 | + return new \OC\URLGenerator( |
|
397 | + $config, |
|
398 | + $cacheFactory |
|
399 | + ); |
|
400 | + }); |
|
401 | + $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
402 | + |
|
403 | + $this->registerService('AppHelper', function ($c) { |
|
404 | + return new \OC\AppHelper(); |
|
405 | + }); |
|
406 | + $this->registerService('AppFetcher', function ($c) { |
|
407 | + return new AppFetcher( |
|
408 | + $this->getAppDataDir('appstore'), |
|
409 | + $this->getHTTPClientService(), |
|
410 | + $this->query(TimeFactory::class), |
|
411 | + $this->getConfig() |
|
412 | + ); |
|
413 | + }); |
|
414 | + $this->registerService('CategoryFetcher', function ($c) { |
|
415 | + return new CategoryFetcher( |
|
416 | + $this->getAppDataDir('appstore'), |
|
417 | + $this->getHTTPClientService(), |
|
418 | + $this->query(TimeFactory::class), |
|
419 | + $this->getConfig() |
|
420 | + ); |
|
421 | + }); |
|
422 | + |
|
423 | + $this->registerService(\OCP\ICache::class, function ($c) { |
|
424 | + return new Cache\File(); |
|
425 | + }); |
|
426 | + $this->registerAlias('UserCache', \OCP\ICache::class); |
|
427 | + |
|
428 | + $this->registerService(Factory::class, function (Server $c) { |
|
429 | + $config = $c->getConfig(); |
|
430 | + |
|
431 | + if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
432 | + $v = \OC_App::getAppVersions(); |
|
433 | + $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
434 | + $version = implode(',', $v); |
|
435 | + $instanceId = \OC_Util::getInstanceId(); |
|
436 | + $path = \OC::$SERVERROOT; |
|
437 | + $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
438 | + return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
439 | + $config->getSystemValue('memcache.local', null), |
|
440 | + $config->getSystemValue('memcache.distributed', null), |
|
441 | + $config->getSystemValue('memcache.locking', null) |
|
442 | + ); |
|
443 | + } |
|
444 | + |
|
445 | + return new \OC\Memcache\Factory('', $c->getLogger(), |
|
446 | + '\\OC\\Memcache\\ArrayCache', |
|
447 | + '\\OC\\Memcache\\ArrayCache', |
|
448 | + '\\OC\\Memcache\\ArrayCache' |
|
449 | + ); |
|
450 | + }); |
|
451 | + $this->registerAlias('MemCacheFactory', Factory::class); |
|
452 | + $this->registerAlias(ICacheFactory::class, Factory::class); |
|
453 | + |
|
454 | + $this->registerService('RedisFactory', function (Server $c) { |
|
455 | + $systemConfig = $c->getSystemConfig(); |
|
456 | + return new RedisFactory($systemConfig); |
|
457 | + }); |
|
458 | + |
|
459 | + $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
460 | + return new \OC\Activity\Manager( |
|
461 | + $c->getRequest(), |
|
462 | + $c->getUserSession(), |
|
463 | + $c->getConfig(), |
|
464 | + $c->query(IValidator::class) |
|
465 | + ); |
|
466 | + }); |
|
467 | + $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
468 | + |
|
469 | + $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
470 | + return new \OC\Activity\EventMerger( |
|
471 | + $c->getL10N('lib') |
|
472 | + ); |
|
473 | + }); |
|
474 | + $this->registerAlias(IValidator::class, Validator::class); |
|
475 | + |
|
476 | + $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
477 | + return new AvatarManager( |
|
478 | + $c->getUserManager(), |
|
479 | + $c->getAppDataDir('avatar'), |
|
480 | + $c->getL10N('lib'), |
|
481 | + $c->getLogger(), |
|
482 | + $c->getConfig() |
|
483 | + ); |
|
484 | + }); |
|
485 | + $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
486 | + |
|
487 | + $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
488 | + $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
489 | + $logger = Log::getLogClass($logType); |
|
490 | + call_user_func(array($logger, 'init')); |
|
491 | + |
|
492 | + return new Log($logger); |
|
493 | + }); |
|
494 | + $this->registerAlias('Logger', \OCP\ILogger::class); |
|
495 | + |
|
496 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
497 | + $config = $c->getConfig(); |
|
498 | + return new \OC\BackgroundJob\JobList( |
|
499 | + $c->getDatabaseConnection(), |
|
500 | + $config, |
|
501 | + new TimeFactory() |
|
502 | + ); |
|
503 | + }); |
|
504 | + $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
505 | + |
|
506 | + $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
507 | + $cacheFactory = $c->getMemCacheFactory(); |
|
508 | + $logger = $c->getLogger(); |
|
509 | + if ($cacheFactory->isAvailable()) { |
|
510 | + $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger); |
|
511 | + } else { |
|
512 | + $router = new \OC\Route\Router($logger); |
|
513 | + } |
|
514 | + return $router; |
|
515 | + }); |
|
516 | + $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
517 | + |
|
518 | + $this->registerService(\OCP\ISearch::class, function ($c) { |
|
519 | + return new Search(); |
|
520 | + }); |
|
521 | + $this->registerAlias('Search', \OCP\ISearch::class); |
|
522 | + |
|
523 | + $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
524 | + return new SecureRandom(); |
|
525 | + }); |
|
526 | + $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
527 | + |
|
528 | + $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
529 | + return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
530 | + }); |
|
531 | + $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
532 | + |
|
533 | + $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
534 | + return new Hasher($c->getConfig()); |
|
535 | + }); |
|
536 | + $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
537 | + |
|
538 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
539 | + return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
540 | + }); |
|
541 | + $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
542 | + |
|
543 | + $this->registerService(IDBConnection::class, function (Server $c) { |
|
544 | + $systemConfig = $c->getSystemConfig(); |
|
545 | + $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
546 | + $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
547 | + if (!$factory->isValidType($type)) { |
|
548 | + throw new \OC\DatabaseException('Invalid database type'); |
|
549 | + } |
|
550 | + $connectionParams = $factory->createConnectionParams(); |
|
551 | + $connection = $factory->getConnection($type, $connectionParams); |
|
552 | + $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
553 | + return $connection; |
|
554 | + }); |
|
555 | + $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
556 | + |
|
557 | + $this->registerService('HTTPHelper', function (Server $c) { |
|
558 | + $config = $c->getConfig(); |
|
559 | + return new HTTPHelper( |
|
560 | + $config, |
|
561 | + $c->getHTTPClientService() |
|
562 | + ); |
|
563 | + }); |
|
564 | + |
|
565 | + $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
566 | + $user = \OC_User::getUser(); |
|
567 | + $uid = $user ? $user : null; |
|
568 | + return new ClientService( |
|
569 | + $c->getConfig(), |
|
570 | + new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger()) |
|
571 | + ); |
|
572 | + }); |
|
573 | + $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
574 | + |
|
575 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
576 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
577 | + return new EventLogger(); |
|
578 | + } else { |
|
579 | + return new NullEventLogger(); |
|
580 | + } |
|
581 | + }); |
|
582 | + $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
583 | + |
|
584 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
585 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
586 | + return new QueryLogger(); |
|
587 | + } else { |
|
588 | + return new NullQueryLogger(); |
|
589 | + } |
|
590 | + }); |
|
591 | + $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
592 | + |
|
593 | + $this->registerService(TempManager::class, function (Server $c) { |
|
594 | + return new TempManager( |
|
595 | + $c->getLogger(), |
|
596 | + $c->getConfig() |
|
597 | + ); |
|
598 | + }); |
|
599 | + $this->registerAlias('TempManager', TempManager::class); |
|
600 | + $this->registerAlias(ITempManager::class, TempManager::class); |
|
601 | + |
|
602 | + $this->registerService(AppManager::class, function (Server $c) { |
|
603 | + return new \OC\App\AppManager( |
|
604 | + $c->getUserSession(), |
|
605 | + $c->getAppConfig(), |
|
606 | + $c->getGroupManager(), |
|
607 | + $c->getMemCacheFactory(), |
|
608 | + $c->getEventDispatcher() |
|
609 | + ); |
|
610 | + }); |
|
611 | + $this->registerAlias('AppManager', AppManager::class); |
|
612 | + $this->registerAlias(IAppManager::class, AppManager::class); |
|
613 | + |
|
614 | + $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
615 | + return new DateTimeZone( |
|
616 | + $c->getConfig(), |
|
617 | + $c->getSession() |
|
618 | + ); |
|
619 | + }); |
|
620 | + $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
621 | + |
|
622 | + $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
623 | + $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
624 | + |
|
625 | + return new DateTimeFormatter( |
|
626 | + $c->getDateTimeZone()->getTimeZone(), |
|
627 | + $c->getL10N('lib', $language) |
|
628 | + ); |
|
629 | + }); |
|
630 | + $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
631 | + |
|
632 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
633 | + $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
634 | + $listener = new UserMountCacheListener($mountCache); |
|
635 | + $listener->listen($c->getUserManager()); |
|
636 | + return $mountCache; |
|
637 | + }); |
|
638 | + $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
639 | + |
|
640 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
641 | + $loader = \OC\Files\Filesystem::getLoader(); |
|
642 | + $mountCache = $c->query('UserMountCache'); |
|
643 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
644 | + |
|
645 | + // builtin providers |
|
646 | + |
|
647 | + $config = $c->getConfig(); |
|
648 | + $manager->registerProvider(new CacheMountProvider($config)); |
|
649 | + $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
650 | + $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
651 | + |
|
652 | + return $manager; |
|
653 | + }); |
|
654 | + $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
655 | + |
|
656 | + $this->registerService('IniWrapper', function ($c) { |
|
657 | + return new IniGetWrapper(); |
|
658 | + }); |
|
659 | + $this->registerService('AsyncCommandBus', function (Server $c) { |
|
660 | + $jobList = $c->getJobList(); |
|
661 | + return new AsyncBus($jobList); |
|
662 | + }); |
|
663 | + $this->registerService('TrustedDomainHelper', function ($c) { |
|
664 | + return new TrustedDomainHelper($this->getConfig()); |
|
665 | + }); |
|
666 | + $this->registerService('Throttler', function(Server $c) { |
|
667 | + return new Throttler( |
|
668 | + $c->getDatabaseConnection(), |
|
669 | + new TimeFactory(), |
|
670 | + $c->getLogger(), |
|
671 | + $c->getConfig() |
|
672 | + ); |
|
673 | + }); |
|
674 | + $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
675 | + // IConfig and IAppManager requires a working database. This code |
|
676 | + // might however be called when ownCloud is not yet setup. |
|
677 | + if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
678 | + $config = $c->getConfig(); |
|
679 | + $appManager = $c->getAppManager(); |
|
680 | + } else { |
|
681 | + $config = null; |
|
682 | + $appManager = null; |
|
683 | + } |
|
684 | + |
|
685 | + return new Checker( |
|
686 | + new EnvironmentHelper(), |
|
687 | + new FileAccessHelper(), |
|
688 | + new AppLocator(), |
|
689 | + $config, |
|
690 | + $c->getMemCacheFactory(), |
|
691 | + $appManager, |
|
692 | + $c->getTempManager() |
|
693 | + ); |
|
694 | + }); |
|
695 | + $this->registerService(\OCP\IRequest::class, function ($c) { |
|
696 | + if (isset($this['urlParams'])) { |
|
697 | + $urlParams = $this['urlParams']; |
|
698 | + } else { |
|
699 | + $urlParams = []; |
|
700 | + } |
|
701 | + |
|
702 | + if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
703 | + && in_array('fakeinput', stream_get_wrappers()) |
|
704 | + ) { |
|
705 | + $stream = 'fakeinput://data'; |
|
706 | + } else { |
|
707 | + $stream = 'php://input'; |
|
708 | + } |
|
709 | + |
|
710 | + return new Request( |
|
711 | + [ |
|
712 | + 'get' => $_GET, |
|
713 | + 'post' => $_POST, |
|
714 | + 'files' => $_FILES, |
|
715 | + 'server' => $_SERVER, |
|
716 | + 'env' => $_ENV, |
|
717 | + 'cookies' => $_COOKIE, |
|
718 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
719 | + ? $_SERVER['REQUEST_METHOD'] |
|
720 | + : null, |
|
721 | + 'urlParams' => $urlParams, |
|
722 | + ], |
|
723 | + $this->getSecureRandom(), |
|
724 | + $this->getConfig(), |
|
725 | + $this->getCsrfTokenManager(), |
|
726 | + $stream |
|
727 | + ); |
|
728 | + }); |
|
729 | + $this->registerAlias('Request', \OCP\IRequest::class); |
|
730 | + |
|
731 | + $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
732 | + return new Mailer( |
|
733 | + $c->getConfig(), |
|
734 | + $c->getLogger(), |
|
735 | + $c->getThemingDefaults() |
|
736 | + ); |
|
737 | + }); |
|
738 | + $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
739 | + |
|
740 | + $this->registerService('LDAPProvider', function(Server $c) { |
|
741 | + $config = $c->getConfig(); |
|
742 | + $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
743 | + if(is_null($factoryClass)) { |
|
744 | + throw new \Exception('ldapProviderFactory not set'); |
|
745 | + } |
|
746 | + /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
747 | + $factory = new $factoryClass($this); |
|
748 | + return $factory->getLDAPProvider(); |
|
749 | + }); |
|
750 | + $this->registerService('LockingProvider', function (Server $c) { |
|
751 | + $ini = $c->getIniWrapper(); |
|
752 | + $config = $c->getConfig(); |
|
753 | + $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
754 | + if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
755 | + /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
756 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
757 | + $memcache = $memcacheFactory->createLocking('lock'); |
|
758 | + if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
759 | + return new MemcacheLockingProvider($memcache, $ttl); |
|
760 | + } |
|
761 | + return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl); |
|
762 | + } |
|
763 | + return new NoopLockingProvider(); |
|
764 | + }); |
|
765 | + |
|
766 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
767 | + return new \OC\Files\Mount\Manager(); |
|
768 | + }); |
|
769 | + $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
770 | + |
|
771 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
772 | + return new \OC\Files\Type\Detection( |
|
773 | + $c->getURLGenerator(), |
|
774 | + \OC::$configDir, |
|
775 | + \OC::$SERVERROOT . '/resources/config/' |
|
776 | + ); |
|
777 | + }); |
|
778 | + $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
779 | + |
|
780 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
781 | + return new \OC\Files\Type\Loader( |
|
782 | + $c->getDatabaseConnection() |
|
783 | + ); |
|
784 | + }); |
|
785 | + $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
786 | + |
|
787 | + $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
788 | + return new Manager( |
|
789 | + $c->query(IValidator::class) |
|
790 | + ); |
|
791 | + }); |
|
792 | + $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
793 | + |
|
794 | + $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
795 | + $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
796 | + $manager->registerCapability(function () use ($c) { |
|
797 | + return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
798 | + }); |
|
799 | + return $manager; |
|
800 | + }); |
|
801 | + $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
802 | + |
|
803 | + $this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) { |
|
804 | + $config = $c->getConfig(); |
|
805 | + $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); |
|
806 | + /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
807 | + $factory = new $factoryClass($this); |
|
808 | + return $factory->getManager(); |
|
809 | + }); |
|
810 | + $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
811 | + |
|
812 | + $this->registerService('ThemingDefaults', function(Server $c) { |
|
813 | + /* |
|
814 | 814 | * Dark magic for autoloader. |
815 | 815 | * If we do a class_exists it will try to load the class which will |
816 | 816 | * make composer cache the result. Resulting in errors when enabling |
817 | 817 | * the theming app. |
818 | 818 | */ |
819 | - $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
820 | - if (isset($prefixes['OCA\\Theming\\'])) { |
|
821 | - $classExists = true; |
|
822 | - } else { |
|
823 | - $classExists = false; |
|
824 | - } |
|
825 | - |
|
826 | - if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) { |
|
827 | - return new ThemingDefaults( |
|
828 | - $c->getConfig(), |
|
829 | - $c->getL10N('theming'), |
|
830 | - $c->getURLGenerator(), |
|
831 | - new \OC_Defaults(), |
|
832 | - $c->getLazyRootFolder(), |
|
833 | - $c->getMemCacheFactory() |
|
834 | - ); |
|
835 | - } |
|
836 | - return new \OC_Defaults(); |
|
837 | - }); |
|
838 | - $this->registerService(EventDispatcher::class, function () { |
|
839 | - return new EventDispatcher(); |
|
840 | - }); |
|
841 | - $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
842 | - $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
843 | - |
|
844 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
845 | - // FIXME: Instantiiated here due to cyclic dependency |
|
846 | - $request = new Request( |
|
847 | - [ |
|
848 | - 'get' => $_GET, |
|
849 | - 'post' => $_POST, |
|
850 | - 'files' => $_FILES, |
|
851 | - 'server' => $_SERVER, |
|
852 | - 'env' => $_ENV, |
|
853 | - 'cookies' => $_COOKIE, |
|
854 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
855 | - ? $_SERVER['REQUEST_METHOD'] |
|
856 | - : null, |
|
857 | - ], |
|
858 | - $c->getSecureRandom(), |
|
859 | - $c->getConfig() |
|
860 | - ); |
|
861 | - |
|
862 | - return new CryptoWrapper( |
|
863 | - $c->getConfig(), |
|
864 | - $c->getCrypto(), |
|
865 | - $c->getSecureRandom(), |
|
866 | - $request |
|
867 | - ); |
|
868 | - }); |
|
869 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
870 | - $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
871 | - |
|
872 | - return new CsrfTokenManager( |
|
873 | - $tokenGenerator, |
|
874 | - $c->query(SessionStorage::class) |
|
875 | - ); |
|
876 | - }); |
|
877 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
878 | - return new SessionStorage($c->getSession()); |
|
879 | - }); |
|
880 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
881 | - return new ContentSecurityPolicyManager(); |
|
882 | - }); |
|
883 | - $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
884 | - |
|
885 | - $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) { |
|
886 | - return new ContentSecurityPolicyNonceManager( |
|
887 | - $c->getCsrfTokenManager(), |
|
888 | - $c->getRequest() |
|
889 | - ); |
|
890 | - }); |
|
891 | - |
|
892 | - $this->registerService(\OCP\Share\IManager::class, function(Server $c) { |
|
893 | - $config = $c->getConfig(); |
|
894 | - $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory'); |
|
895 | - /** @var \OCP\Share\IProviderFactory $factory */ |
|
896 | - $factory = new $factoryClass($this); |
|
897 | - |
|
898 | - $manager = new \OC\Share20\Manager( |
|
899 | - $c->getLogger(), |
|
900 | - $c->getConfig(), |
|
901 | - $c->getSecureRandom(), |
|
902 | - $c->getHasher(), |
|
903 | - $c->getMountManager(), |
|
904 | - $c->getGroupManager(), |
|
905 | - $c->getL10N('core'), |
|
906 | - $factory, |
|
907 | - $c->getUserManager(), |
|
908 | - $c->getLazyRootFolder(), |
|
909 | - $c->getEventDispatcher() |
|
910 | - ); |
|
911 | - |
|
912 | - return $manager; |
|
913 | - }); |
|
914 | - $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
915 | - |
|
916 | - $this->registerService('SettingsManager', function(Server $c) { |
|
917 | - $manager = new \OC\Settings\Manager( |
|
918 | - $c->getLogger(), |
|
919 | - $c->getDatabaseConnection(), |
|
920 | - $c->getL10N('lib'), |
|
921 | - $c->getConfig(), |
|
922 | - $c->getEncryptionManager(), |
|
923 | - $c->getUserManager(), |
|
924 | - $c->getLockingProvider(), |
|
925 | - $c->getRequest(), |
|
926 | - new \OC\Settings\Mapper($c->getDatabaseConnection()), |
|
927 | - $c->getURLGenerator() |
|
928 | - ); |
|
929 | - return $manager; |
|
930 | - }); |
|
931 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
932 | - return new \OC\Files\AppData\Factory( |
|
933 | - $c->getRootFolder(), |
|
934 | - $c->getSystemConfig() |
|
935 | - ); |
|
936 | - }); |
|
937 | - |
|
938 | - $this->registerService('LockdownManager', function (Server $c) { |
|
939 | - return new LockdownManager(); |
|
940 | - }); |
|
941 | - |
|
942 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
943 | - return new CloudIdManager(); |
|
944 | - }); |
|
945 | - |
|
946 | - /* To trick DI since we don't extend the DIContainer here */ |
|
947 | - $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
948 | - return new CleanPreviewsBackgroundJob( |
|
949 | - $c->getRootFolder(), |
|
950 | - $c->getLogger(), |
|
951 | - $c->getJobList(), |
|
952 | - new TimeFactory() |
|
953 | - ); |
|
954 | - }); |
|
955 | - |
|
956 | - $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
957 | - $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
958 | - |
|
959 | - $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
960 | - $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
961 | - |
|
962 | - $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) { |
|
963 | - return $c->query(\OCP\IUserSession::class)->getSession(); |
|
964 | - }); |
|
965 | - } |
|
966 | - |
|
967 | - /** |
|
968 | - * @return \OCP\Contacts\IManager |
|
969 | - */ |
|
970 | - public function getContactsManager() { |
|
971 | - return $this->query('ContactsManager'); |
|
972 | - } |
|
973 | - |
|
974 | - /** |
|
975 | - * @return \OC\Encryption\Manager |
|
976 | - */ |
|
977 | - public function getEncryptionManager() { |
|
978 | - return $this->query('EncryptionManager'); |
|
979 | - } |
|
980 | - |
|
981 | - /** |
|
982 | - * @return \OC\Encryption\File |
|
983 | - */ |
|
984 | - public function getEncryptionFilesHelper() { |
|
985 | - return $this->query('EncryptionFileHelper'); |
|
986 | - } |
|
987 | - |
|
988 | - /** |
|
989 | - * @return \OCP\Encryption\Keys\IStorage |
|
990 | - */ |
|
991 | - public function getEncryptionKeyStorage() { |
|
992 | - return $this->query('EncryptionKeyStorage'); |
|
993 | - } |
|
994 | - |
|
995 | - /** |
|
996 | - * The current request object holding all information about the request |
|
997 | - * currently being processed is returned from this method. |
|
998 | - * In case the current execution was not initiated by a web request null is returned |
|
999 | - * |
|
1000 | - * @return \OCP\IRequest |
|
1001 | - */ |
|
1002 | - public function getRequest() { |
|
1003 | - return $this->query('Request'); |
|
1004 | - } |
|
1005 | - |
|
1006 | - /** |
|
1007 | - * Returns the preview manager which can create preview images for a given file |
|
1008 | - * |
|
1009 | - * @return \OCP\IPreview |
|
1010 | - */ |
|
1011 | - public function getPreviewManager() { |
|
1012 | - return $this->query('PreviewManager'); |
|
1013 | - } |
|
1014 | - |
|
1015 | - /** |
|
1016 | - * Returns the tag manager which can get and set tags for different object types |
|
1017 | - * |
|
1018 | - * @see \OCP\ITagManager::load() |
|
1019 | - * @return \OCP\ITagManager |
|
1020 | - */ |
|
1021 | - public function getTagManager() { |
|
1022 | - return $this->query('TagManager'); |
|
1023 | - } |
|
1024 | - |
|
1025 | - /** |
|
1026 | - * Returns the system-tag manager |
|
1027 | - * |
|
1028 | - * @return \OCP\SystemTag\ISystemTagManager |
|
1029 | - * |
|
1030 | - * @since 9.0.0 |
|
1031 | - */ |
|
1032 | - public function getSystemTagManager() { |
|
1033 | - return $this->query('SystemTagManager'); |
|
1034 | - } |
|
1035 | - |
|
1036 | - /** |
|
1037 | - * Returns the system-tag object mapper |
|
1038 | - * |
|
1039 | - * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
1040 | - * |
|
1041 | - * @since 9.0.0 |
|
1042 | - */ |
|
1043 | - public function getSystemTagObjectMapper() { |
|
1044 | - return $this->query('SystemTagObjectMapper'); |
|
1045 | - } |
|
1046 | - |
|
1047 | - /** |
|
1048 | - * Returns the avatar manager, used for avatar functionality |
|
1049 | - * |
|
1050 | - * @return \OCP\IAvatarManager |
|
1051 | - */ |
|
1052 | - public function getAvatarManager() { |
|
1053 | - return $this->query('AvatarManager'); |
|
1054 | - } |
|
1055 | - |
|
1056 | - /** |
|
1057 | - * Returns the root folder of ownCloud's data directory |
|
1058 | - * |
|
1059 | - * @return \OCP\Files\IRootFolder |
|
1060 | - */ |
|
1061 | - public function getRootFolder() { |
|
1062 | - return $this->query('LazyRootFolder'); |
|
1063 | - } |
|
1064 | - |
|
1065 | - /** |
|
1066 | - * Returns the root folder of ownCloud's data directory |
|
1067 | - * This is the lazy variant so this gets only initialized once it |
|
1068 | - * is actually used. |
|
1069 | - * |
|
1070 | - * @return \OCP\Files\IRootFolder |
|
1071 | - */ |
|
1072 | - public function getLazyRootFolder() { |
|
1073 | - return $this->query('LazyRootFolder'); |
|
1074 | - } |
|
1075 | - |
|
1076 | - /** |
|
1077 | - * Returns a view to ownCloud's files folder |
|
1078 | - * |
|
1079 | - * @param string $userId user ID |
|
1080 | - * @return \OCP\Files\Folder|null |
|
1081 | - */ |
|
1082 | - public function getUserFolder($userId = null) { |
|
1083 | - if ($userId === null) { |
|
1084 | - $user = $this->getUserSession()->getUser(); |
|
1085 | - if (!$user) { |
|
1086 | - return null; |
|
1087 | - } |
|
1088 | - $userId = $user->getUID(); |
|
1089 | - } |
|
1090 | - $root = $this->getRootFolder(); |
|
1091 | - return $root->getUserFolder($userId); |
|
1092 | - } |
|
1093 | - |
|
1094 | - /** |
|
1095 | - * Returns an app-specific view in ownClouds data directory |
|
1096 | - * |
|
1097 | - * @return \OCP\Files\Folder |
|
1098 | - * @deprecated since 9.2.0 use IAppData |
|
1099 | - */ |
|
1100 | - public function getAppFolder() { |
|
1101 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
1102 | - $root = $this->getRootFolder(); |
|
1103 | - if (!$root->nodeExists($dir)) { |
|
1104 | - $folder = $root->newFolder($dir); |
|
1105 | - } else { |
|
1106 | - $folder = $root->get($dir); |
|
1107 | - } |
|
1108 | - return $folder; |
|
1109 | - } |
|
1110 | - |
|
1111 | - /** |
|
1112 | - * @return \OC\User\Manager |
|
1113 | - */ |
|
1114 | - public function getUserManager() { |
|
1115 | - return $this->query('UserManager'); |
|
1116 | - } |
|
1117 | - |
|
1118 | - /** |
|
1119 | - * @return \OC\Group\Manager |
|
1120 | - */ |
|
1121 | - public function getGroupManager() { |
|
1122 | - return $this->query('GroupManager'); |
|
1123 | - } |
|
1124 | - |
|
1125 | - /** |
|
1126 | - * @return \OC\User\Session |
|
1127 | - */ |
|
1128 | - public function getUserSession() { |
|
1129 | - return $this->query('UserSession'); |
|
1130 | - } |
|
1131 | - |
|
1132 | - /** |
|
1133 | - * @return \OCP\ISession |
|
1134 | - */ |
|
1135 | - public function getSession() { |
|
1136 | - return $this->query('UserSession')->getSession(); |
|
1137 | - } |
|
1138 | - |
|
1139 | - /** |
|
1140 | - * @param \OCP\ISession $session |
|
1141 | - */ |
|
1142 | - public function setSession(\OCP\ISession $session) { |
|
1143 | - $this->query(SessionStorage::class)->setSession($session); |
|
1144 | - $this->query('UserSession')->setSession($session); |
|
1145 | - $this->query(Store::class)->setSession($session); |
|
1146 | - } |
|
1147 | - |
|
1148 | - /** |
|
1149 | - * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1150 | - */ |
|
1151 | - public function getTwoFactorAuthManager() { |
|
1152 | - return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1153 | - } |
|
1154 | - |
|
1155 | - /** |
|
1156 | - * @return \OC\NavigationManager |
|
1157 | - */ |
|
1158 | - public function getNavigationManager() { |
|
1159 | - return $this->query('NavigationManager'); |
|
1160 | - } |
|
1161 | - |
|
1162 | - /** |
|
1163 | - * @return \OCP\IConfig |
|
1164 | - */ |
|
1165 | - public function getConfig() { |
|
1166 | - return $this->query('AllConfig'); |
|
1167 | - } |
|
1168 | - |
|
1169 | - /** |
|
1170 | - * @internal For internal use only |
|
1171 | - * @return \OC\SystemConfig |
|
1172 | - */ |
|
1173 | - public function getSystemConfig() { |
|
1174 | - return $this->query('SystemConfig'); |
|
1175 | - } |
|
1176 | - |
|
1177 | - /** |
|
1178 | - * Returns the app config manager |
|
1179 | - * |
|
1180 | - * @return \OCP\IAppConfig |
|
1181 | - */ |
|
1182 | - public function getAppConfig() { |
|
1183 | - return $this->query('AppConfig'); |
|
1184 | - } |
|
1185 | - |
|
1186 | - /** |
|
1187 | - * @return \OCP\L10N\IFactory |
|
1188 | - */ |
|
1189 | - public function getL10NFactory() { |
|
1190 | - return $this->query('L10NFactory'); |
|
1191 | - } |
|
1192 | - |
|
1193 | - /** |
|
1194 | - * get an L10N instance |
|
1195 | - * |
|
1196 | - * @param string $app appid |
|
1197 | - * @param string $lang |
|
1198 | - * @return IL10N |
|
1199 | - */ |
|
1200 | - public function getL10N($app, $lang = null) { |
|
1201 | - return $this->getL10NFactory()->get($app, $lang); |
|
1202 | - } |
|
1203 | - |
|
1204 | - /** |
|
1205 | - * @return \OCP\IURLGenerator |
|
1206 | - */ |
|
1207 | - public function getURLGenerator() { |
|
1208 | - return $this->query('URLGenerator'); |
|
1209 | - } |
|
1210 | - |
|
1211 | - /** |
|
1212 | - * @return \OCP\IHelper |
|
1213 | - */ |
|
1214 | - public function getHelper() { |
|
1215 | - return $this->query('AppHelper'); |
|
1216 | - } |
|
1217 | - |
|
1218 | - /** |
|
1219 | - * @return AppFetcher |
|
1220 | - */ |
|
1221 | - public function getAppFetcher() { |
|
1222 | - return $this->query('AppFetcher'); |
|
1223 | - } |
|
1224 | - |
|
1225 | - /** |
|
1226 | - * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1227 | - * getMemCacheFactory() instead. |
|
1228 | - * |
|
1229 | - * @return \OCP\ICache |
|
1230 | - * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1231 | - */ |
|
1232 | - public function getCache() { |
|
1233 | - return $this->query('UserCache'); |
|
1234 | - } |
|
1235 | - |
|
1236 | - /** |
|
1237 | - * Returns an \OCP\CacheFactory instance |
|
1238 | - * |
|
1239 | - * @return \OCP\ICacheFactory |
|
1240 | - */ |
|
1241 | - public function getMemCacheFactory() { |
|
1242 | - return $this->query('MemCacheFactory'); |
|
1243 | - } |
|
1244 | - |
|
1245 | - /** |
|
1246 | - * Returns an \OC\RedisFactory instance |
|
1247 | - * |
|
1248 | - * @return \OC\RedisFactory |
|
1249 | - */ |
|
1250 | - public function getGetRedisFactory() { |
|
1251 | - return $this->query('RedisFactory'); |
|
1252 | - } |
|
1253 | - |
|
1254 | - |
|
1255 | - /** |
|
1256 | - * Returns the current session |
|
1257 | - * |
|
1258 | - * @return \OCP\IDBConnection |
|
1259 | - */ |
|
1260 | - public function getDatabaseConnection() { |
|
1261 | - return $this->query('DatabaseConnection'); |
|
1262 | - } |
|
1263 | - |
|
1264 | - /** |
|
1265 | - * Returns the activity manager |
|
1266 | - * |
|
1267 | - * @return \OCP\Activity\IManager |
|
1268 | - */ |
|
1269 | - public function getActivityManager() { |
|
1270 | - return $this->query('ActivityManager'); |
|
1271 | - } |
|
1272 | - |
|
1273 | - /** |
|
1274 | - * Returns an job list for controlling background jobs |
|
1275 | - * |
|
1276 | - * @return \OCP\BackgroundJob\IJobList |
|
1277 | - */ |
|
1278 | - public function getJobList() { |
|
1279 | - return $this->query('JobList'); |
|
1280 | - } |
|
1281 | - |
|
1282 | - /** |
|
1283 | - * Returns a logger instance |
|
1284 | - * |
|
1285 | - * @return \OCP\ILogger |
|
1286 | - */ |
|
1287 | - public function getLogger() { |
|
1288 | - return $this->query('Logger'); |
|
1289 | - } |
|
1290 | - |
|
1291 | - /** |
|
1292 | - * Returns a router for generating and matching urls |
|
1293 | - * |
|
1294 | - * @return \OCP\Route\IRouter |
|
1295 | - */ |
|
1296 | - public function getRouter() { |
|
1297 | - return $this->query('Router'); |
|
1298 | - } |
|
1299 | - |
|
1300 | - /** |
|
1301 | - * Returns a search instance |
|
1302 | - * |
|
1303 | - * @return \OCP\ISearch |
|
1304 | - */ |
|
1305 | - public function getSearch() { |
|
1306 | - return $this->query('Search'); |
|
1307 | - } |
|
1308 | - |
|
1309 | - /** |
|
1310 | - * Returns a SecureRandom instance |
|
1311 | - * |
|
1312 | - * @return \OCP\Security\ISecureRandom |
|
1313 | - */ |
|
1314 | - public function getSecureRandom() { |
|
1315 | - return $this->query('SecureRandom'); |
|
1316 | - } |
|
1317 | - |
|
1318 | - /** |
|
1319 | - * Returns a Crypto instance |
|
1320 | - * |
|
1321 | - * @return \OCP\Security\ICrypto |
|
1322 | - */ |
|
1323 | - public function getCrypto() { |
|
1324 | - return $this->query('Crypto'); |
|
1325 | - } |
|
1326 | - |
|
1327 | - /** |
|
1328 | - * Returns a Hasher instance |
|
1329 | - * |
|
1330 | - * @return \OCP\Security\IHasher |
|
1331 | - */ |
|
1332 | - public function getHasher() { |
|
1333 | - return $this->query('Hasher'); |
|
1334 | - } |
|
1335 | - |
|
1336 | - /** |
|
1337 | - * Returns a CredentialsManager instance |
|
1338 | - * |
|
1339 | - * @return \OCP\Security\ICredentialsManager |
|
1340 | - */ |
|
1341 | - public function getCredentialsManager() { |
|
1342 | - return $this->query('CredentialsManager'); |
|
1343 | - } |
|
1344 | - |
|
1345 | - /** |
|
1346 | - * Returns an instance of the HTTP helper class |
|
1347 | - * |
|
1348 | - * @deprecated Use getHTTPClientService() |
|
1349 | - * @return \OC\HTTPHelper |
|
1350 | - */ |
|
1351 | - public function getHTTPHelper() { |
|
1352 | - return $this->query('HTTPHelper'); |
|
1353 | - } |
|
1354 | - |
|
1355 | - /** |
|
1356 | - * Get the certificate manager for the user |
|
1357 | - * |
|
1358 | - * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1359 | - * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1360 | - */ |
|
1361 | - public function getCertificateManager($userId = '') { |
|
1362 | - if ($userId === '') { |
|
1363 | - $userSession = $this->getUserSession(); |
|
1364 | - $user = $userSession->getUser(); |
|
1365 | - if (is_null($user)) { |
|
1366 | - return null; |
|
1367 | - } |
|
1368 | - $userId = $user->getUID(); |
|
1369 | - } |
|
1370 | - return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger()); |
|
1371 | - } |
|
1372 | - |
|
1373 | - /** |
|
1374 | - * Returns an instance of the HTTP client service |
|
1375 | - * |
|
1376 | - * @return \OCP\Http\Client\IClientService |
|
1377 | - */ |
|
1378 | - public function getHTTPClientService() { |
|
1379 | - return $this->query('HttpClientService'); |
|
1380 | - } |
|
1381 | - |
|
1382 | - /** |
|
1383 | - * Create a new event source |
|
1384 | - * |
|
1385 | - * @return \OCP\IEventSource |
|
1386 | - */ |
|
1387 | - public function createEventSource() { |
|
1388 | - return new \OC_EventSource(); |
|
1389 | - } |
|
1390 | - |
|
1391 | - /** |
|
1392 | - * Get the active event logger |
|
1393 | - * |
|
1394 | - * The returned logger only logs data when debug mode is enabled |
|
1395 | - * |
|
1396 | - * @return \OCP\Diagnostics\IEventLogger |
|
1397 | - */ |
|
1398 | - public function getEventLogger() { |
|
1399 | - return $this->query('EventLogger'); |
|
1400 | - } |
|
1401 | - |
|
1402 | - /** |
|
1403 | - * Get the active query logger |
|
1404 | - * |
|
1405 | - * The returned logger only logs data when debug mode is enabled |
|
1406 | - * |
|
1407 | - * @return \OCP\Diagnostics\IQueryLogger |
|
1408 | - */ |
|
1409 | - public function getQueryLogger() { |
|
1410 | - return $this->query('QueryLogger'); |
|
1411 | - } |
|
1412 | - |
|
1413 | - /** |
|
1414 | - * Get the manager for temporary files and folders |
|
1415 | - * |
|
1416 | - * @return \OCP\ITempManager |
|
1417 | - */ |
|
1418 | - public function getTempManager() { |
|
1419 | - return $this->query('TempManager'); |
|
1420 | - } |
|
1421 | - |
|
1422 | - /** |
|
1423 | - * Get the app manager |
|
1424 | - * |
|
1425 | - * @return \OCP\App\IAppManager |
|
1426 | - */ |
|
1427 | - public function getAppManager() { |
|
1428 | - return $this->query('AppManager'); |
|
1429 | - } |
|
1430 | - |
|
1431 | - /** |
|
1432 | - * Creates a new mailer |
|
1433 | - * |
|
1434 | - * @return \OCP\Mail\IMailer |
|
1435 | - */ |
|
1436 | - public function getMailer() { |
|
1437 | - return $this->query('Mailer'); |
|
1438 | - } |
|
1439 | - |
|
1440 | - /** |
|
1441 | - * Get the webroot |
|
1442 | - * |
|
1443 | - * @return string |
|
1444 | - */ |
|
1445 | - public function getWebRoot() { |
|
1446 | - return $this->webRoot; |
|
1447 | - } |
|
1448 | - |
|
1449 | - /** |
|
1450 | - * @return \OC\OCSClient |
|
1451 | - */ |
|
1452 | - public function getOcsClient() { |
|
1453 | - return $this->query('OcsClient'); |
|
1454 | - } |
|
1455 | - |
|
1456 | - /** |
|
1457 | - * @return \OCP\IDateTimeZone |
|
1458 | - */ |
|
1459 | - public function getDateTimeZone() { |
|
1460 | - return $this->query('DateTimeZone'); |
|
1461 | - } |
|
1462 | - |
|
1463 | - /** |
|
1464 | - * @return \OCP\IDateTimeFormatter |
|
1465 | - */ |
|
1466 | - public function getDateTimeFormatter() { |
|
1467 | - return $this->query('DateTimeFormatter'); |
|
1468 | - } |
|
1469 | - |
|
1470 | - /** |
|
1471 | - * @return \OCP\Files\Config\IMountProviderCollection |
|
1472 | - */ |
|
1473 | - public function getMountProviderCollection() { |
|
1474 | - return $this->query('MountConfigManager'); |
|
1475 | - } |
|
1476 | - |
|
1477 | - /** |
|
1478 | - * Get the IniWrapper |
|
1479 | - * |
|
1480 | - * @return IniGetWrapper |
|
1481 | - */ |
|
1482 | - public function getIniWrapper() { |
|
1483 | - return $this->query('IniWrapper'); |
|
1484 | - } |
|
1485 | - |
|
1486 | - /** |
|
1487 | - * @return \OCP\Command\IBus |
|
1488 | - */ |
|
1489 | - public function getCommandBus() { |
|
1490 | - return $this->query('AsyncCommandBus'); |
|
1491 | - } |
|
1492 | - |
|
1493 | - /** |
|
1494 | - * Get the trusted domain helper |
|
1495 | - * |
|
1496 | - * @return TrustedDomainHelper |
|
1497 | - */ |
|
1498 | - public function getTrustedDomainHelper() { |
|
1499 | - return $this->query('TrustedDomainHelper'); |
|
1500 | - } |
|
1501 | - |
|
1502 | - /** |
|
1503 | - * Get the locking provider |
|
1504 | - * |
|
1505 | - * @return \OCP\Lock\ILockingProvider |
|
1506 | - * @since 8.1.0 |
|
1507 | - */ |
|
1508 | - public function getLockingProvider() { |
|
1509 | - return $this->query('LockingProvider'); |
|
1510 | - } |
|
1511 | - |
|
1512 | - /** |
|
1513 | - * @return \OCP\Files\Mount\IMountManager |
|
1514 | - **/ |
|
1515 | - function getMountManager() { |
|
1516 | - return $this->query('MountManager'); |
|
1517 | - } |
|
1518 | - |
|
1519 | - /** @return \OCP\Files\Config\IUserMountCache */ |
|
1520 | - function getUserMountCache() { |
|
1521 | - return $this->query('UserMountCache'); |
|
1522 | - } |
|
1523 | - |
|
1524 | - /** |
|
1525 | - * Get the MimeTypeDetector |
|
1526 | - * |
|
1527 | - * @return \OCP\Files\IMimeTypeDetector |
|
1528 | - */ |
|
1529 | - public function getMimeTypeDetector() { |
|
1530 | - return $this->query('MimeTypeDetector'); |
|
1531 | - } |
|
1532 | - |
|
1533 | - /** |
|
1534 | - * Get the MimeTypeLoader |
|
1535 | - * |
|
1536 | - * @return \OCP\Files\IMimeTypeLoader |
|
1537 | - */ |
|
1538 | - public function getMimeTypeLoader() { |
|
1539 | - return $this->query('MimeTypeLoader'); |
|
1540 | - } |
|
1541 | - |
|
1542 | - /** |
|
1543 | - * Get the manager of all the capabilities |
|
1544 | - * |
|
1545 | - * @return \OC\CapabilitiesManager |
|
1546 | - */ |
|
1547 | - public function getCapabilitiesManager() { |
|
1548 | - return $this->query('CapabilitiesManager'); |
|
1549 | - } |
|
1550 | - |
|
1551 | - /** |
|
1552 | - * Get the EventDispatcher |
|
1553 | - * |
|
1554 | - * @return EventDispatcherInterface |
|
1555 | - * @since 8.2.0 |
|
1556 | - */ |
|
1557 | - public function getEventDispatcher() { |
|
1558 | - return $this->query('EventDispatcher'); |
|
1559 | - } |
|
1560 | - |
|
1561 | - /** |
|
1562 | - * Get the Notification Manager |
|
1563 | - * |
|
1564 | - * @return \OCP\Notification\IManager |
|
1565 | - * @since 8.2.0 |
|
1566 | - */ |
|
1567 | - public function getNotificationManager() { |
|
1568 | - return $this->query('NotificationManager'); |
|
1569 | - } |
|
1570 | - |
|
1571 | - /** |
|
1572 | - * @return \OCP\Comments\ICommentsManager |
|
1573 | - */ |
|
1574 | - public function getCommentsManager() { |
|
1575 | - return $this->query('CommentsManager'); |
|
1576 | - } |
|
1577 | - |
|
1578 | - /** |
|
1579 | - * @return \OC_Defaults |
|
1580 | - */ |
|
1581 | - public function getThemingDefaults() { |
|
1582 | - return $this->query('ThemingDefaults'); |
|
1583 | - } |
|
1584 | - |
|
1585 | - /** |
|
1586 | - * @return \OC\IntegrityCheck\Checker |
|
1587 | - */ |
|
1588 | - public function getIntegrityCodeChecker() { |
|
1589 | - return $this->query('IntegrityCodeChecker'); |
|
1590 | - } |
|
1591 | - |
|
1592 | - /** |
|
1593 | - * @return \OC\Session\CryptoWrapper |
|
1594 | - */ |
|
1595 | - public function getSessionCryptoWrapper() { |
|
1596 | - return $this->query('CryptoWrapper'); |
|
1597 | - } |
|
1598 | - |
|
1599 | - /** |
|
1600 | - * @return CsrfTokenManager |
|
1601 | - */ |
|
1602 | - public function getCsrfTokenManager() { |
|
1603 | - return $this->query('CsrfTokenManager'); |
|
1604 | - } |
|
1605 | - |
|
1606 | - /** |
|
1607 | - * @return Throttler |
|
1608 | - */ |
|
1609 | - public function getBruteForceThrottler() { |
|
1610 | - return $this->query('Throttler'); |
|
1611 | - } |
|
1612 | - |
|
1613 | - /** |
|
1614 | - * @return IContentSecurityPolicyManager |
|
1615 | - */ |
|
1616 | - public function getContentSecurityPolicyManager() { |
|
1617 | - return $this->query('ContentSecurityPolicyManager'); |
|
1618 | - } |
|
1619 | - |
|
1620 | - /** |
|
1621 | - * @return ContentSecurityPolicyNonceManager |
|
1622 | - */ |
|
1623 | - public function getContentSecurityPolicyNonceManager() { |
|
1624 | - return $this->query('ContentSecurityPolicyNonceManager'); |
|
1625 | - } |
|
1626 | - |
|
1627 | - /** |
|
1628 | - * Not a public API as of 8.2, wait for 9.0 |
|
1629 | - * |
|
1630 | - * @return \OCA\Files_External\Service\BackendService |
|
1631 | - */ |
|
1632 | - public function getStoragesBackendService() { |
|
1633 | - return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1634 | - } |
|
1635 | - |
|
1636 | - /** |
|
1637 | - * Not a public API as of 8.2, wait for 9.0 |
|
1638 | - * |
|
1639 | - * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1640 | - */ |
|
1641 | - public function getGlobalStoragesService() { |
|
1642 | - return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1643 | - } |
|
1644 | - |
|
1645 | - /** |
|
1646 | - * Not a public API as of 8.2, wait for 9.0 |
|
1647 | - * |
|
1648 | - * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1649 | - */ |
|
1650 | - public function getUserGlobalStoragesService() { |
|
1651 | - return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1652 | - } |
|
1653 | - |
|
1654 | - /** |
|
1655 | - * Not a public API as of 8.2, wait for 9.0 |
|
1656 | - * |
|
1657 | - * @return \OCA\Files_External\Service\UserStoragesService |
|
1658 | - */ |
|
1659 | - public function getUserStoragesService() { |
|
1660 | - return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1661 | - } |
|
1662 | - |
|
1663 | - /** |
|
1664 | - * @return \OCP\Share\IManager |
|
1665 | - */ |
|
1666 | - public function getShareManager() { |
|
1667 | - return $this->query('ShareManager'); |
|
1668 | - } |
|
1669 | - |
|
1670 | - /** |
|
1671 | - * Returns the LDAP Provider |
|
1672 | - * |
|
1673 | - * @return \OCP\LDAP\ILDAPProvider |
|
1674 | - */ |
|
1675 | - public function getLDAPProvider() { |
|
1676 | - return $this->query('LDAPProvider'); |
|
1677 | - } |
|
1678 | - |
|
1679 | - /** |
|
1680 | - * @return \OCP\Settings\IManager |
|
1681 | - */ |
|
1682 | - public function getSettingsManager() { |
|
1683 | - return $this->query('SettingsManager'); |
|
1684 | - } |
|
1685 | - |
|
1686 | - /** |
|
1687 | - * @return \OCP\Files\IAppData |
|
1688 | - */ |
|
1689 | - public function getAppDataDir($app) { |
|
1690 | - /** @var \OC\Files\AppData\Factory $factory */ |
|
1691 | - $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
1692 | - return $factory->get($app); |
|
1693 | - } |
|
1694 | - |
|
1695 | - /** |
|
1696 | - * @return \OCP\Lockdown\ILockdownManager |
|
1697 | - */ |
|
1698 | - public function getLockdownManager() { |
|
1699 | - return $this->query('LockdownManager'); |
|
1700 | - } |
|
1701 | - |
|
1702 | - /** |
|
1703 | - * @return \OCP\Federation\ICloudIdManager |
|
1704 | - */ |
|
1705 | - public function getCloudIdManager() { |
|
1706 | - return $this->query(ICloudIdManager::class); |
|
1707 | - } |
|
819 | + $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
820 | + if (isset($prefixes['OCA\\Theming\\'])) { |
|
821 | + $classExists = true; |
|
822 | + } else { |
|
823 | + $classExists = false; |
|
824 | + } |
|
825 | + |
|
826 | + if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) { |
|
827 | + return new ThemingDefaults( |
|
828 | + $c->getConfig(), |
|
829 | + $c->getL10N('theming'), |
|
830 | + $c->getURLGenerator(), |
|
831 | + new \OC_Defaults(), |
|
832 | + $c->getLazyRootFolder(), |
|
833 | + $c->getMemCacheFactory() |
|
834 | + ); |
|
835 | + } |
|
836 | + return new \OC_Defaults(); |
|
837 | + }); |
|
838 | + $this->registerService(EventDispatcher::class, function () { |
|
839 | + return new EventDispatcher(); |
|
840 | + }); |
|
841 | + $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
842 | + $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
843 | + |
|
844 | + $this->registerService('CryptoWrapper', function (Server $c) { |
|
845 | + // FIXME: Instantiiated here due to cyclic dependency |
|
846 | + $request = new Request( |
|
847 | + [ |
|
848 | + 'get' => $_GET, |
|
849 | + 'post' => $_POST, |
|
850 | + 'files' => $_FILES, |
|
851 | + 'server' => $_SERVER, |
|
852 | + 'env' => $_ENV, |
|
853 | + 'cookies' => $_COOKIE, |
|
854 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
855 | + ? $_SERVER['REQUEST_METHOD'] |
|
856 | + : null, |
|
857 | + ], |
|
858 | + $c->getSecureRandom(), |
|
859 | + $c->getConfig() |
|
860 | + ); |
|
861 | + |
|
862 | + return new CryptoWrapper( |
|
863 | + $c->getConfig(), |
|
864 | + $c->getCrypto(), |
|
865 | + $c->getSecureRandom(), |
|
866 | + $request |
|
867 | + ); |
|
868 | + }); |
|
869 | + $this->registerService('CsrfTokenManager', function (Server $c) { |
|
870 | + $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
871 | + |
|
872 | + return new CsrfTokenManager( |
|
873 | + $tokenGenerator, |
|
874 | + $c->query(SessionStorage::class) |
|
875 | + ); |
|
876 | + }); |
|
877 | + $this->registerService(SessionStorage::class, function (Server $c) { |
|
878 | + return new SessionStorage($c->getSession()); |
|
879 | + }); |
|
880 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
881 | + return new ContentSecurityPolicyManager(); |
|
882 | + }); |
|
883 | + $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
884 | + |
|
885 | + $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) { |
|
886 | + return new ContentSecurityPolicyNonceManager( |
|
887 | + $c->getCsrfTokenManager(), |
|
888 | + $c->getRequest() |
|
889 | + ); |
|
890 | + }); |
|
891 | + |
|
892 | + $this->registerService(\OCP\Share\IManager::class, function(Server $c) { |
|
893 | + $config = $c->getConfig(); |
|
894 | + $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory'); |
|
895 | + /** @var \OCP\Share\IProviderFactory $factory */ |
|
896 | + $factory = new $factoryClass($this); |
|
897 | + |
|
898 | + $manager = new \OC\Share20\Manager( |
|
899 | + $c->getLogger(), |
|
900 | + $c->getConfig(), |
|
901 | + $c->getSecureRandom(), |
|
902 | + $c->getHasher(), |
|
903 | + $c->getMountManager(), |
|
904 | + $c->getGroupManager(), |
|
905 | + $c->getL10N('core'), |
|
906 | + $factory, |
|
907 | + $c->getUserManager(), |
|
908 | + $c->getLazyRootFolder(), |
|
909 | + $c->getEventDispatcher() |
|
910 | + ); |
|
911 | + |
|
912 | + return $manager; |
|
913 | + }); |
|
914 | + $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
915 | + |
|
916 | + $this->registerService('SettingsManager', function(Server $c) { |
|
917 | + $manager = new \OC\Settings\Manager( |
|
918 | + $c->getLogger(), |
|
919 | + $c->getDatabaseConnection(), |
|
920 | + $c->getL10N('lib'), |
|
921 | + $c->getConfig(), |
|
922 | + $c->getEncryptionManager(), |
|
923 | + $c->getUserManager(), |
|
924 | + $c->getLockingProvider(), |
|
925 | + $c->getRequest(), |
|
926 | + new \OC\Settings\Mapper($c->getDatabaseConnection()), |
|
927 | + $c->getURLGenerator() |
|
928 | + ); |
|
929 | + return $manager; |
|
930 | + }); |
|
931 | + $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
932 | + return new \OC\Files\AppData\Factory( |
|
933 | + $c->getRootFolder(), |
|
934 | + $c->getSystemConfig() |
|
935 | + ); |
|
936 | + }); |
|
937 | + |
|
938 | + $this->registerService('LockdownManager', function (Server $c) { |
|
939 | + return new LockdownManager(); |
|
940 | + }); |
|
941 | + |
|
942 | + $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
943 | + return new CloudIdManager(); |
|
944 | + }); |
|
945 | + |
|
946 | + /* To trick DI since we don't extend the DIContainer here */ |
|
947 | + $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
948 | + return new CleanPreviewsBackgroundJob( |
|
949 | + $c->getRootFolder(), |
|
950 | + $c->getLogger(), |
|
951 | + $c->getJobList(), |
|
952 | + new TimeFactory() |
|
953 | + ); |
|
954 | + }); |
|
955 | + |
|
956 | + $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
957 | + $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
958 | + |
|
959 | + $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
960 | + $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
961 | + |
|
962 | + $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) { |
|
963 | + return $c->query(\OCP\IUserSession::class)->getSession(); |
|
964 | + }); |
|
965 | + } |
|
966 | + |
|
967 | + /** |
|
968 | + * @return \OCP\Contacts\IManager |
|
969 | + */ |
|
970 | + public function getContactsManager() { |
|
971 | + return $this->query('ContactsManager'); |
|
972 | + } |
|
973 | + |
|
974 | + /** |
|
975 | + * @return \OC\Encryption\Manager |
|
976 | + */ |
|
977 | + public function getEncryptionManager() { |
|
978 | + return $this->query('EncryptionManager'); |
|
979 | + } |
|
980 | + |
|
981 | + /** |
|
982 | + * @return \OC\Encryption\File |
|
983 | + */ |
|
984 | + public function getEncryptionFilesHelper() { |
|
985 | + return $this->query('EncryptionFileHelper'); |
|
986 | + } |
|
987 | + |
|
988 | + /** |
|
989 | + * @return \OCP\Encryption\Keys\IStorage |
|
990 | + */ |
|
991 | + public function getEncryptionKeyStorage() { |
|
992 | + return $this->query('EncryptionKeyStorage'); |
|
993 | + } |
|
994 | + |
|
995 | + /** |
|
996 | + * The current request object holding all information about the request |
|
997 | + * currently being processed is returned from this method. |
|
998 | + * In case the current execution was not initiated by a web request null is returned |
|
999 | + * |
|
1000 | + * @return \OCP\IRequest |
|
1001 | + */ |
|
1002 | + public function getRequest() { |
|
1003 | + return $this->query('Request'); |
|
1004 | + } |
|
1005 | + |
|
1006 | + /** |
|
1007 | + * Returns the preview manager which can create preview images for a given file |
|
1008 | + * |
|
1009 | + * @return \OCP\IPreview |
|
1010 | + */ |
|
1011 | + public function getPreviewManager() { |
|
1012 | + return $this->query('PreviewManager'); |
|
1013 | + } |
|
1014 | + |
|
1015 | + /** |
|
1016 | + * Returns the tag manager which can get and set tags for different object types |
|
1017 | + * |
|
1018 | + * @see \OCP\ITagManager::load() |
|
1019 | + * @return \OCP\ITagManager |
|
1020 | + */ |
|
1021 | + public function getTagManager() { |
|
1022 | + return $this->query('TagManager'); |
|
1023 | + } |
|
1024 | + |
|
1025 | + /** |
|
1026 | + * Returns the system-tag manager |
|
1027 | + * |
|
1028 | + * @return \OCP\SystemTag\ISystemTagManager |
|
1029 | + * |
|
1030 | + * @since 9.0.0 |
|
1031 | + */ |
|
1032 | + public function getSystemTagManager() { |
|
1033 | + return $this->query('SystemTagManager'); |
|
1034 | + } |
|
1035 | + |
|
1036 | + /** |
|
1037 | + * Returns the system-tag object mapper |
|
1038 | + * |
|
1039 | + * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
1040 | + * |
|
1041 | + * @since 9.0.0 |
|
1042 | + */ |
|
1043 | + public function getSystemTagObjectMapper() { |
|
1044 | + return $this->query('SystemTagObjectMapper'); |
|
1045 | + } |
|
1046 | + |
|
1047 | + /** |
|
1048 | + * Returns the avatar manager, used for avatar functionality |
|
1049 | + * |
|
1050 | + * @return \OCP\IAvatarManager |
|
1051 | + */ |
|
1052 | + public function getAvatarManager() { |
|
1053 | + return $this->query('AvatarManager'); |
|
1054 | + } |
|
1055 | + |
|
1056 | + /** |
|
1057 | + * Returns the root folder of ownCloud's data directory |
|
1058 | + * |
|
1059 | + * @return \OCP\Files\IRootFolder |
|
1060 | + */ |
|
1061 | + public function getRootFolder() { |
|
1062 | + return $this->query('LazyRootFolder'); |
|
1063 | + } |
|
1064 | + |
|
1065 | + /** |
|
1066 | + * Returns the root folder of ownCloud's data directory |
|
1067 | + * This is the lazy variant so this gets only initialized once it |
|
1068 | + * is actually used. |
|
1069 | + * |
|
1070 | + * @return \OCP\Files\IRootFolder |
|
1071 | + */ |
|
1072 | + public function getLazyRootFolder() { |
|
1073 | + return $this->query('LazyRootFolder'); |
|
1074 | + } |
|
1075 | + |
|
1076 | + /** |
|
1077 | + * Returns a view to ownCloud's files folder |
|
1078 | + * |
|
1079 | + * @param string $userId user ID |
|
1080 | + * @return \OCP\Files\Folder|null |
|
1081 | + */ |
|
1082 | + public function getUserFolder($userId = null) { |
|
1083 | + if ($userId === null) { |
|
1084 | + $user = $this->getUserSession()->getUser(); |
|
1085 | + if (!$user) { |
|
1086 | + return null; |
|
1087 | + } |
|
1088 | + $userId = $user->getUID(); |
|
1089 | + } |
|
1090 | + $root = $this->getRootFolder(); |
|
1091 | + return $root->getUserFolder($userId); |
|
1092 | + } |
|
1093 | + |
|
1094 | + /** |
|
1095 | + * Returns an app-specific view in ownClouds data directory |
|
1096 | + * |
|
1097 | + * @return \OCP\Files\Folder |
|
1098 | + * @deprecated since 9.2.0 use IAppData |
|
1099 | + */ |
|
1100 | + public function getAppFolder() { |
|
1101 | + $dir = '/' . \OC_App::getCurrentApp(); |
|
1102 | + $root = $this->getRootFolder(); |
|
1103 | + if (!$root->nodeExists($dir)) { |
|
1104 | + $folder = $root->newFolder($dir); |
|
1105 | + } else { |
|
1106 | + $folder = $root->get($dir); |
|
1107 | + } |
|
1108 | + return $folder; |
|
1109 | + } |
|
1110 | + |
|
1111 | + /** |
|
1112 | + * @return \OC\User\Manager |
|
1113 | + */ |
|
1114 | + public function getUserManager() { |
|
1115 | + return $this->query('UserManager'); |
|
1116 | + } |
|
1117 | + |
|
1118 | + /** |
|
1119 | + * @return \OC\Group\Manager |
|
1120 | + */ |
|
1121 | + public function getGroupManager() { |
|
1122 | + return $this->query('GroupManager'); |
|
1123 | + } |
|
1124 | + |
|
1125 | + /** |
|
1126 | + * @return \OC\User\Session |
|
1127 | + */ |
|
1128 | + public function getUserSession() { |
|
1129 | + return $this->query('UserSession'); |
|
1130 | + } |
|
1131 | + |
|
1132 | + /** |
|
1133 | + * @return \OCP\ISession |
|
1134 | + */ |
|
1135 | + public function getSession() { |
|
1136 | + return $this->query('UserSession')->getSession(); |
|
1137 | + } |
|
1138 | + |
|
1139 | + /** |
|
1140 | + * @param \OCP\ISession $session |
|
1141 | + */ |
|
1142 | + public function setSession(\OCP\ISession $session) { |
|
1143 | + $this->query(SessionStorage::class)->setSession($session); |
|
1144 | + $this->query('UserSession')->setSession($session); |
|
1145 | + $this->query(Store::class)->setSession($session); |
|
1146 | + } |
|
1147 | + |
|
1148 | + /** |
|
1149 | + * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1150 | + */ |
|
1151 | + public function getTwoFactorAuthManager() { |
|
1152 | + return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1153 | + } |
|
1154 | + |
|
1155 | + /** |
|
1156 | + * @return \OC\NavigationManager |
|
1157 | + */ |
|
1158 | + public function getNavigationManager() { |
|
1159 | + return $this->query('NavigationManager'); |
|
1160 | + } |
|
1161 | + |
|
1162 | + /** |
|
1163 | + * @return \OCP\IConfig |
|
1164 | + */ |
|
1165 | + public function getConfig() { |
|
1166 | + return $this->query('AllConfig'); |
|
1167 | + } |
|
1168 | + |
|
1169 | + /** |
|
1170 | + * @internal For internal use only |
|
1171 | + * @return \OC\SystemConfig |
|
1172 | + */ |
|
1173 | + public function getSystemConfig() { |
|
1174 | + return $this->query('SystemConfig'); |
|
1175 | + } |
|
1176 | + |
|
1177 | + /** |
|
1178 | + * Returns the app config manager |
|
1179 | + * |
|
1180 | + * @return \OCP\IAppConfig |
|
1181 | + */ |
|
1182 | + public function getAppConfig() { |
|
1183 | + return $this->query('AppConfig'); |
|
1184 | + } |
|
1185 | + |
|
1186 | + /** |
|
1187 | + * @return \OCP\L10N\IFactory |
|
1188 | + */ |
|
1189 | + public function getL10NFactory() { |
|
1190 | + return $this->query('L10NFactory'); |
|
1191 | + } |
|
1192 | + |
|
1193 | + /** |
|
1194 | + * get an L10N instance |
|
1195 | + * |
|
1196 | + * @param string $app appid |
|
1197 | + * @param string $lang |
|
1198 | + * @return IL10N |
|
1199 | + */ |
|
1200 | + public function getL10N($app, $lang = null) { |
|
1201 | + return $this->getL10NFactory()->get($app, $lang); |
|
1202 | + } |
|
1203 | + |
|
1204 | + /** |
|
1205 | + * @return \OCP\IURLGenerator |
|
1206 | + */ |
|
1207 | + public function getURLGenerator() { |
|
1208 | + return $this->query('URLGenerator'); |
|
1209 | + } |
|
1210 | + |
|
1211 | + /** |
|
1212 | + * @return \OCP\IHelper |
|
1213 | + */ |
|
1214 | + public function getHelper() { |
|
1215 | + return $this->query('AppHelper'); |
|
1216 | + } |
|
1217 | + |
|
1218 | + /** |
|
1219 | + * @return AppFetcher |
|
1220 | + */ |
|
1221 | + public function getAppFetcher() { |
|
1222 | + return $this->query('AppFetcher'); |
|
1223 | + } |
|
1224 | + |
|
1225 | + /** |
|
1226 | + * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1227 | + * getMemCacheFactory() instead. |
|
1228 | + * |
|
1229 | + * @return \OCP\ICache |
|
1230 | + * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1231 | + */ |
|
1232 | + public function getCache() { |
|
1233 | + return $this->query('UserCache'); |
|
1234 | + } |
|
1235 | + |
|
1236 | + /** |
|
1237 | + * Returns an \OCP\CacheFactory instance |
|
1238 | + * |
|
1239 | + * @return \OCP\ICacheFactory |
|
1240 | + */ |
|
1241 | + public function getMemCacheFactory() { |
|
1242 | + return $this->query('MemCacheFactory'); |
|
1243 | + } |
|
1244 | + |
|
1245 | + /** |
|
1246 | + * Returns an \OC\RedisFactory instance |
|
1247 | + * |
|
1248 | + * @return \OC\RedisFactory |
|
1249 | + */ |
|
1250 | + public function getGetRedisFactory() { |
|
1251 | + return $this->query('RedisFactory'); |
|
1252 | + } |
|
1253 | + |
|
1254 | + |
|
1255 | + /** |
|
1256 | + * Returns the current session |
|
1257 | + * |
|
1258 | + * @return \OCP\IDBConnection |
|
1259 | + */ |
|
1260 | + public function getDatabaseConnection() { |
|
1261 | + return $this->query('DatabaseConnection'); |
|
1262 | + } |
|
1263 | + |
|
1264 | + /** |
|
1265 | + * Returns the activity manager |
|
1266 | + * |
|
1267 | + * @return \OCP\Activity\IManager |
|
1268 | + */ |
|
1269 | + public function getActivityManager() { |
|
1270 | + return $this->query('ActivityManager'); |
|
1271 | + } |
|
1272 | + |
|
1273 | + /** |
|
1274 | + * Returns an job list for controlling background jobs |
|
1275 | + * |
|
1276 | + * @return \OCP\BackgroundJob\IJobList |
|
1277 | + */ |
|
1278 | + public function getJobList() { |
|
1279 | + return $this->query('JobList'); |
|
1280 | + } |
|
1281 | + |
|
1282 | + /** |
|
1283 | + * Returns a logger instance |
|
1284 | + * |
|
1285 | + * @return \OCP\ILogger |
|
1286 | + */ |
|
1287 | + public function getLogger() { |
|
1288 | + return $this->query('Logger'); |
|
1289 | + } |
|
1290 | + |
|
1291 | + /** |
|
1292 | + * Returns a router for generating and matching urls |
|
1293 | + * |
|
1294 | + * @return \OCP\Route\IRouter |
|
1295 | + */ |
|
1296 | + public function getRouter() { |
|
1297 | + return $this->query('Router'); |
|
1298 | + } |
|
1299 | + |
|
1300 | + /** |
|
1301 | + * Returns a search instance |
|
1302 | + * |
|
1303 | + * @return \OCP\ISearch |
|
1304 | + */ |
|
1305 | + public function getSearch() { |
|
1306 | + return $this->query('Search'); |
|
1307 | + } |
|
1308 | + |
|
1309 | + /** |
|
1310 | + * Returns a SecureRandom instance |
|
1311 | + * |
|
1312 | + * @return \OCP\Security\ISecureRandom |
|
1313 | + */ |
|
1314 | + public function getSecureRandom() { |
|
1315 | + return $this->query('SecureRandom'); |
|
1316 | + } |
|
1317 | + |
|
1318 | + /** |
|
1319 | + * Returns a Crypto instance |
|
1320 | + * |
|
1321 | + * @return \OCP\Security\ICrypto |
|
1322 | + */ |
|
1323 | + public function getCrypto() { |
|
1324 | + return $this->query('Crypto'); |
|
1325 | + } |
|
1326 | + |
|
1327 | + /** |
|
1328 | + * Returns a Hasher instance |
|
1329 | + * |
|
1330 | + * @return \OCP\Security\IHasher |
|
1331 | + */ |
|
1332 | + public function getHasher() { |
|
1333 | + return $this->query('Hasher'); |
|
1334 | + } |
|
1335 | + |
|
1336 | + /** |
|
1337 | + * Returns a CredentialsManager instance |
|
1338 | + * |
|
1339 | + * @return \OCP\Security\ICredentialsManager |
|
1340 | + */ |
|
1341 | + public function getCredentialsManager() { |
|
1342 | + return $this->query('CredentialsManager'); |
|
1343 | + } |
|
1344 | + |
|
1345 | + /** |
|
1346 | + * Returns an instance of the HTTP helper class |
|
1347 | + * |
|
1348 | + * @deprecated Use getHTTPClientService() |
|
1349 | + * @return \OC\HTTPHelper |
|
1350 | + */ |
|
1351 | + public function getHTTPHelper() { |
|
1352 | + return $this->query('HTTPHelper'); |
|
1353 | + } |
|
1354 | + |
|
1355 | + /** |
|
1356 | + * Get the certificate manager for the user |
|
1357 | + * |
|
1358 | + * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1359 | + * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1360 | + */ |
|
1361 | + public function getCertificateManager($userId = '') { |
|
1362 | + if ($userId === '') { |
|
1363 | + $userSession = $this->getUserSession(); |
|
1364 | + $user = $userSession->getUser(); |
|
1365 | + if (is_null($user)) { |
|
1366 | + return null; |
|
1367 | + } |
|
1368 | + $userId = $user->getUID(); |
|
1369 | + } |
|
1370 | + return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger()); |
|
1371 | + } |
|
1372 | + |
|
1373 | + /** |
|
1374 | + * Returns an instance of the HTTP client service |
|
1375 | + * |
|
1376 | + * @return \OCP\Http\Client\IClientService |
|
1377 | + */ |
|
1378 | + public function getHTTPClientService() { |
|
1379 | + return $this->query('HttpClientService'); |
|
1380 | + } |
|
1381 | + |
|
1382 | + /** |
|
1383 | + * Create a new event source |
|
1384 | + * |
|
1385 | + * @return \OCP\IEventSource |
|
1386 | + */ |
|
1387 | + public function createEventSource() { |
|
1388 | + return new \OC_EventSource(); |
|
1389 | + } |
|
1390 | + |
|
1391 | + /** |
|
1392 | + * Get the active event logger |
|
1393 | + * |
|
1394 | + * The returned logger only logs data when debug mode is enabled |
|
1395 | + * |
|
1396 | + * @return \OCP\Diagnostics\IEventLogger |
|
1397 | + */ |
|
1398 | + public function getEventLogger() { |
|
1399 | + return $this->query('EventLogger'); |
|
1400 | + } |
|
1401 | + |
|
1402 | + /** |
|
1403 | + * Get the active query logger |
|
1404 | + * |
|
1405 | + * The returned logger only logs data when debug mode is enabled |
|
1406 | + * |
|
1407 | + * @return \OCP\Diagnostics\IQueryLogger |
|
1408 | + */ |
|
1409 | + public function getQueryLogger() { |
|
1410 | + return $this->query('QueryLogger'); |
|
1411 | + } |
|
1412 | + |
|
1413 | + /** |
|
1414 | + * Get the manager for temporary files and folders |
|
1415 | + * |
|
1416 | + * @return \OCP\ITempManager |
|
1417 | + */ |
|
1418 | + public function getTempManager() { |
|
1419 | + return $this->query('TempManager'); |
|
1420 | + } |
|
1421 | + |
|
1422 | + /** |
|
1423 | + * Get the app manager |
|
1424 | + * |
|
1425 | + * @return \OCP\App\IAppManager |
|
1426 | + */ |
|
1427 | + public function getAppManager() { |
|
1428 | + return $this->query('AppManager'); |
|
1429 | + } |
|
1430 | + |
|
1431 | + /** |
|
1432 | + * Creates a new mailer |
|
1433 | + * |
|
1434 | + * @return \OCP\Mail\IMailer |
|
1435 | + */ |
|
1436 | + public function getMailer() { |
|
1437 | + return $this->query('Mailer'); |
|
1438 | + } |
|
1439 | + |
|
1440 | + /** |
|
1441 | + * Get the webroot |
|
1442 | + * |
|
1443 | + * @return string |
|
1444 | + */ |
|
1445 | + public function getWebRoot() { |
|
1446 | + return $this->webRoot; |
|
1447 | + } |
|
1448 | + |
|
1449 | + /** |
|
1450 | + * @return \OC\OCSClient |
|
1451 | + */ |
|
1452 | + public function getOcsClient() { |
|
1453 | + return $this->query('OcsClient'); |
|
1454 | + } |
|
1455 | + |
|
1456 | + /** |
|
1457 | + * @return \OCP\IDateTimeZone |
|
1458 | + */ |
|
1459 | + public function getDateTimeZone() { |
|
1460 | + return $this->query('DateTimeZone'); |
|
1461 | + } |
|
1462 | + |
|
1463 | + /** |
|
1464 | + * @return \OCP\IDateTimeFormatter |
|
1465 | + */ |
|
1466 | + public function getDateTimeFormatter() { |
|
1467 | + return $this->query('DateTimeFormatter'); |
|
1468 | + } |
|
1469 | + |
|
1470 | + /** |
|
1471 | + * @return \OCP\Files\Config\IMountProviderCollection |
|
1472 | + */ |
|
1473 | + public function getMountProviderCollection() { |
|
1474 | + return $this->query('MountConfigManager'); |
|
1475 | + } |
|
1476 | + |
|
1477 | + /** |
|
1478 | + * Get the IniWrapper |
|
1479 | + * |
|
1480 | + * @return IniGetWrapper |
|
1481 | + */ |
|
1482 | + public function getIniWrapper() { |
|
1483 | + return $this->query('IniWrapper'); |
|
1484 | + } |
|
1485 | + |
|
1486 | + /** |
|
1487 | + * @return \OCP\Command\IBus |
|
1488 | + */ |
|
1489 | + public function getCommandBus() { |
|
1490 | + return $this->query('AsyncCommandBus'); |
|
1491 | + } |
|
1492 | + |
|
1493 | + /** |
|
1494 | + * Get the trusted domain helper |
|
1495 | + * |
|
1496 | + * @return TrustedDomainHelper |
|
1497 | + */ |
|
1498 | + public function getTrustedDomainHelper() { |
|
1499 | + return $this->query('TrustedDomainHelper'); |
|
1500 | + } |
|
1501 | + |
|
1502 | + /** |
|
1503 | + * Get the locking provider |
|
1504 | + * |
|
1505 | + * @return \OCP\Lock\ILockingProvider |
|
1506 | + * @since 8.1.0 |
|
1507 | + */ |
|
1508 | + public function getLockingProvider() { |
|
1509 | + return $this->query('LockingProvider'); |
|
1510 | + } |
|
1511 | + |
|
1512 | + /** |
|
1513 | + * @return \OCP\Files\Mount\IMountManager |
|
1514 | + **/ |
|
1515 | + function getMountManager() { |
|
1516 | + return $this->query('MountManager'); |
|
1517 | + } |
|
1518 | + |
|
1519 | + /** @return \OCP\Files\Config\IUserMountCache */ |
|
1520 | + function getUserMountCache() { |
|
1521 | + return $this->query('UserMountCache'); |
|
1522 | + } |
|
1523 | + |
|
1524 | + /** |
|
1525 | + * Get the MimeTypeDetector |
|
1526 | + * |
|
1527 | + * @return \OCP\Files\IMimeTypeDetector |
|
1528 | + */ |
|
1529 | + public function getMimeTypeDetector() { |
|
1530 | + return $this->query('MimeTypeDetector'); |
|
1531 | + } |
|
1532 | + |
|
1533 | + /** |
|
1534 | + * Get the MimeTypeLoader |
|
1535 | + * |
|
1536 | + * @return \OCP\Files\IMimeTypeLoader |
|
1537 | + */ |
|
1538 | + public function getMimeTypeLoader() { |
|
1539 | + return $this->query('MimeTypeLoader'); |
|
1540 | + } |
|
1541 | + |
|
1542 | + /** |
|
1543 | + * Get the manager of all the capabilities |
|
1544 | + * |
|
1545 | + * @return \OC\CapabilitiesManager |
|
1546 | + */ |
|
1547 | + public function getCapabilitiesManager() { |
|
1548 | + return $this->query('CapabilitiesManager'); |
|
1549 | + } |
|
1550 | + |
|
1551 | + /** |
|
1552 | + * Get the EventDispatcher |
|
1553 | + * |
|
1554 | + * @return EventDispatcherInterface |
|
1555 | + * @since 8.2.0 |
|
1556 | + */ |
|
1557 | + public function getEventDispatcher() { |
|
1558 | + return $this->query('EventDispatcher'); |
|
1559 | + } |
|
1560 | + |
|
1561 | + /** |
|
1562 | + * Get the Notification Manager |
|
1563 | + * |
|
1564 | + * @return \OCP\Notification\IManager |
|
1565 | + * @since 8.2.0 |
|
1566 | + */ |
|
1567 | + public function getNotificationManager() { |
|
1568 | + return $this->query('NotificationManager'); |
|
1569 | + } |
|
1570 | + |
|
1571 | + /** |
|
1572 | + * @return \OCP\Comments\ICommentsManager |
|
1573 | + */ |
|
1574 | + public function getCommentsManager() { |
|
1575 | + return $this->query('CommentsManager'); |
|
1576 | + } |
|
1577 | + |
|
1578 | + /** |
|
1579 | + * @return \OC_Defaults |
|
1580 | + */ |
|
1581 | + public function getThemingDefaults() { |
|
1582 | + return $this->query('ThemingDefaults'); |
|
1583 | + } |
|
1584 | + |
|
1585 | + /** |
|
1586 | + * @return \OC\IntegrityCheck\Checker |
|
1587 | + */ |
|
1588 | + public function getIntegrityCodeChecker() { |
|
1589 | + return $this->query('IntegrityCodeChecker'); |
|
1590 | + } |
|
1591 | + |
|
1592 | + /** |
|
1593 | + * @return \OC\Session\CryptoWrapper |
|
1594 | + */ |
|
1595 | + public function getSessionCryptoWrapper() { |
|
1596 | + return $this->query('CryptoWrapper'); |
|
1597 | + } |
|
1598 | + |
|
1599 | + /** |
|
1600 | + * @return CsrfTokenManager |
|
1601 | + */ |
|
1602 | + public function getCsrfTokenManager() { |
|
1603 | + return $this->query('CsrfTokenManager'); |
|
1604 | + } |
|
1605 | + |
|
1606 | + /** |
|
1607 | + * @return Throttler |
|
1608 | + */ |
|
1609 | + public function getBruteForceThrottler() { |
|
1610 | + return $this->query('Throttler'); |
|
1611 | + } |
|
1612 | + |
|
1613 | + /** |
|
1614 | + * @return IContentSecurityPolicyManager |
|
1615 | + */ |
|
1616 | + public function getContentSecurityPolicyManager() { |
|
1617 | + return $this->query('ContentSecurityPolicyManager'); |
|
1618 | + } |
|
1619 | + |
|
1620 | + /** |
|
1621 | + * @return ContentSecurityPolicyNonceManager |
|
1622 | + */ |
|
1623 | + public function getContentSecurityPolicyNonceManager() { |
|
1624 | + return $this->query('ContentSecurityPolicyNonceManager'); |
|
1625 | + } |
|
1626 | + |
|
1627 | + /** |
|
1628 | + * Not a public API as of 8.2, wait for 9.0 |
|
1629 | + * |
|
1630 | + * @return \OCA\Files_External\Service\BackendService |
|
1631 | + */ |
|
1632 | + public function getStoragesBackendService() { |
|
1633 | + return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1634 | + } |
|
1635 | + |
|
1636 | + /** |
|
1637 | + * Not a public API as of 8.2, wait for 9.0 |
|
1638 | + * |
|
1639 | + * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1640 | + */ |
|
1641 | + public function getGlobalStoragesService() { |
|
1642 | + return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1643 | + } |
|
1644 | + |
|
1645 | + /** |
|
1646 | + * Not a public API as of 8.2, wait for 9.0 |
|
1647 | + * |
|
1648 | + * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1649 | + */ |
|
1650 | + public function getUserGlobalStoragesService() { |
|
1651 | + return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1652 | + } |
|
1653 | + |
|
1654 | + /** |
|
1655 | + * Not a public API as of 8.2, wait for 9.0 |
|
1656 | + * |
|
1657 | + * @return \OCA\Files_External\Service\UserStoragesService |
|
1658 | + */ |
|
1659 | + public function getUserStoragesService() { |
|
1660 | + return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1661 | + } |
|
1662 | + |
|
1663 | + /** |
|
1664 | + * @return \OCP\Share\IManager |
|
1665 | + */ |
|
1666 | + public function getShareManager() { |
|
1667 | + return $this->query('ShareManager'); |
|
1668 | + } |
|
1669 | + |
|
1670 | + /** |
|
1671 | + * Returns the LDAP Provider |
|
1672 | + * |
|
1673 | + * @return \OCP\LDAP\ILDAPProvider |
|
1674 | + */ |
|
1675 | + public function getLDAPProvider() { |
|
1676 | + return $this->query('LDAPProvider'); |
|
1677 | + } |
|
1678 | + |
|
1679 | + /** |
|
1680 | + * @return \OCP\Settings\IManager |
|
1681 | + */ |
|
1682 | + public function getSettingsManager() { |
|
1683 | + return $this->query('SettingsManager'); |
|
1684 | + } |
|
1685 | + |
|
1686 | + /** |
|
1687 | + * @return \OCP\Files\IAppData |
|
1688 | + */ |
|
1689 | + public function getAppDataDir($app) { |
|
1690 | + /** @var \OC\Files\AppData\Factory $factory */ |
|
1691 | + $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
1692 | + return $factory->get($app); |
|
1693 | + } |
|
1694 | + |
|
1695 | + /** |
|
1696 | + * @return \OCP\Lockdown\ILockdownManager |
|
1697 | + */ |
|
1698 | + public function getLockdownManager() { |
|
1699 | + return $this->query('LockdownManager'); |
|
1700 | + } |
|
1701 | + |
|
1702 | + /** |
|
1703 | + * @return \OCP\Federation\ICloudIdManager |
|
1704 | + */ |
|
1705 | + public function getCloudIdManager() { |
|
1706 | + return $this->query(ICloudIdManager::class); |
|
1707 | + } |
|
1708 | 1708 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
130 | 130 | $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
131 | 131 | |
132 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
132 | + $this->registerService(\OCP\IPreview::class, function(Server $c) { |
|
133 | 133 | return new PreviewManager( |
134 | 134 | $c->getConfig(), |
135 | 135 | $c->getRootFolder(), |
@@ -140,13 +140,13 @@ discard block |
||
140 | 140 | }); |
141 | 141 | $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
142 | 142 | |
143 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
143 | + $this->registerService(\OC\Preview\Watcher::class, function(Server $c) { |
|
144 | 144 | return new \OC\Preview\Watcher( |
145 | 145 | $c->getAppDataDir('preview') |
146 | 146 | ); |
147 | 147 | }); |
148 | 148 | |
149 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
149 | + $this->registerService('EncryptionManager', function(Server $c) { |
|
150 | 150 | $view = new View(); |
151 | 151 | $util = new Encryption\Util( |
152 | 152 | $view, |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | ); |
165 | 165 | }); |
166 | 166 | |
167 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
167 | + $this->registerService('EncryptionFileHelper', function(Server $c) { |
|
168 | 168 | $util = new Encryption\Util( |
169 | 169 | new View(), |
170 | 170 | $c->getUserManager(), |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | return new Encryption\File($util); |
175 | 175 | }); |
176 | 176 | |
177 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
177 | + $this->registerService('EncryptionKeyStorage', function(Server $c) { |
|
178 | 178 | $view = new View(); |
179 | 179 | $util = new Encryption\Util( |
180 | 180 | $view, |
@@ -185,32 +185,32 @@ discard block |
||
185 | 185 | |
186 | 186 | return new Encryption\Keys\Storage($view, $util); |
187 | 187 | }); |
188 | - $this->registerService('TagMapper', function (Server $c) { |
|
188 | + $this->registerService('TagMapper', function(Server $c) { |
|
189 | 189 | return new TagMapper($c->getDatabaseConnection()); |
190 | 190 | }); |
191 | 191 | |
192 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
192 | + $this->registerService(\OCP\ITagManager::class, function(Server $c) { |
|
193 | 193 | $tagMapper = $c->query('TagMapper'); |
194 | 194 | return new TagManager($tagMapper, $c->getUserSession()); |
195 | 195 | }); |
196 | 196 | $this->registerAlias('TagManager', \OCP\ITagManager::class); |
197 | 197 | |
198 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
198 | + $this->registerService('SystemTagManagerFactory', function(Server $c) { |
|
199 | 199 | $config = $c->getConfig(); |
200 | 200 | $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
201 | 201 | /** @var \OC\SystemTag\ManagerFactory $factory */ |
202 | 202 | $factory = new $factoryClass($this); |
203 | 203 | return $factory; |
204 | 204 | }); |
205 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
205 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function(Server $c) { |
|
206 | 206 | return $c->query('SystemTagManagerFactory')->getManager(); |
207 | 207 | }); |
208 | 208 | $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
209 | 209 | |
210 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
210 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function(Server $c) { |
|
211 | 211 | return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
212 | 212 | }); |
213 | - $this->registerService('RootFolder', function (Server $c) { |
|
213 | + $this->registerService('RootFolder', function(Server $c) { |
|
214 | 214 | $manager = \OC\Files\Filesystem::getMountManager(null); |
215 | 215 | $view = new View(); |
216 | 216 | $root = new Root( |
@@ -238,30 +238,30 @@ discard block |
||
238 | 238 | }); |
239 | 239 | $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
240 | 240 | |
241 | - $this->registerService(\OCP\IUserManager::class, function (Server $c) { |
|
241 | + $this->registerService(\OCP\IUserManager::class, function(Server $c) { |
|
242 | 242 | $config = $c->getConfig(); |
243 | 243 | return new \OC\User\Manager($config); |
244 | 244 | }); |
245 | 245 | $this->registerAlias('UserManager', \OCP\IUserManager::class); |
246 | 246 | |
247 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
247 | + $this->registerService(\OCP\IGroupManager::class, function(Server $c) { |
|
248 | 248 | $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
249 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
249 | + $groupManager->listen('\OC\Group', 'preCreate', function($gid) { |
|
250 | 250 | \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
251 | 251 | }); |
252 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
252 | + $groupManager->listen('\OC\Group', 'postCreate', function(\OC\Group\Group $gid) { |
|
253 | 253 | \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
254 | 254 | }); |
255 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
255 | + $groupManager->listen('\OC\Group', 'preDelete', function(\OC\Group\Group $group) { |
|
256 | 256 | \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
257 | 257 | }); |
258 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
258 | + $groupManager->listen('\OC\Group', 'postDelete', function(\OC\Group\Group $group) { |
|
259 | 259 | \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
260 | 260 | }); |
261 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
261 | + $groupManager->listen('\OC\Group', 'preAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
262 | 262 | \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
263 | 263 | }); |
264 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
264 | + $groupManager->listen('\OC\Group', 'postAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
265 | 265 | \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
266 | 266 | //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
267 | 267 | \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
@@ -281,11 +281,11 @@ discard block |
||
281 | 281 | return new Store($session, $logger, $tokenProvider); |
282 | 282 | }); |
283 | 283 | $this->registerAlias(IStore::class, Store::class); |
284 | - $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
284 | + $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function(Server $c) { |
|
285 | 285 | $dbConnection = $c->getDatabaseConnection(); |
286 | 286 | return new Authentication\Token\DefaultTokenMapper($dbConnection); |
287 | 287 | }); |
288 | - $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
288 | + $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function(Server $c) { |
|
289 | 289 | $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
290 | 290 | $crypto = $c->getCrypto(); |
291 | 291 | $config = $c->getConfig(); |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | }); |
296 | 296 | $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
297 | 297 | |
298 | - $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
298 | + $this->registerService(\OCP\IUserSession::class, function(Server $c) { |
|
299 | 299 | $manager = $c->getUserManager(); |
300 | 300 | $session = new \OC\Session\Memory(''); |
301 | 301 | $timeFactory = new TimeFactory(); |
@@ -308,40 +308,40 @@ discard block |
||
308 | 308 | } |
309 | 309 | |
310 | 310 | $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom()); |
311 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
311 | + $userSession->listen('\OC\User', 'preCreateUser', function($uid, $password) { |
|
312 | 312 | \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
313 | 313 | }); |
314 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
314 | + $userSession->listen('\OC\User', 'postCreateUser', function($user, $password) { |
|
315 | 315 | /** @var $user \OC\User\User */ |
316 | 316 | \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
317 | 317 | }); |
318 | - $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
318 | + $userSession->listen('\OC\User', 'preDelete', function($user) { |
|
319 | 319 | /** @var $user \OC\User\User */ |
320 | 320 | \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
321 | 321 | }); |
322 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
322 | + $userSession->listen('\OC\User', 'postDelete', function($user) { |
|
323 | 323 | /** @var $user \OC\User\User */ |
324 | 324 | \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
325 | 325 | }); |
326 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
326 | + $userSession->listen('\OC\User', 'preSetPassword', function($user, $password, $recoveryPassword) { |
|
327 | 327 | /** @var $user \OC\User\User */ |
328 | 328 | \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
329 | 329 | }); |
330 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
330 | + $userSession->listen('\OC\User', 'postSetPassword', function($user, $password, $recoveryPassword) { |
|
331 | 331 | /** @var $user \OC\User\User */ |
332 | 332 | \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
333 | 333 | }); |
334 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
334 | + $userSession->listen('\OC\User', 'preLogin', function($uid, $password) { |
|
335 | 335 | \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
336 | 336 | }); |
337 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
337 | + $userSession->listen('\OC\User', 'postLogin', function($user, $password) { |
|
338 | 338 | /** @var $user \OC\User\User */ |
339 | 339 | \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
340 | 340 | }); |
341 | - $userSession->listen('\OC\User', 'logout', function () { |
|
341 | + $userSession->listen('\OC\User', 'logout', function() { |
|
342 | 342 | \OC_Hook::emit('OC_User', 'logout', array()); |
343 | 343 | }); |
344 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) { |
|
344 | + $userSession->listen('\OC\User', 'changeUser', function($user, $feature, $value) { |
|
345 | 345 | /** @var $user \OC\User\User */ |
346 | 346 | \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value)); |
347 | 347 | }); |
@@ -349,11 +349,11 @@ discard block |
||
349 | 349 | }); |
350 | 350 | $this->registerAlias('UserSession', \OCP\IUserSession::class); |
351 | 351 | |
352 | - $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
352 | + $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function(Server $c) { |
|
353 | 353 | return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
354 | 354 | }); |
355 | 355 | |
356 | - $this->registerService(\OCP\INavigationManager::class, function (Server $c) { |
|
356 | + $this->registerService(\OCP\INavigationManager::class, function(Server $c) { |
|
357 | 357 | return new \OC\NavigationManager($c->getAppManager(), |
358 | 358 | $c->getURLGenerator(), |
359 | 359 | $c->getL10NFactory(), |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | }); |
363 | 363 | $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
364 | 364 | |
365 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
365 | + $this->registerService(\OC\AllConfig::class, function(Server $c) { |
|
366 | 366 | return new \OC\AllConfig( |
367 | 367 | $c->getSystemConfig() |
368 | 368 | ); |
@@ -370,17 +370,17 @@ discard block |
||
370 | 370 | $this->registerAlias('AllConfig', \OC\AllConfig::class); |
371 | 371 | $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
372 | 372 | |
373 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
373 | + $this->registerService('SystemConfig', function($c) use ($config) { |
|
374 | 374 | return new \OC\SystemConfig($config); |
375 | 375 | }); |
376 | 376 | |
377 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
377 | + $this->registerService(\OC\AppConfig::class, function(Server $c) { |
|
378 | 378 | return new \OC\AppConfig($c->getDatabaseConnection()); |
379 | 379 | }); |
380 | 380 | $this->registerAlias('AppConfig', \OC\AppConfig::class); |
381 | 381 | $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
382 | 382 | |
383 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
383 | + $this->registerService(\OCP\L10N\IFactory::class, function(Server $c) { |
|
384 | 384 | return new \OC\L10N\Factory( |
385 | 385 | $c->getConfig(), |
386 | 386 | $c->getRequest(), |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | }); |
391 | 391 | $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
392 | 392 | |
393 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
393 | + $this->registerService(\OCP\IURLGenerator::class, function(Server $c) { |
|
394 | 394 | $config = $c->getConfig(); |
395 | 395 | $cacheFactory = $c->getMemCacheFactory(); |
396 | 396 | return new \OC\URLGenerator( |
@@ -400,10 +400,10 @@ discard block |
||
400 | 400 | }); |
401 | 401 | $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
402 | 402 | |
403 | - $this->registerService('AppHelper', function ($c) { |
|
403 | + $this->registerService('AppHelper', function($c) { |
|
404 | 404 | return new \OC\AppHelper(); |
405 | 405 | }); |
406 | - $this->registerService('AppFetcher', function ($c) { |
|
406 | + $this->registerService('AppFetcher', function($c) { |
|
407 | 407 | return new AppFetcher( |
408 | 408 | $this->getAppDataDir('appstore'), |
409 | 409 | $this->getHTTPClientService(), |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | $this->getConfig() |
412 | 412 | ); |
413 | 413 | }); |
414 | - $this->registerService('CategoryFetcher', function ($c) { |
|
414 | + $this->registerService('CategoryFetcher', function($c) { |
|
415 | 415 | return new CategoryFetcher( |
416 | 416 | $this->getAppDataDir('appstore'), |
417 | 417 | $this->getHTTPClientService(), |
@@ -420,21 +420,21 @@ discard block |
||
420 | 420 | ); |
421 | 421 | }); |
422 | 422 | |
423 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
423 | + $this->registerService(\OCP\ICache::class, function($c) { |
|
424 | 424 | return new Cache\File(); |
425 | 425 | }); |
426 | 426 | $this->registerAlias('UserCache', \OCP\ICache::class); |
427 | 427 | |
428 | - $this->registerService(Factory::class, function (Server $c) { |
|
428 | + $this->registerService(Factory::class, function(Server $c) { |
|
429 | 429 | $config = $c->getConfig(); |
430 | 430 | |
431 | 431 | if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
432 | 432 | $v = \OC_App::getAppVersions(); |
433 | - $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
433 | + $v['core'] = md5(file_get_contents(\OC::$SERVERROOT.'/version.php')); |
|
434 | 434 | $version = implode(',', $v); |
435 | 435 | $instanceId = \OC_Util::getInstanceId(); |
436 | 436 | $path = \OC::$SERVERROOT; |
437 | - $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
437 | + $prefix = md5($instanceId.'-'.$version.'-'.$path.'-'.\OC::$WEBROOT); |
|
438 | 438 | return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
439 | 439 | $config->getSystemValue('memcache.local', null), |
440 | 440 | $config->getSystemValue('memcache.distributed', null), |
@@ -451,12 +451,12 @@ discard block |
||
451 | 451 | $this->registerAlias('MemCacheFactory', Factory::class); |
452 | 452 | $this->registerAlias(ICacheFactory::class, Factory::class); |
453 | 453 | |
454 | - $this->registerService('RedisFactory', function (Server $c) { |
|
454 | + $this->registerService('RedisFactory', function(Server $c) { |
|
455 | 455 | $systemConfig = $c->getSystemConfig(); |
456 | 456 | return new RedisFactory($systemConfig); |
457 | 457 | }); |
458 | 458 | |
459 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
459 | + $this->registerService(\OCP\Activity\IManager::class, function(Server $c) { |
|
460 | 460 | return new \OC\Activity\Manager( |
461 | 461 | $c->getRequest(), |
462 | 462 | $c->getUserSession(), |
@@ -466,14 +466,14 @@ discard block |
||
466 | 466 | }); |
467 | 467 | $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
468 | 468 | |
469 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
469 | + $this->registerService(\OCP\Activity\IEventMerger::class, function(Server $c) { |
|
470 | 470 | return new \OC\Activity\EventMerger( |
471 | 471 | $c->getL10N('lib') |
472 | 472 | ); |
473 | 473 | }); |
474 | 474 | $this->registerAlias(IValidator::class, Validator::class); |
475 | 475 | |
476 | - $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
476 | + $this->registerService(\OCP\IAvatarManager::class, function(Server $c) { |
|
477 | 477 | return new AvatarManager( |
478 | 478 | $c->getUserManager(), |
479 | 479 | $c->getAppDataDir('avatar'), |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | }); |
485 | 485 | $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
486 | 486 | |
487 | - $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
487 | + $this->registerService(\OCP\ILogger::class, function(Server $c) { |
|
488 | 488 | $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
489 | 489 | $logger = Log::getLogClass($logType); |
490 | 490 | call_user_func(array($logger, 'init')); |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | }); |
494 | 494 | $this->registerAlias('Logger', \OCP\ILogger::class); |
495 | 495 | |
496 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
496 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function(Server $c) { |
|
497 | 497 | $config = $c->getConfig(); |
498 | 498 | return new \OC\BackgroundJob\JobList( |
499 | 499 | $c->getDatabaseConnection(), |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | }); |
504 | 504 | $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
505 | 505 | |
506 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
506 | + $this->registerService(\OCP\Route\IRouter::class, function(Server $c) { |
|
507 | 507 | $cacheFactory = $c->getMemCacheFactory(); |
508 | 508 | $logger = $c->getLogger(); |
509 | 509 | if ($cacheFactory->isAvailable()) { |
@@ -515,32 +515,32 @@ discard block |
||
515 | 515 | }); |
516 | 516 | $this->registerAlias('Router', \OCP\Route\IRouter::class); |
517 | 517 | |
518 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
518 | + $this->registerService(\OCP\ISearch::class, function($c) { |
|
519 | 519 | return new Search(); |
520 | 520 | }); |
521 | 521 | $this->registerAlias('Search', \OCP\ISearch::class); |
522 | 522 | |
523 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
523 | + $this->registerService(\OCP\Security\ISecureRandom::class, function($c) { |
|
524 | 524 | return new SecureRandom(); |
525 | 525 | }); |
526 | 526 | $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
527 | 527 | |
528 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
528 | + $this->registerService(\OCP\Security\ICrypto::class, function(Server $c) { |
|
529 | 529 | return new Crypto($c->getConfig(), $c->getSecureRandom()); |
530 | 530 | }); |
531 | 531 | $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
532 | 532 | |
533 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
533 | + $this->registerService(\OCP\Security\IHasher::class, function(Server $c) { |
|
534 | 534 | return new Hasher($c->getConfig()); |
535 | 535 | }); |
536 | 536 | $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
537 | 537 | |
538 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
538 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function(Server $c) { |
|
539 | 539 | return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
540 | 540 | }); |
541 | 541 | $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
542 | 542 | |
543 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
543 | + $this->registerService(IDBConnection::class, function(Server $c) { |
|
544 | 544 | $systemConfig = $c->getSystemConfig(); |
545 | 545 | $factory = new \OC\DB\ConnectionFactory($systemConfig); |
546 | 546 | $type = $systemConfig->getValue('dbtype', 'sqlite'); |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | }); |
555 | 555 | $this->registerAlias('DatabaseConnection', IDBConnection::class); |
556 | 556 | |
557 | - $this->registerService('HTTPHelper', function (Server $c) { |
|
557 | + $this->registerService('HTTPHelper', function(Server $c) { |
|
558 | 558 | $config = $c->getConfig(); |
559 | 559 | return new HTTPHelper( |
560 | 560 | $config, |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | ); |
563 | 563 | }); |
564 | 564 | |
565 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
565 | + $this->registerService(\OCP\Http\Client\IClientService::class, function(Server $c) { |
|
566 | 566 | $user = \OC_User::getUser(); |
567 | 567 | $uid = $user ? $user : null; |
568 | 568 | return new ClientService( |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | }); |
573 | 573 | $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
574 | 574 | |
575 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
575 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function(Server $c) { |
|
576 | 576 | if ($c->getSystemConfig()->getValue('debug', false)) { |
577 | 577 | return new EventLogger(); |
578 | 578 | } else { |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | }); |
582 | 582 | $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
583 | 583 | |
584 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
584 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function(Server $c) { |
|
585 | 585 | if ($c->getSystemConfig()->getValue('debug', false)) { |
586 | 586 | return new QueryLogger(); |
587 | 587 | } else { |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | }); |
591 | 591 | $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
592 | 592 | |
593 | - $this->registerService(TempManager::class, function (Server $c) { |
|
593 | + $this->registerService(TempManager::class, function(Server $c) { |
|
594 | 594 | return new TempManager( |
595 | 595 | $c->getLogger(), |
596 | 596 | $c->getConfig() |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | $this->registerAlias('TempManager', TempManager::class); |
600 | 600 | $this->registerAlias(ITempManager::class, TempManager::class); |
601 | 601 | |
602 | - $this->registerService(AppManager::class, function (Server $c) { |
|
602 | + $this->registerService(AppManager::class, function(Server $c) { |
|
603 | 603 | return new \OC\App\AppManager( |
604 | 604 | $c->getUserSession(), |
605 | 605 | $c->getAppConfig(), |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | $this->registerAlias('AppManager', AppManager::class); |
612 | 612 | $this->registerAlias(IAppManager::class, AppManager::class); |
613 | 613 | |
614 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
614 | + $this->registerService(\OCP\IDateTimeZone::class, function(Server $c) { |
|
615 | 615 | return new DateTimeZone( |
616 | 616 | $c->getConfig(), |
617 | 617 | $c->getSession() |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | }); |
620 | 620 | $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
621 | 621 | |
622 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
622 | + $this->registerService(\OCP\IDateTimeFormatter::class, function(Server $c) { |
|
623 | 623 | $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
624 | 624 | |
625 | 625 | return new DateTimeFormatter( |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | }); |
630 | 630 | $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
631 | 631 | |
632 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
632 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function(Server $c) { |
|
633 | 633 | $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
634 | 634 | $listener = new UserMountCacheListener($mountCache); |
635 | 635 | $listener->listen($c->getUserManager()); |
@@ -637,10 +637,10 @@ discard block |
||
637 | 637 | }); |
638 | 638 | $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
639 | 639 | |
640 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
640 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function(Server $c) { |
|
641 | 641 | $loader = \OC\Files\Filesystem::getLoader(); |
642 | 642 | $mountCache = $c->query('UserMountCache'); |
643 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
643 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
644 | 644 | |
645 | 645 | // builtin providers |
646 | 646 | |
@@ -653,14 +653,14 @@ discard block |
||
653 | 653 | }); |
654 | 654 | $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
655 | 655 | |
656 | - $this->registerService('IniWrapper', function ($c) { |
|
656 | + $this->registerService('IniWrapper', function($c) { |
|
657 | 657 | return new IniGetWrapper(); |
658 | 658 | }); |
659 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
659 | + $this->registerService('AsyncCommandBus', function(Server $c) { |
|
660 | 660 | $jobList = $c->getJobList(); |
661 | 661 | return new AsyncBus($jobList); |
662 | 662 | }); |
663 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
663 | + $this->registerService('TrustedDomainHelper', function($c) { |
|
664 | 664 | return new TrustedDomainHelper($this->getConfig()); |
665 | 665 | }); |
666 | 666 | $this->registerService('Throttler', function(Server $c) { |
@@ -671,10 +671,10 @@ discard block |
||
671 | 671 | $c->getConfig() |
672 | 672 | ); |
673 | 673 | }); |
674 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
674 | + $this->registerService('IntegrityCodeChecker', function(Server $c) { |
|
675 | 675 | // IConfig and IAppManager requires a working database. This code |
676 | 676 | // might however be called when ownCloud is not yet setup. |
677 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
677 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
678 | 678 | $config = $c->getConfig(); |
679 | 679 | $appManager = $c->getAppManager(); |
680 | 680 | } else { |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | $c->getTempManager() |
693 | 693 | ); |
694 | 694 | }); |
695 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
695 | + $this->registerService(\OCP\IRequest::class, function($c) { |
|
696 | 696 | if (isset($this['urlParams'])) { |
697 | 697 | $urlParams = $this['urlParams']; |
698 | 698 | } else { |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | }); |
729 | 729 | $this->registerAlias('Request', \OCP\IRequest::class); |
730 | 730 | |
731 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
731 | + $this->registerService(\OCP\Mail\IMailer::class, function(Server $c) { |
|
732 | 732 | return new Mailer( |
733 | 733 | $c->getConfig(), |
734 | 734 | $c->getLogger(), |
@@ -740,14 +740,14 @@ discard block |
||
740 | 740 | $this->registerService('LDAPProvider', function(Server $c) { |
741 | 741 | $config = $c->getConfig(); |
742 | 742 | $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
743 | - if(is_null($factoryClass)) { |
|
743 | + if (is_null($factoryClass)) { |
|
744 | 744 | throw new \Exception('ldapProviderFactory not set'); |
745 | 745 | } |
746 | 746 | /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
747 | 747 | $factory = new $factoryClass($this); |
748 | 748 | return $factory->getLDAPProvider(); |
749 | 749 | }); |
750 | - $this->registerService('LockingProvider', function (Server $c) { |
|
750 | + $this->registerService('LockingProvider', function(Server $c) { |
|
751 | 751 | $ini = $c->getIniWrapper(); |
752 | 752 | $config = $c->getConfig(); |
753 | 753 | $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
@@ -763,37 +763,37 @@ discard block |
||
763 | 763 | return new NoopLockingProvider(); |
764 | 764 | }); |
765 | 765 | |
766 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
766 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function() { |
|
767 | 767 | return new \OC\Files\Mount\Manager(); |
768 | 768 | }); |
769 | 769 | $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
770 | 770 | |
771 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
771 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function(Server $c) { |
|
772 | 772 | return new \OC\Files\Type\Detection( |
773 | 773 | $c->getURLGenerator(), |
774 | 774 | \OC::$configDir, |
775 | - \OC::$SERVERROOT . '/resources/config/' |
|
775 | + \OC::$SERVERROOT.'/resources/config/' |
|
776 | 776 | ); |
777 | 777 | }); |
778 | 778 | $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
779 | 779 | |
780 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
780 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function(Server $c) { |
|
781 | 781 | return new \OC\Files\Type\Loader( |
782 | 782 | $c->getDatabaseConnection() |
783 | 783 | ); |
784 | 784 | }); |
785 | 785 | $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
786 | 786 | |
787 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
787 | + $this->registerService(\OCP\Notification\IManager::class, function(Server $c) { |
|
788 | 788 | return new Manager( |
789 | 789 | $c->query(IValidator::class) |
790 | 790 | ); |
791 | 791 | }); |
792 | 792 | $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
793 | 793 | |
794 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
794 | + $this->registerService(\OC\CapabilitiesManager::class, function(Server $c) { |
|
795 | 795 | $manager = new \OC\CapabilitiesManager($c->getLogger()); |
796 | - $manager->registerCapability(function () use ($c) { |
|
796 | + $manager->registerCapability(function() use ($c) { |
|
797 | 797 | return new \OC\OCS\CoreCapabilities($c->getConfig()); |
798 | 798 | }); |
799 | 799 | return $manager; |
@@ -835,13 +835,13 @@ discard block |
||
835 | 835 | } |
836 | 836 | return new \OC_Defaults(); |
837 | 837 | }); |
838 | - $this->registerService(EventDispatcher::class, function () { |
|
838 | + $this->registerService(EventDispatcher::class, function() { |
|
839 | 839 | return new EventDispatcher(); |
840 | 840 | }); |
841 | 841 | $this->registerAlias('EventDispatcher', EventDispatcher::class); |
842 | 842 | $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
843 | 843 | |
844 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
844 | + $this->registerService('CryptoWrapper', function(Server $c) { |
|
845 | 845 | // FIXME: Instantiiated here due to cyclic dependency |
846 | 846 | $request = new Request( |
847 | 847 | [ |
@@ -866,7 +866,7 @@ discard block |
||
866 | 866 | $request |
867 | 867 | ); |
868 | 868 | }); |
869 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
869 | + $this->registerService('CsrfTokenManager', function(Server $c) { |
|
870 | 870 | $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
871 | 871 | |
872 | 872 | return new CsrfTokenManager( |
@@ -874,10 +874,10 @@ discard block |
||
874 | 874 | $c->query(SessionStorage::class) |
875 | 875 | ); |
876 | 876 | }); |
877 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
877 | + $this->registerService(SessionStorage::class, function(Server $c) { |
|
878 | 878 | return new SessionStorage($c->getSession()); |
879 | 879 | }); |
880 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
880 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function(Server $c) { |
|
881 | 881 | return new ContentSecurityPolicyManager(); |
882 | 882 | }); |
883 | 883 | $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
@@ -928,23 +928,23 @@ discard block |
||
928 | 928 | ); |
929 | 929 | return $manager; |
930 | 930 | }); |
931 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
931 | + $this->registerService(\OC\Files\AppData\Factory::class, function(Server $c) { |
|
932 | 932 | return new \OC\Files\AppData\Factory( |
933 | 933 | $c->getRootFolder(), |
934 | 934 | $c->getSystemConfig() |
935 | 935 | ); |
936 | 936 | }); |
937 | 937 | |
938 | - $this->registerService('LockdownManager', function (Server $c) { |
|
938 | + $this->registerService('LockdownManager', function(Server $c) { |
|
939 | 939 | return new LockdownManager(); |
940 | 940 | }); |
941 | 941 | |
942 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
942 | + $this->registerService(ICloudIdManager::class, function(Server $c) { |
|
943 | 943 | return new CloudIdManager(); |
944 | 944 | }); |
945 | 945 | |
946 | 946 | /* To trick DI since we don't extend the DIContainer here */ |
947 | - $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
947 | + $this->registerService(CleanPreviewsBackgroundJob::class, function(Server $c) { |
|
948 | 948 | return new CleanPreviewsBackgroundJob( |
949 | 949 | $c->getRootFolder(), |
950 | 950 | $c->getLogger(), |
@@ -1098,7 +1098,7 @@ discard block |
||
1098 | 1098 | * @deprecated since 9.2.0 use IAppData |
1099 | 1099 | */ |
1100 | 1100 | public function getAppFolder() { |
1101 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
1101 | + $dir = '/'.\OC_App::getCurrentApp(); |
|
1102 | 1102 | $root = $this->getRootFolder(); |
1103 | 1103 | if (!$root->nodeExists($dir)) { |
1104 | 1104 | $folder = $root->newFolder($dir); |