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