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