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