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