@@ -243,2058 +243,2058 @@ |
||
| 243 | 243 | */ |
| 244 | 244 | class Server extends ServerContainer implements IServerContainer { |
| 245 | 245 | |
| 246 | - /** @var string */ |
|
| 247 | - private $webRoot; |
|
| 248 | - |
|
| 249 | - /** |
|
| 250 | - * @param string $webRoot |
|
| 251 | - * @param \OC\Config $config |
|
| 252 | - */ |
|
| 253 | - public function __construct($webRoot, \OC\Config $config) { |
|
| 254 | - parent::__construct(); |
|
| 255 | - $this->webRoot = $webRoot; |
|
| 256 | - |
|
| 257 | - // To find out if we are running from CLI or not |
|
| 258 | - $this->registerParameter('isCLI', \OC::$CLI); |
|
| 259 | - $this->registerParameter('serverRoot', \OC::$SERVERROOT); |
|
| 260 | - |
|
| 261 | - $this->registerService(ContainerInterface::class, function (ContainerInterface $c) { |
|
| 262 | - return $c; |
|
| 263 | - }); |
|
| 264 | - $this->registerService(\OCP\IServerContainer::class, function (ContainerInterface $c) { |
|
| 265 | - return $c; |
|
| 266 | - }); |
|
| 267 | - |
|
| 268 | - $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class); |
|
| 269 | - /** @deprecated 19.0.0 */ |
|
| 270 | - $this->registerDeprecatedAlias('CalendarManager', \OC\Calendar\Manager::class); |
|
| 271 | - |
|
| 272 | - $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class); |
|
| 273 | - /** @deprecated 19.0.0 */ |
|
| 274 | - $this->registerDeprecatedAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class); |
|
| 275 | - |
|
| 276 | - $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class); |
|
| 277 | - /** @deprecated 19.0.0 */ |
|
| 278 | - $this->registerDeprecatedAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class); |
|
| 279 | - |
|
| 280 | - $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
| 281 | - /** @deprecated 19.0.0 */ |
|
| 282 | - $this->registerDeprecatedAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
| 283 | - |
|
| 284 | - $this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class); |
|
| 285 | - |
|
| 286 | - $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
| 287 | - |
|
| 288 | - |
|
| 289 | - $this->registerService(IPreview::class, function (Server $c) { |
|
| 290 | - return new PreviewManager( |
|
| 291 | - $c->getConfig(), |
|
| 292 | - $c->getRootFolder(), |
|
| 293 | - new \OC\Preview\Storage\Root($c->getRootFolder(), $c->getSystemConfig()), |
|
| 294 | - $c->getEventDispatcher(), |
|
| 295 | - $c->getGeneratorHelper(), |
|
| 296 | - $c->getSession()->get('user_id') |
|
| 297 | - ); |
|
| 298 | - }); |
|
| 299 | - /** @deprecated 19.0.0 */ |
|
| 300 | - $this->registerDeprecatedAlias('PreviewManager', IPreview::class); |
|
| 301 | - |
|
| 302 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
| 303 | - return new \OC\Preview\Watcher( |
|
| 304 | - new \OC\Preview\Storage\Root($c->getRootFolder(), $c->getSystemConfig()) |
|
| 305 | - ); |
|
| 306 | - }); |
|
| 307 | - |
|
| 308 | - $this->registerService(\OCP\Encryption\IManager::class, function (Server $c) { |
|
| 309 | - $view = new View(); |
|
| 310 | - $util = new Encryption\Util( |
|
| 311 | - $view, |
|
| 312 | - $c->getUserManager(), |
|
| 313 | - $c->getGroupManager(), |
|
| 314 | - $c->getConfig() |
|
| 315 | - ); |
|
| 316 | - return new Encryption\Manager( |
|
| 317 | - $c->getConfig(), |
|
| 318 | - $c->getLogger(), |
|
| 319 | - $c->getL10N('core'), |
|
| 320 | - new View(), |
|
| 321 | - $util, |
|
| 322 | - new ArrayCache() |
|
| 323 | - ); |
|
| 324 | - }); |
|
| 325 | - /** @deprecated 19.0.0 */ |
|
| 326 | - $this->registerDeprecatedAlias('EncryptionManager', \OCP\Encryption\IManager::class); |
|
| 327 | - |
|
| 328 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
| 329 | - $util = new Encryption\Util( |
|
| 330 | - new View(), |
|
| 331 | - $c->getUserManager(), |
|
| 332 | - $c->getGroupManager(), |
|
| 333 | - $c->getConfig() |
|
| 334 | - ); |
|
| 335 | - return new Encryption\File( |
|
| 336 | - $util, |
|
| 337 | - $c->getRootFolder(), |
|
| 338 | - $c->getShareManager() |
|
| 339 | - ); |
|
| 340 | - }); |
|
| 341 | - |
|
| 342 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
| 343 | - $view = new View(); |
|
| 344 | - $util = new Encryption\Util( |
|
| 345 | - $view, |
|
| 346 | - $c->getUserManager(), |
|
| 347 | - $c->getGroupManager(), |
|
| 348 | - $c->getConfig() |
|
| 349 | - ); |
|
| 350 | - |
|
| 351 | - return new Encryption\Keys\Storage($view, $util); |
|
| 352 | - }); |
|
| 353 | - /** @deprecated 20.0.0 */ |
|
| 354 | - $this->registerDeprecatedAlias('TagMapper', TagMapper::class); |
|
| 355 | - |
|
| 356 | - $this->registerAlias(\OCP\ITagManager::class, TagManager::class); |
|
| 357 | - /** @deprecated 19.0.0 */ |
|
| 358 | - $this->registerDeprecatedAlias('TagManager', \OCP\ITagManager::class); |
|
| 359 | - |
|
| 360 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
| 361 | - $config = $c->getConfig(); |
|
| 362 | - $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class); |
|
| 363 | - return new $factoryClass($this); |
|
| 364 | - }); |
|
| 365 | - $this->registerService(ISystemTagManager::class, function (Server $c) { |
|
| 366 | - return $c->query('SystemTagManagerFactory')->getManager(); |
|
| 367 | - }); |
|
| 368 | - /** @deprecated 19.0.0 */ |
|
| 369 | - $this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class); |
|
| 370 | - |
|
| 371 | - $this->registerService(ISystemTagObjectMapper::class, function (Server $c) { |
|
| 372 | - return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
| 373 | - }); |
|
| 374 | - $this->registerService('RootFolder', function (Server $c) { |
|
| 375 | - $manager = \OC\Files\Filesystem::getMountManager(null); |
|
| 376 | - $view = new View(); |
|
| 377 | - $root = new Root( |
|
| 378 | - $manager, |
|
| 379 | - $view, |
|
| 380 | - null, |
|
| 381 | - $c->getUserMountCache(), |
|
| 382 | - $this->getLogger(), |
|
| 383 | - $this->getUserManager() |
|
| 384 | - ); |
|
| 385 | - |
|
| 386 | - $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
| 387 | - $previewConnector->connectWatcher(); |
|
| 388 | - |
|
| 389 | - return $root; |
|
| 390 | - }); |
|
| 391 | - $this->registerService(HookConnector::class, function (Server $c) { |
|
| 392 | - return new HookConnector( |
|
| 393 | - $c->query(IRootFolder::class), |
|
| 394 | - new View(), |
|
| 395 | - $c->query(\OC\EventDispatcher\SymfonyAdapter::class), |
|
| 396 | - $c->query(IEventDispatcher::class) |
|
| 397 | - ); |
|
| 398 | - }); |
|
| 399 | - |
|
| 400 | - /** @deprecated 19.0.0 */ |
|
| 401 | - $this->registerDeprecatedAlias('SystemTagObjectMapper', ISystemTagObjectMapper::class); |
|
| 402 | - |
|
| 403 | - $this->registerService(IRootFolder::class, function (Server $c) { |
|
| 404 | - return new LazyRoot(function () use ($c) { |
|
| 405 | - return $c->query('RootFolder'); |
|
| 406 | - }); |
|
| 407 | - }); |
|
| 408 | - /** @deprecated 19.0.0 */ |
|
| 409 | - $this->registerDeprecatedAlias('LazyRootFolder', IRootFolder::class); |
|
| 410 | - |
|
| 411 | - /** @deprecated 19.0.0 */ |
|
| 412 | - $this->registerDeprecatedAlias('UserManager', \OC\User\Manager::class); |
|
| 413 | - $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); |
|
| 414 | - |
|
| 415 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
| 416 | - $groupManager = new \OC\Group\Manager($this->getUserManager(), $c->getEventDispatcher(), $this->getLogger()); |
|
| 417 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
| 418 | - \OC_Hook::emit('OC_Group', 'pre_createGroup', ['run' => true, 'gid' => $gid]); |
|
| 419 | - |
|
| 420 | - /** @var IEventDispatcher $dispatcher */ |
|
| 421 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 422 | - $dispatcher->dispatchTyped(new BeforeGroupCreatedEvent($gid)); |
|
| 423 | - }); |
|
| 424 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $group) { |
|
| 425 | - \OC_Hook::emit('OC_User', 'post_createGroup', ['gid' => $group->getGID()]); |
|
| 426 | - |
|
| 427 | - /** @var IEventDispatcher $dispatcher */ |
|
| 428 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 429 | - $dispatcher->dispatchTyped(new GroupCreatedEvent($group)); |
|
| 430 | - }); |
|
| 431 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
| 432 | - \OC_Hook::emit('OC_Group', 'pre_deleteGroup', ['run' => true, 'gid' => $group->getGID()]); |
|
| 433 | - |
|
| 434 | - /** @var IEventDispatcher $dispatcher */ |
|
| 435 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 436 | - $dispatcher->dispatchTyped(new BeforeGroupDeletedEvent($group)); |
|
| 437 | - }); |
|
| 438 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
| 439 | - \OC_Hook::emit('OC_User', 'post_deleteGroup', ['gid' => $group->getGID()]); |
|
| 440 | - |
|
| 441 | - /** @var IEventDispatcher $dispatcher */ |
|
| 442 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 443 | - $dispatcher->dispatchTyped(new GroupDeletedEvent($group)); |
|
| 444 | - }); |
|
| 445 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 446 | - \OC_Hook::emit('OC_Group', 'pre_addToGroup', ['run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()]); |
|
| 447 | - |
|
| 448 | - /** @var IEventDispatcher $dispatcher */ |
|
| 449 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 450 | - $dispatcher->dispatchTyped(new BeforeUserAddedEvent($group, $user)); |
|
| 451 | - }); |
|
| 452 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 453 | - \OC_Hook::emit('OC_Group', 'post_addToGroup', ['uid' => $user->getUID(), 'gid' => $group->getGID()]); |
|
| 454 | - //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
| 455 | - \OC_Hook::emit('OC_User', 'post_addToGroup', ['uid' => $user->getUID(), 'gid' => $group->getGID()]); |
|
| 456 | - |
|
| 457 | - /** @var IEventDispatcher $dispatcher */ |
|
| 458 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 459 | - $dispatcher->dispatchTyped(new UserAddedEvent($group, $user)); |
|
| 460 | - }); |
|
| 461 | - $groupManager->listen('\OC\Group', 'preRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 462 | - /** @var IEventDispatcher $dispatcher */ |
|
| 463 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 464 | - $dispatcher->dispatchTyped(new BeforeUserRemovedEvent($group, $user)); |
|
| 465 | - }); |
|
| 466 | - $groupManager->listen('\OC\Group', 'postRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 467 | - /** @var IEventDispatcher $dispatcher */ |
|
| 468 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 469 | - $dispatcher->dispatchTyped(new UserRemovedEvent($group, $user)); |
|
| 470 | - }); |
|
| 471 | - return $groupManager; |
|
| 472 | - }); |
|
| 473 | - /** @deprecated 19.0.0 */ |
|
| 474 | - $this->registerDeprecatedAlias('GroupManager', \OCP\IGroupManager::class); |
|
| 475 | - |
|
| 476 | - $this->registerService(Store::class, function (Server $c) { |
|
| 477 | - $session = $c->getSession(); |
|
| 478 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 479 | - $tokenProvider = $c->query(IProvider::class); |
|
| 480 | - } else { |
|
| 481 | - $tokenProvider = null; |
|
| 482 | - } |
|
| 483 | - $logger = $c->getLogger(); |
|
| 484 | - return new Store($session, $logger, $tokenProvider); |
|
| 485 | - }); |
|
| 486 | - $this->registerAlias(IStore::class, Store::class); |
|
| 487 | - $this->registerAlias(IProvider::class, Authentication\Token\Manager::class); |
|
| 488 | - |
|
| 489 | - $this->registerService(\OC\User\Session::class, function (Server $c) { |
|
| 490 | - $manager = $c->getUserManager(); |
|
| 491 | - $session = new \OC\Session\Memory(''); |
|
| 492 | - $timeFactory = new TimeFactory(); |
|
| 493 | - // Token providers might require a working database. This code |
|
| 494 | - // might however be called when ownCloud is not yet setup. |
|
| 495 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 496 | - $defaultTokenProvider = $c->query(IProvider::class); |
|
| 497 | - } else { |
|
| 498 | - $defaultTokenProvider = null; |
|
| 499 | - } |
|
| 500 | - |
|
| 501 | - $legacyDispatcher = $c->getEventDispatcher(); |
|
| 502 | - |
|
| 503 | - $userSession = new \OC\User\Session( |
|
| 504 | - $manager, |
|
| 505 | - $session, |
|
| 506 | - $timeFactory, |
|
| 507 | - $defaultTokenProvider, |
|
| 508 | - $c->getConfig(), |
|
| 509 | - $c->getSecureRandom(), |
|
| 510 | - $c->getLockdownManager(), |
|
| 511 | - $c->getLogger(), |
|
| 512 | - $c->query(IEventDispatcher::class) |
|
| 513 | - ); |
|
| 514 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
| 515 | - \OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]); |
|
| 516 | - |
|
| 517 | - /** @var IEventDispatcher $dispatcher */ |
|
| 518 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 519 | - $dispatcher->dispatchTyped(new BeforeUserCreatedEvent($uid, $password)); |
|
| 520 | - }); |
|
| 521 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
| 522 | - /** @var \OC\User\User $user */ |
|
| 523 | - \OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]); |
|
| 524 | - |
|
| 525 | - /** @var IEventDispatcher $dispatcher */ |
|
| 526 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 527 | - $dispatcher->dispatchTyped(new UserCreatedEvent($user, $password)); |
|
| 528 | - }); |
|
| 529 | - $userSession->listen('\OC\User', 'preDelete', function ($user) use ($legacyDispatcher) { |
|
| 530 | - /** @var \OC\User\User $user */ |
|
| 531 | - \OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]); |
|
| 532 | - $legacyDispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); |
|
| 533 | - |
|
| 534 | - /** @var IEventDispatcher $dispatcher */ |
|
| 535 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 536 | - $dispatcher->dispatchTyped(new BeforeUserDeletedEvent($user)); |
|
| 537 | - }); |
|
| 538 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
| 539 | - /** @var \OC\User\User $user */ |
|
| 540 | - \OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]); |
|
| 541 | - |
|
| 542 | - /** @var IEventDispatcher $dispatcher */ |
|
| 543 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 544 | - $dispatcher->dispatchTyped(new UserDeletedEvent($user)); |
|
| 545 | - }); |
|
| 546 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 547 | - /** @var \OC\User\User $user */ |
|
| 548 | - \OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]); |
|
| 549 | - |
|
| 550 | - /** @var IEventDispatcher $dispatcher */ |
|
| 551 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 552 | - $dispatcher->dispatchTyped(new BeforePasswordUpdatedEvent($user, $password, $recoveryPassword)); |
|
| 553 | - }); |
|
| 554 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 555 | - /** @var \OC\User\User $user */ |
|
| 556 | - \OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]); |
|
| 557 | - |
|
| 558 | - /** @var IEventDispatcher $dispatcher */ |
|
| 559 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 560 | - $dispatcher->dispatchTyped(new PasswordUpdatedEvent($user, $password, $recoveryPassword)); |
|
| 561 | - }); |
|
| 562 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
| 563 | - \OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]); |
|
| 564 | - |
|
| 565 | - /** @var IEventDispatcher $dispatcher */ |
|
| 566 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 567 | - $dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password)); |
|
| 568 | - }); |
|
| 569 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password, $isTokenLogin) { |
|
| 570 | - /** @var \OC\User\User $user */ |
|
| 571 | - \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'isTokenLogin' => $isTokenLogin]); |
|
| 572 | - |
|
| 573 | - /** @var IEventDispatcher $dispatcher */ |
|
| 574 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 575 | - $dispatcher->dispatchTyped(new UserLoggedInEvent($user, $password, $isTokenLogin)); |
|
| 576 | - }); |
|
| 577 | - $userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) { |
|
| 578 | - /** @var IEventDispatcher $dispatcher */ |
|
| 579 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 580 | - $dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid)); |
|
| 581 | - }); |
|
| 582 | - $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { |
|
| 583 | - /** @var \OC\User\User $user */ |
|
| 584 | - \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]); |
|
| 585 | - |
|
| 586 | - /** @var IEventDispatcher $dispatcher */ |
|
| 587 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 588 | - $dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password)); |
|
| 589 | - }); |
|
| 590 | - $userSession->listen('\OC\User', 'logout', function ($user) { |
|
| 591 | - \OC_Hook::emit('OC_User', 'logout', []); |
|
| 592 | - |
|
| 593 | - /** @var IEventDispatcher $dispatcher */ |
|
| 594 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 595 | - $dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user)); |
|
| 596 | - }); |
|
| 597 | - $userSession->listen('\OC\User', 'postLogout', function ($user) { |
|
| 598 | - /** @var IEventDispatcher $dispatcher */ |
|
| 599 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 600 | - $dispatcher->dispatchTyped(new UserLoggedOutEvent($user)); |
|
| 601 | - }); |
|
| 602 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) { |
|
| 603 | - /** @var \OC\User\User $user */ |
|
| 604 | - \OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]); |
|
| 605 | - |
|
| 606 | - /** @var IEventDispatcher $dispatcher */ |
|
| 607 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 608 | - $dispatcher->dispatchTyped(new UserChangedEvent($user, $feature, $value, $oldValue)); |
|
| 609 | - }); |
|
| 610 | - return $userSession; |
|
| 611 | - }); |
|
| 612 | - $this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class); |
|
| 613 | - /** @deprecated 19.0.0 */ |
|
| 614 | - $this->registerDeprecatedAlias('UserSession', \OC\User\Session::class); |
|
| 615 | - |
|
| 616 | - $this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class); |
|
| 617 | - |
|
| 618 | - $this->registerAlias(INavigationManager::class, \OC\NavigationManager::class); |
|
| 619 | - /** @deprecated 19.0.0 */ |
|
| 620 | - $this->registerDeprecatedAlias('NavigationManager', INavigationManager::class); |
|
| 621 | - |
|
| 622 | - /** @deprecated 19.0.0 */ |
|
| 623 | - $this->registerDeprecatedAlias('AllConfig', \OC\AllConfig::class); |
|
| 624 | - $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
| 625 | - |
|
| 626 | - $this->registerService(\OC\SystemConfig::class, function ($c) use ($config) { |
|
| 627 | - return new \OC\SystemConfig($config); |
|
| 628 | - }); |
|
| 629 | - /** @deprecated 19.0.0 */ |
|
| 630 | - $this->registerDeprecatedAlias('SystemConfig', \OC\SystemConfig::class); |
|
| 631 | - |
|
| 632 | - /** @deprecated 19.0.0 */ |
|
| 633 | - $this->registerDeprecatedAlias('AppConfig', \OC\AppConfig::class); |
|
| 634 | - $this->registerAlias(IAppConfig::class, \OC\AppConfig::class); |
|
| 635 | - |
|
| 636 | - $this->registerService(IFactory::class, function (Server $c) { |
|
| 637 | - return new \OC\L10N\Factory( |
|
| 638 | - $c->getConfig(), |
|
| 639 | - $c->getRequest(), |
|
| 640 | - $c->getUserSession(), |
|
| 641 | - \OC::$SERVERROOT |
|
| 642 | - ); |
|
| 643 | - }); |
|
| 644 | - /** @deprecated 19.0.0 */ |
|
| 645 | - $this->registerDeprecatedAlias('L10NFactory', IFactory::class); |
|
| 646 | - |
|
| 647 | - $this->registerAlias(IURLGenerator::class, URLGenerator::class); |
|
| 648 | - /** @deprecated 19.0.0 */ |
|
| 649 | - $this->registerDeprecatedAlias('URLGenerator', IURLGenerator::class); |
|
| 650 | - |
|
| 651 | - /** @deprecated 19.0.0 */ |
|
| 652 | - $this->registerDeprecatedAlias('AppFetcher', AppFetcher::class); |
|
| 653 | - /** @deprecated 19.0.0 */ |
|
| 654 | - $this->registerDeprecatedAlias('CategoryFetcher', CategoryFetcher::class); |
|
| 655 | - |
|
| 656 | - $this->registerService(ICache::class, function ($c) { |
|
| 657 | - return new Cache\File(); |
|
| 658 | - }); |
|
| 659 | - /** @deprecated 19.0.0 */ |
|
| 660 | - $this->registerDeprecatedAlias('UserCache', ICache::class); |
|
| 661 | - |
|
| 662 | - $this->registerService(Factory::class, function (Server $c) { |
|
| 663 | - $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), |
|
| 664 | - ArrayCache::class, |
|
| 665 | - ArrayCache::class, |
|
| 666 | - ArrayCache::class |
|
| 667 | - ); |
|
| 668 | - $config = $c->getConfig(); |
|
| 669 | - |
|
| 670 | - if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
| 671 | - $v = \OC_App::getAppVersions(); |
|
| 672 | - $v['core'] = implode(',', \OC_Util::getVersion()); |
|
| 673 | - $version = implode(',', $v); |
|
| 674 | - $instanceId = \OC_Util::getInstanceId(); |
|
| 675 | - $path = \OC::$SERVERROOT; |
|
| 676 | - $prefix = md5($instanceId . '-' . $version . '-' . $path); |
|
| 677 | - return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
| 678 | - $config->getSystemValue('memcache.local', null), |
|
| 679 | - $config->getSystemValue('memcache.distributed', null), |
|
| 680 | - $config->getSystemValue('memcache.locking', null) |
|
| 681 | - ); |
|
| 682 | - } |
|
| 683 | - return $arrayCacheFactory; |
|
| 684 | - }); |
|
| 685 | - /** @deprecated 19.0.0 */ |
|
| 686 | - $this->registerDeprecatedAlias('MemCacheFactory', Factory::class); |
|
| 687 | - $this->registerAlias(ICacheFactory::class, Factory::class); |
|
| 688 | - |
|
| 689 | - $this->registerService('RedisFactory', function (Server $c) { |
|
| 690 | - $systemConfig = $c->getSystemConfig(); |
|
| 691 | - return new RedisFactory($systemConfig); |
|
| 692 | - }); |
|
| 693 | - |
|
| 694 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
| 695 | - $l10n = $this->get(IFactory::class)->get('activity'); |
|
| 696 | - return new \OC\Activity\Manager( |
|
| 697 | - $c->getRequest(), |
|
| 698 | - $c->getUserSession(), |
|
| 699 | - $c->getConfig(), |
|
| 700 | - $c->query(IValidator::class), |
|
| 701 | - $l10n |
|
| 702 | - ); |
|
| 703 | - }); |
|
| 704 | - /** @deprecated 19.0.0 */ |
|
| 705 | - $this->registerDeprecatedAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
| 706 | - |
|
| 707 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
| 708 | - return new \OC\Activity\EventMerger( |
|
| 709 | - $c->getL10N('lib') |
|
| 710 | - ); |
|
| 711 | - }); |
|
| 712 | - $this->registerAlias(IValidator::class, Validator::class); |
|
| 713 | - |
|
| 714 | - $this->registerService(AvatarManager::class, function (Server $c) { |
|
| 715 | - return new AvatarManager( |
|
| 716 | - $c->query(\OC\User\Manager::class), |
|
| 717 | - $c->getAppDataDir('avatar'), |
|
| 718 | - $c->getL10N('lib'), |
|
| 719 | - $c->getLogger(), |
|
| 720 | - $c->getConfig() |
|
| 721 | - ); |
|
| 722 | - }); |
|
| 723 | - $this->registerAlias(IAvatarManager::class, AvatarManager::class); |
|
| 724 | - /** @deprecated 19.0.0 */ |
|
| 725 | - $this->registerDeprecatedAlias('AvatarManager', AvatarManager::class); |
|
| 726 | - |
|
| 727 | - $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); |
|
| 728 | - $this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class); |
|
| 729 | - |
|
| 730 | - $this->registerService(\OC\Log::class, function (Server $c) { |
|
| 731 | - $logType = $c->query(AllConfig::class)->getSystemValue('log_type', 'file'); |
|
| 732 | - $factory = new LogFactory($c, $this->getSystemConfig()); |
|
| 733 | - $logger = $factory->get($logType); |
|
| 734 | - $registry = $c->query(\OCP\Support\CrashReport\IRegistry::class); |
|
| 735 | - |
|
| 736 | - return new Log($logger, $this->getSystemConfig(), null, $registry); |
|
| 737 | - }); |
|
| 738 | - $this->registerAlias(ILogger::class, \OC\Log::class); |
|
| 739 | - /** @deprecated 19.0.0 */ |
|
| 740 | - $this->registerDeprecatedAlias('Logger', \OC\Log::class); |
|
| 741 | - // PSR-3 logger |
|
| 742 | - $this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class); |
|
| 743 | - |
|
| 744 | - $this->registerService(ILogFactory::class, function (Server $c) { |
|
| 745 | - return new LogFactory($c, $this->getSystemConfig()); |
|
| 746 | - }); |
|
| 747 | - |
|
| 748 | - $this->registerAlias(IJobList::class, \OC\BackgroundJob\JobList::class); |
|
| 749 | - /** @deprecated 19.0.0 */ |
|
| 750 | - $this->registerDeprecatedAlias('JobList', IJobList::class); |
|
| 751 | - |
|
| 752 | - $this->registerService(IRouter::class, function (Server $c) { |
|
| 753 | - $cacheFactory = $c->getMemCacheFactory(); |
|
| 754 | - $logger = $c->getLogger(); |
|
| 755 | - if ($cacheFactory->isLocalCacheAvailable()) { |
|
| 756 | - $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger); |
|
| 757 | - } else { |
|
| 758 | - $router = new \OC\Route\Router($logger); |
|
| 759 | - } |
|
| 760 | - return $router; |
|
| 761 | - }); |
|
| 762 | - /** @deprecated 19.0.0 */ |
|
| 763 | - $this->registerDeprecatedAlias('Router', IRouter::class); |
|
| 764 | - |
|
| 765 | - $this->registerAlias(ISearch::class, Search::class); |
|
| 766 | - /** @deprecated 19.0.0 */ |
|
| 767 | - $this->registerDeprecatedAlias('Search', ISearch::class); |
|
| 768 | - |
|
| 769 | - $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { |
|
| 770 | - return new \OC\Security\RateLimiting\Backend\MemoryCache( |
|
| 771 | - $this->getMemCacheFactory(), |
|
| 772 | - new \OC\AppFramework\Utility\TimeFactory() |
|
| 773 | - ); |
|
| 774 | - }); |
|
| 775 | - |
|
| 776 | - $this->registerAlias(\OCP\Security\ISecureRandom::class, SecureRandom::class); |
|
| 777 | - /** @deprecated 19.0.0 */ |
|
| 778 | - $this->registerDeprecatedAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
| 779 | - |
|
| 780 | - $this->registerAlias(ICrypto::class, Crypto::class); |
|
| 781 | - /** @deprecated 19.0.0 */ |
|
| 782 | - $this->registerDeprecatedAlias('Crypto', ICrypto::class); |
|
| 783 | - |
|
| 784 | - $this->registerAlias(IHasher::class, Hasher::class); |
|
| 785 | - /** @deprecated 19.0.0 */ |
|
| 786 | - $this->registerDeprecatedAlias('Hasher', IHasher::class); |
|
| 787 | - |
|
| 788 | - $this->registerAlias(ICredentialsManager::class, CredentialsManager::class); |
|
| 789 | - /** @deprecated 19.0.0 */ |
|
| 790 | - $this->registerDeprecatedAlias('CredentialsManager', ICredentialsManager::class); |
|
| 791 | - |
|
| 792 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
| 793 | - $systemConfig = $c->getSystemConfig(); |
|
| 794 | - $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
| 795 | - $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
| 796 | - if (!$factory->isValidType($type)) { |
|
| 797 | - throw new \OC\DatabaseException('Invalid database type'); |
|
| 798 | - } |
|
| 799 | - $connectionParams = $factory->createConnectionParams(); |
|
| 800 | - $connection = $factory->getConnection($type, $connectionParams); |
|
| 801 | - $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
| 802 | - return $connection; |
|
| 803 | - }); |
|
| 804 | - /** @deprecated 19.0.0 */ |
|
| 805 | - $this->registerDeprecatedAlias('DatabaseConnection', IDBConnection::class); |
|
| 806 | - |
|
| 807 | - |
|
| 808 | - $this->registerService(IClientService::class, function (Server $c) { |
|
| 809 | - $user = \OC_User::getUser(); |
|
| 810 | - $uid = $user ? $user : null; |
|
| 811 | - return new ClientService( |
|
| 812 | - $c->getConfig(), |
|
| 813 | - $c->getLogger(), |
|
| 814 | - new \OC\Security\CertificateManager( |
|
| 815 | - $uid, |
|
| 816 | - new View(), |
|
| 817 | - $c->getConfig(), |
|
| 818 | - $c->getLogger(), |
|
| 819 | - $c->getSecureRandom() |
|
| 820 | - ) |
|
| 821 | - ); |
|
| 822 | - }); |
|
| 823 | - /** @deprecated 19.0.0 */ |
|
| 824 | - $this->registerDeprecatedAlias('HttpClientService', IClientService::class); |
|
| 825 | - $this->registerService(IEventLogger::class, function (Server $c) { |
|
| 826 | - $eventLogger = new EventLogger(); |
|
| 827 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
| 828 | - // In debug mode, module is being activated by default |
|
| 829 | - $eventLogger->activate(); |
|
| 830 | - } |
|
| 831 | - return $eventLogger; |
|
| 832 | - }); |
|
| 833 | - /** @deprecated 19.0.0 */ |
|
| 834 | - $this->registerDeprecatedAlias('EventLogger', IEventLogger::class); |
|
| 835 | - |
|
| 836 | - $this->registerService(IQueryLogger::class, function (Server $c) { |
|
| 837 | - $queryLogger = new QueryLogger(); |
|
| 838 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
| 839 | - // In debug mode, module is being activated by default |
|
| 840 | - $queryLogger->activate(); |
|
| 841 | - } |
|
| 842 | - return $queryLogger; |
|
| 843 | - }); |
|
| 844 | - /** @deprecated 19.0.0 */ |
|
| 845 | - $this->registerDeprecatedAlias('QueryLogger', IQueryLogger::class); |
|
| 846 | - |
|
| 847 | - /** @deprecated 19.0.0 */ |
|
| 848 | - $this->registerDeprecatedAlias('TempManager', TempManager::class); |
|
| 849 | - $this->registerAlias(ITempManager::class, TempManager::class); |
|
| 850 | - |
|
| 851 | - $this->registerService(AppManager::class, function (Server $c) { |
|
| 852 | - return new \OC\App\AppManager( |
|
| 853 | - $c->getUserSession(), |
|
| 854 | - $c->getConfig(), |
|
| 855 | - $c->query(\OC\AppConfig::class), |
|
| 856 | - $c->getGroupManager(), |
|
| 857 | - $c->getMemCacheFactory(), |
|
| 858 | - $c->getEventDispatcher(), |
|
| 859 | - $c->getLogger() |
|
| 860 | - ); |
|
| 861 | - }); |
|
| 862 | - /** @deprecated 19.0.0 */ |
|
| 863 | - $this->registerDeprecatedAlias('AppManager', AppManager::class); |
|
| 864 | - $this->registerAlias(IAppManager::class, AppManager::class); |
|
| 865 | - |
|
| 866 | - $this->registerAlias(IDateTimeZone::class, DateTimeZone::class); |
|
| 867 | - /** @deprecated 19.0.0 */ |
|
| 868 | - $this->registerDeprecatedAlias('DateTimeZone', IDateTimeZone::class); |
|
| 869 | - |
|
| 870 | - $this->registerService(IDateTimeFormatter::class, function (Server $c) { |
|
| 871 | - $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
| 872 | - |
|
| 873 | - return new DateTimeFormatter( |
|
| 874 | - $c->getDateTimeZone()->getTimeZone(), |
|
| 875 | - $c->getL10N('lib', $language) |
|
| 876 | - ); |
|
| 877 | - }); |
|
| 878 | - /** @deprecated 19.0.0 */ |
|
| 879 | - $this->registerDeprecatedAlias('DateTimeFormatter', IDateTimeFormatter::class); |
|
| 880 | - |
|
| 881 | - $this->registerService(IUserMountCache::class, function (Server $c) { |
|
| 882 | - $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
| 883 | - $listener = new UserMountCacheListener($mountCache); |
|
| 884 | - $listener->listen($c->getUserManager()); |
|
| 885 | - return $mountCache; |
|
| 886 | - }); |
|
| 887 | - /** @deprecated 19.0.0 */ |
|
| 888 | - $this->registerDeprecatedAlias('UserMountCache', IUserMountCache::class); |
|
| 889 | - |
|
| 890 | - $this->registerService(IMountProviderCollection::class, function (Server $c) { |
|
| 891 | - $loader = \OC\Files\Filesystem::getLoader(); |
|
| 892 | - $mountCache = $c->query(IUserMountCache::class); |
|
| 893 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
| 894 | - |
|
| 895 | - // builtin providers |
|
| 896 | - |
|
| 897 | - $config = $c->getConfig(); |
|
| 898 | - $logger = $c->getLogger(); |
|
| 899 | - $manager->registerProvider(new CacheMountProvider($config)); |
|
| 900 | - $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
| 901 | - $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
| 902 | - $manager->registerRootProvider(new ObjectStorePreviewCacheMountProvider($logger, $config)); |
|
| 903 | - |
|
| 904 | - return $manager; |
|
| 905 | - }); |
|
| 906 | - /** @deprecated 19.0.0 */ |
|
| 907 | - $this->registerDeprecatedAlias('MountConfigManager', IMountProviderCollection::class); |
|
| 908 | - |
|
| 909 | - /** @deprecated 20.0.0 */ |
|
| 910 | - $this->registerDeprecatedAlias('IniWrapper', IniGetWrapper::class); |
|
| 911 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
| 912 | - $busClass = $c->getConfig()->getSystemValue('commandbus'); |
|
| 913 | - if ($busClass) { |
|
| 914 | - [$app, $class] = explode('::', $busClass, 2); |
|
| 915 | - if ($c->getAppManager()->isInstalled($app)) { |
|
| 916 | - \OC_App::loadApp($app); |
|
| 917 | - return $c->query($class); |
|
| 918 | - } else { |
|
| 919 | - throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled"); |
|
| 920 | - } |
|
| 921 | - } else { |
|
| 922 | - $jobList = $c->getJobList(); |
|
| 923 | - return new CronBus($jobList); |
|
| 924 | - } |
|
| 925 | - }); |
|
| 926 | - $this->registerAlias(IBus::class, 'AsyncCommandBus'); |
|
| 927 | - /** @deprecated 20.0.0 */ |
|
| 928 | - $this->registerDeprecatedAlias('TrustedDomainHelper', TrustedDomainHelper::class); |
|
| 929 | - /** @deprecated 19.0.0 */ |
|
| 930 | - $this->registerDeprecatedAlias('Throttler', Throttler::class); |
|
| 931 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
| 932 | - // IConfig and IAppManager requires a working database. This code |
|
| 933 | - // might however be called when ownCloud is not yet setup. |
|
| 934 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 935 | - $config = $c->getConfig(); |
|
| 936 | - $appManager = $c->getAppManager(); |
|
| 937 | - } else { |
|
| 938 | - $config = null; |
|
| 939 | - $appManager = null; |
|
| 940 | - } |
|
| 941 | - |
|
| 942 | - return new Checker( |
|
| 943 | - new EnvironmentHelper(), |
|
| 944 | - new FileAccessHelper(), |
|
| 945 | - new AppLocator(), |
|
| 946 | - $config, |
|
| 947 | - $c->getMemCacheFactory(), |
|
| 948 | - $appManager, |
|
| 949 | - $c->getTempManager(), |
|
| 950 | - $c->getMimeTypeDetector() |
|
| 951 | - ); |
|
| 952 | - }); |
|
| 953 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
| 954 | - if (isset($this['urlParams'])) { |
|
| 955 | - $urlParams = $this['urlParams']; |
|
| 956 | - } else { |
|
| 957 | - $urlParams = []; |
|
| 958 | - } |
|
| 959 | - |
|
| 960 | - if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
| 961 | - && in_array('fakeinput', stream_get_wrappers()) |
|
| 962 | - ) { |
|
| 963 | - $stream = 'fakeinput://data'; |
|
| 964 | - } else { |
|
| 965 | - $stream = 'php://input'; |
|
| 966 | - } |
|
| 967 | - |
|
| 968 | - return new Request( |
|
| 969 | - [ |
|
| 970 | - 'get' => $_GET, |
|
| 971 | - 'post' => $_POST, |
|
| 972 | - 'files' => $_FILES, |
|
| 973 | - 'server' => $_SERVER, |
|
| 974 | - 'env' => $_ENV, |
|
| 975 | - 'cookies' => $_COOKIE, |
|
| 976 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
| 977 | - ? $_SERVER['REQUEST_METHOD'] |
|
| 978 | - : '', |
|
| 979 | - 'urlParams' => $urlParams, |
|
| 980 | - ], |
|
| 981 | - $this->getSecureRandom(), |
|
| 982 | - $this->getConfig(), |
|
| 983 | - $this->getCsrfTokenManager(), |
|
| 984 | - $stream |
|
| 985 | - ); |
|
| 986 | - }); |
|
| 987 | - /** @deprecated 19.0.0 */ |
|
| 988 | - $this->registerDeprecatedAlias('Request', \OCP\IRequest::class); |
|
| 989 | - |
|
| 990 | - $this->registerService(IMailer::class, function (Server $c) { |
|
| 991 | - return new Mailer( |
|
| 992 | - $c->getConfig(), |
|
| 993 | - $c->getLogger(), |
|
| 994 | - $c->query(Defaults::class), |
|
| 995 | - $c->getURLGenerator(), |
|
| 996 | - $c->getL10N('lib'), |
|
| 997 | - $c->query(IEventDispatcher::class), |
|
| 998 | - $c->getL10NFactory() |
|
| 999 | - ); |
|
| 1000 | - }); |
|
| 1001 | - /** @deprecated 19.0.0 */ |
|
| 1002 | - $this->registerDeprecatedAlias('Mailer', IMailer::class); |
|
| 1003 | - |
|
| 1004 | - $this->registerService('LDAPProvider', function (Server $c) { |
|
| 1005 | - $config = $c->getConfig(); |
|
| 1006 | - $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
| 1007 | - if (is_null($factoryClass)) { |
|
| 1008 | - throw new \Exception('ldapProviderFactory not set'); |
|
| 1009 | - } |
|
| 1010 | - /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
| 1011 | - $factory = new $factoryClass($this); |
|
| 1012 | - return $factory->getLDAPProvider(); |
|
| 1013 | - }); |
|
| 1014 | - $this->registerService(ILockingProvider::class, function (Server $c) { |
|
| 1015 | - $ini = $c->getIniWrapper(); |
|
| 1016 | - $config = $c->getConfig(); |
|
| 1017 | - $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
| 1018 | - if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
| 1019 | - /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
| 1020 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
| 1021 | - $memcache = $memcacheFactory->createLocking('lock'); |
|
| 1022 | - if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
| 1023 | - return new MemcacheLockingProvider($memcache, $ttl); |
|
| 1024 | - } |
|
| 1025 | - return new DBLockingProvider( |
|
| 1026 | - $c->getDatabaseConnection(), |
|
| 1027 | - $c->getLogger(), |
|
| 1028 | - new TimeFactory(), |
|
| 1029 | - $ttl, |
|
| 1030 | - !\OC::$CLI |
|
| 1031 | - ); |
|
| 1032 | - } |
|
| 1033 | - return new NoopLockingProvider(); |
|
| 1034 | - }); |
|
| 1035 | - /** @deprecated 19.0.0 */ |
|
| 1036 | - $this->registerDeprecatedAlias('LockingProvider', ILockingProvider::class); |
|
| 1037 | - |
|
| 1038 | - $this->registerAlias(IMountManager::class, \OC\Files\Mount\Manager::class); |
|
| 1039 | - /** @deprecated 19.0.0 */ |
|
| 1040 | - $this->registerDeprecatedAlias('MountManager', IMountManager::class); |
|
| 1041 | - |
|
| 1042 | - $this->registerService(IMimeTypeDetector::class, function (Server $c) { |
|
| 1043 | - return new \OC\Files\Type\Detection( |
|
| 1044 | - $c->getURLGenerator(), |
|
| 1045 | - $c->getLogger(), |
|
| 1046 | - \OC::$configDir, |
|
| 1047 | - \OC::$SERVERROOT . '/resources/config/' |
|
| 1048 | - ); |
|
| 1049 | - }); |
|
| 1050 | - /** @deprecated 19.0.0 */ |
|
| 1051 | - $this->registerDeprecatedAlias('MimeTypeDetector', IMimeTypeDetector::class); |
|
| 1052 | - |
|
| 1053 | - $this->registerAlias(IMimeTypeLoader::class, Loader::class); |
|
| 1054 | - /** @deprecated 19.0.0 */ |
|
| 1055 | - $this->registerDeprecatedAlias('MimeTypeLoader', IMimeTypeLoader::class); |
|
| 1056 | - $this->registerService(BundleFetcher::class, function () { |
|
| 1057 | - return new BundleFetcher($this->getL10N('lib')); |
|
| 1058 | - }); |
|
| 1059 | - $this->registerAlias(\OCP\Notification\IManager::class, Manager::class); |
|
| 1060 | - /** @deprecated 19.0.0 */ |
|
| 1061 | - $this->registerDeprecatedAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
| 1062 | - |
|
| 1063 | - $this->registerService(CapabilitiesManager::class, function (Server $c) { |
|
| 1064 | - $manager = new CapabilitiesManager($c->getLogger()); |
|
| 1065 | - $manager->registerCapability(function () use ($c) { |
|
| 1066 | - return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
| 1067 | - }); |
|
| 1068 | - $manager->registerCapability(function () use ($c) { |
|
| 1069 | - return $c->query(\OC\Security\Bruteforce\Capabilities::class); |
|
| 1070 | - }); |
|
| 1071 | - return $manager; |
|
| 1072 | - }); |
|
| 1073 | - /** @deprecated 19.0.0 */ |
|
| 1074 | - $this->registerDeprecatedAlias('CapabilitiesManager', CapabilitiesManager::class); |
|
| 1075 | - |
|
| 1076 | - $this->registerService(ICommentsManager::class, function (Server $c) { |
|
| 1077 | - $config = $c->getConfig(); |
|
| 1078 | - $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class); |
|
| 1079 | - /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
| 1080 | - $factory = new $factoryClass($this); |
|
| 1081 | - $manager = $factory->getManager(); |
|
| 1082 | - |
|
| 1083 | - $manager->registerDisplayNameResolver('user', function ($id) use ($c) { |
|
| 1084 | - $manager = $c->getUserManager(); |
|
| 1085 | - $user = $manager->get($id); |
|
| 1086 | - if (is_null($user)) { |
|
| 1087 | - $l = $c->getL10N('core'); |
|
| 1088 | - $displayName = $l->t('Unknown user'); |
|
| 1089 | - } else { |
|
| 1090 | - $displayName = $user->getDisplayName(); |
|
| 1091 | - } |
|
| 1092 | - return $displayName; |
|
| 1093 | - }); |
|
| 1094 | - |
|
| 1095 | - return $manager; |
|
| 1096 | - }); |
|
| 1097 | - /** @deprecated 19.0.0 */ |
|
| 1098 | - $this->registerDeprecatedAlias('CommentsManager', ICommentsManager::class); |
|
| 1099 | - |
|
| 1100 | - $this->registerAlias(\OC_Defaults::class, 'ThemingDefaults'); |
|
| 1101 | - $this->registerService('ThemingDefaults', function (Server $c) { |
|
| 1102 | - /* |
|
| 246 | + /** @var string */ |
|
| 247 | + private $webRoot; |
|
| 248 | + |
|
| 249 | + /** |
|
| 250 | + * @param string $webRoot |
|
| 251 | + * @param \OC\Config $config |
|
| 252 | + */ |
|
| 253 | + public function __construct($webRoot, \OC\Config $config) { |
|
| 254 | + parent::__construct(); |
|
| 255 | + $this->webRoot = $webRoot; |
|
| 256 | + |
|
| 257 | + // To find out if we are running from CLI or not |
|
| 258 | + $this->registerParameter('isCLI', \OC::$CLI); |
|
| 259 | + $this->registerParameter('serverRoot', \OC::$SERVERROOT); |
|
| 260 | + |
|
| 261 | + $this->registerService(ContainerInterface::class, function (ContainerInterface $c) { |
|
| 262 | + return $c; |
|
| 263 | + }); |
|
| 264 | + $this->registerService(\OCP\IServerContainer::class, function (ContainerInterface $c) { |
|
| 265 | + return $c; |
|
| 266 | + }); |
|
| 267 | + |
|
| 268 | + $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class); |
|
| 269 | + /** @deprecated 19.0.0 */ |
|
| 270 | + $this->registerDeprecatedAlias('CalendarManager', \OC\Calendar\Manager::class); |
|
| 271 | + |
|
| 272 | + $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class); |
|
| 273 | + /** @deprecated 19.0.0 */ |
|
| 274 | + $this->registerDeprecatedAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class); |
|
| 275 | + |
|
| 276 | + $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class); |
|
| 277 | + /** @deprecated 19.0.0 */ |
|
| 278 | + $this->registerDeprecatedAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class); |
|
| 279 | + |
|
| 280 | + $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
| 281 | + /** @deprecated 19.0.0 */ |
|
| 282 | + $this->registerDeprecatedAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
| 283 | + |
|
| 284 | + $this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class); |
|
| 285 | + |
|
| 286 | + $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
| 287 | + |
|
| 288 | + |
|
| 289 | + $this->registerService(IPreview::class, function (Server $c) { |
|
| 290 | + return new PreviewManager( |
|
| 291 | + $c->getConfig(), |
|
| 292 | + $c->getRootFolder(), |
|
| 293 | + new \OC\Preview\Storage\Root($c->getRootFolder(), $c->getSystemConfig()), |
|
| 294 | + $c->getEventDispatcher(), |
|
| 295 | + $c->getGeneratorHelper(), |
|
| 296 | + $c->getSession()->get('user_id') |
|
| 297 | + ); |
|
| 298 | + }); |
|
| 299 | + /** @deprecated 19.0.0 */ |
|
| 300 | + $this->registerDeprecatedAlias('PreviewManager', IPreview::class); |
|
| 301 | + |
|
| 302 | + $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
| 303 | + return new \OC\Preview\Watcher( |
|
| 304 | + new \OC\Preview\Storage\Root($c->getRootFolder(), $c->getSystemConfig()) |
|
| 305 | + ); |
|
| 306 | + }); |
|
| 307 | + |
|
| 308 | + $this->registerService(\OCP\Encryption\IManager::class, function (Server $c) { |
|
| 309 | + $view = new View(); |
|
| 310 | + $util = new Encryption\Util( |
|
| 311 | + $view, |
|
| 312 | + $c->getUserManager(), |
|
| 313 | + $c->getGroupManager(), |
|
| 314 | + $c->getConfig() |
|
| 315 | + ); |
|
| 316 | + return new Encryption\Manager( |
|
| 317 | + $c->getConfig(), |
|
| 318 | + $c->getLogger(), |
|
| 319 | + $c->getL10N('core'), |
|
| 320 | + new View(), |
|
| 321 | + $util, |
|
| 322 | + new ArrayCache() |
|
| 323 | + ); |
|
| 324 | + }); |
|
| 325 | + /** @deprecated 19.0.0 */ |
|
| 326 | + $this->registerDeprecatedAlias('EncryptionManager', \OCP\Encryption\IManager::class); |
|
| 327 | + |
|
| 328 | + $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
| 329 | + $util = new Encryption\Util( |
|
| 330 | + new View(), |
|
| 331 | + $c->getUserManager(), |
|
| 332 | + $c->getGroupManager(), |
|
| 333 | + $c->getConfig() |
|
| 334 | + ); |
|
| 335 | + return new Encryption\File( |
|
| 336 | + $util, |
|
| 337 | + $c->getRootFolder(), |
|
| 338 | + $c->getShareManager() |
|
| 339 | + ); |
|
| 340 | + }); |
|
| 341 | + |
|
| 342 | + $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
| 343 | + $view = new View(); |
|
| 344 | + $util = new Encryption\Util( |
|
| 345 | + $view, |
|
| 346 | + $c->getUserManager(), |
|
| 347 | + $c->getGroupManager(), |
|
| 348 | + $c->getConfig() |
|
| 349 | + ); |
|
| 350 | + |
|
| 351 | + return new Encryption\Keys\Storage($view, $util); |
|
| 352 | + }); |
|
| 353 | + /** @deprecated 20.0.0 */ |
|
| 354 | + $this->registerDeprecatedAlias('TagMapper', TagMapper::class); |
|
| 355 | + |
|
| 356 | + $this->registerAlias(\OCP\ITagManager::class, TagManager::class); |
|
| 357 | + /** @deprecated 19.0.0 */ |
|
| 358 | + $this->registerDeprecatedAlias('TagManager', \OCP\ITagManager::class); |
|
| 359 | + |
|
| 360 | + $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
| 361 | + $config = $c->getConfig(); |
|
| 362 | + $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class); |
|
| 363 | + return new $factoryClass($this); |
|
| 364 | + }); |
|
| 365 | + $this->registerService(ISystemTagManager::class, function (Server $c) { |
|
| 366 | + return $c->query('SystemTagManagerFactory')->getManager(); |
|
| 367 | + }); |
|
| 368 | + /** @deprecated 19.0.0 */ |
|
| 369 | + $this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class); |
|
| 370 | + |
|
| 371 | + $this->registerService(ISystemTagObjectMapper::class, function (Server $c) { |
|
| 372 | + return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
| 373 | + }); |
|
| 374 | + $this->registerService('RootFolder', function (Server $c) { |
|
| 375 | + $manager = \OC\Files\Filesystem::getMountManager(null); |
|
| 376 | + $view = new View(); |
|
| 377 | + $root = new Root( |
|
| 378 | + $manager, |
|
| 379 | + $view, |
|
| 380 | + null, |
|
| 381 | + $c->getUserMountCache(), |
|
| 382 | + $this->getLogger(), |
|
| 383 | + $this->getUserManager() |
|
| 384 | + ); |
|
| 385 | + |
|
| 386 | + $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
| 387 | + $previewConnector->connectWatcher(); |
|
| 388 | + |
|
| 389 | + return $root; |
|
| 390 | + }); |
|
| 391 | + $this->registerService(HookConnector::class, function (Server $c) { |
|
| 392 | + return new HookConnector( |
|
| 393 | + $c->query(IRootFolder::class), |
|
| 394 | + new View(), |
|
| 395 | + $c->query(\OC\EventDispatcher\SymfonyAdapter::class), |
|
| 396 | + $c->query(IEventDispatcher::class) |
|
| 397 | + ); |
|
| 398 | + }); |
|
| 399 | + |
|
| 400 | + /** @deprecated 19.0.0 */ |
|
| 401 | + $this->registerDeprecatedAlias('SystemTagObjectMapper', ISystemTagObjectMapper::class); |
|
| 402 | + |
|
| 403 | + $this->registerService(IRootFolder::class, function (Server $c) { |
|
| 404 | + return new LazyRoot(function () use ($c) { |
|
| 405 | + return $c->query('RootFolder'); |
|
| 406 | + }); |
|
| 407 | + }); |
|
| 408 | + /** @deprecated 19.0.0 */ |
|
| 409 | + $this->registerDeprecatedAlias('LazyRootFolder', IRootFolder::class); |
|
| 410 | + |
|
| 411 | + /** @deprecated 19.0.0 */ |
|
| 412 | + $this->registerDeprecatedAlias('UserManager', \OC\User\Manager::class); |
|
| 413 | + $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); |
|
| 414 | + |
|
| 415 | + $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
| 416 | + $groupManager = new \OC\Group\Manager($this->getUserManager(), $c->getEventDispatcher(), $this->getLogger()); |
|
| 417 | + $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
| 418 | + \OC_Hook::emit('OC_Group', 'pre_createGroup', ['run' => true, 'gid' => $gid]); |
|
| 419 | + |
|
| 420 | + /** @var IEventDispatcher $dispatcher */ |
|
| 421 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 422 | + $dispatcher->dispatchTyped(new BeforeGroupCreatedEvent($gid)); |
|
| 423 | + }); |
|
| 424 | + $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $group) { |
|
| 425 | + \OC_Hook::emit('OC_User', 'post_createGroup', ['gid' => $group->getGID()]); |
|
| 426 | + |
|
| 427 | + /** @var IEventDispatcher $dispatcher */ |
|
| 428 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 429 | + $dispatcher->dispatchTyped(new GroupCreatedEvent($group)); |
|
| 430 | + }); |
|
| 431 | + $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
| 432 | + \OC_Hook::emit('OC_Group', 'pre_deleteGroup', ['run' => true, 'gid' => $group->getGID()]); |
|
| 433 | + |
|
| 434 | + /** @var IEventDispatcher $dispatcher */ |
|
| 435 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 436 | + $dispatcher->dispatchTyped(new BeforeGroupDeletedEvent($group)); |
|
| 437 | + }); |
|
| 438 | + $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
| 439 | + \OC_Hook::emit('OC_User', 'post_deleteGroup', ['gid' => $group->getGID()]); |
|
| 440 | + |
|
| 441 | + /** @var IEventDispatcher $dispatcher */ |
|
| 442 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 443 | + $dispatcher->dispatchTyped(new GroupDeletedEvent($group)); |
|
| 444 | + }); |
|
| 445 | + $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 446 | + \OC_Hook::emit('OC_Group', 'pre_addToGroup', ['run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()]); |
|
| 447 | + |
|
| 448 | + /** @var IEventDispatcher $dispatcher */ |
|
| 449 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 450 | + $dispatcher->dispatchTyped(new BeforeUserAddedEvent($group, $user)); |
|
| 451 | + }); |
|
| 452 | + $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 453 | + \OC_Hook::emit('OC_Group', 'post_addToGroup', ['uid' => $user->getUID(), 'gid' => $group->getGID()]); |
|
| 454 | + //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
| 455 | + \OC_Hook::emit('OC_User', 'post_addToGroup', ['uid' => $user->getUID(), 'gid' => $group->getGID()]); |
|
| 456 | + |
|
| 457 | + /** @var IEventDispatcher $dispatcher */ |
|
| 458 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 459 | + $dispatcher->dispatchTyped(new UserAddedEvent($group, $user)); |
|
| 460 | + }); |
|
| 461 | + $groupManager->listen('\OC\Group', 'preRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 462 | + /** @var IEventDispatcher $dispatcher */ |
|
| 463 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 464 | + $dispatcher->dispatchTyped(new BeforeUserRemovedEvent($group, $user)); |
|
| 465 | + }); |
|
| 466 | + $groupManager->listen('\OC\Group', 'postRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 467 | + /** @var IEventDispatcher $dispatcher */ |
|
| 468 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 469 | + $dispatcher->dispatchTyped(new UserRemovedEvent($group, $user)); |
|
| 470 | + }); |
|
| 471 | + return $groupManager; |
|
| 472 | + }); |
|
| 473 | + /** @deprecated 19.0.0 */ |
|
| 474 | + $this->registerDeprecatedAlias('GroupManager', \OCP\IGroupManager::class); |
|
| 475 | + |
|
| 476 | + $this->registerService(Store::class, function (Server $c) { |
|
| 477 | + $session = $c->getSession(); |
|
| 478 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 479 | + $tokenProvider = $c->query(IProvider::class); |
|
| 480 | + } else { |
|
| 481 | + $tokenProvider = null; |
|
| 482 | + } |
|
| 483 | + $logger = $c->getLogger(); |
|
| 484 | + return new Store($session, $logger, $tokenProvider); |
|
| 485 | + }); |
|
| 486 | + $this->registerAlias(IStore::class, Store::class); |
|
| 487 | + $this->registerAlias(IProvider::class, Authentication\Token\Manager::class); |
|
| 488 | + |
|
| 489 | + $this->registerService(\OC\User\Session::class, function (Server $c) { |
|
| 490 | + $manager = $c->getUserManager(); |
|
| 491 | + $session = new \OC\Session\Memory(''); |
|
| 492 | + $timeFactory = new TimeFactory(); |
|
| 493 | + // Token providers might require a working database. This code |
|
| 494 | + // might however be called when ownCloud is not yet setup. |
|
| 495 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 496 | + $defaultTokenProvider = $c->query(IProvider::class); |
|
| 497 | + } else { |
|
| 498 | + $defaultTokenProvider = null; |
|
| 499 | + } |
|
| 500 | + |
|
| 501 | + $legacyDispatcher = $c->getEventDispatcher(); |
|
| 502 | + |
|
| 503 | + $userSession = new \OC\User\Session( |
|
| 504 | + $manager, |
|
| 505 | + $session, |
|
| 506 | + $timeFactory, |
|
| 507 | + $defaultTokenProvider, |
|
| 508 | + $c->getConfig(), |
|
| 509 | + $c->getSecureRandom(), |
|
| 510 | + $c->getLockdownManager(), |
|
| 511 | + $c->getLogger(), |
|
| 512 | + $c->query(IEventDispatcher::class) |
|
| 513 | + ); |
|
| 514 | + $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
| 515 | + \OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]); |
|
| 516 | + |
|
| 517 | + /** @var IEventDispatcher $dispatcher */ |
|
| 518 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 519 | + $dispatcher->dispatchTyped(new BeforeUserCreatedEvent($uid, $password)); |
|
| 520 | + }); |
|
| 521 | + $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
| 522 | + /** @var \OC\User\User $user */ |
|
| 523 | + \OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]); |
|
| 524 | + |
|
| 525 | + /** @var IEventDispatcher $dispatcher */ |
|
| 526 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 527 | + $dispatcher->dispatchTyped(new UserCreatedEvent($user, $password)); |
|
| 528 | + }); |
|
| 529 | + $userSession->listen('\OC\User', 'preDelete', function ($user) use ($legacyDispatcher) { |
|
| 530 | + /** @var \OC\User\User $user */ |
|
| 531 | + \OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]); |
|
| 532 | + $legacyDispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); |
|
| 533 | + |
|
| 534 | + /** @var IEventDispatcher $dispatcher */ |
|
| 535 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 536 | + $dispatcher->dispatchTyped(new BeforeUserDeletedEvent($user)); |
|
| 537 | + }); |
|
| 538 | + $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
| 539 | + /** @var \OC\User\User $user */ |
|
| 540 | + \OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]); |
|
| 541 | + |
|
| 542 | + /** @var IEventDispatcher $dispatcher */ |
|
| 543 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 544 | + $dispatcher->dispatchTyped(new UserDeletedEvent($user)); |
|
| 545 | + }); |
|
| 546 | + $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 547 | + /** @var \OC\User\User $user */ |
|
| 548 | + \OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]); |
|
| 549 | + |
|
| 550 | + /** @var IEventDispatcher $dispatcher */ |
|
| 551 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 552 | + $dispatcher->dispatchTyped(new BeforePasswordUpdatedEvent($user, $password, $recoveryPassword)); |
|
| 553 | + }); |
|
| 554 | + $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 555 | + /** @var \OC\User\User $user */ |
|
| 556 | + \OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]); |
|
| 557 | + |
|
| 558 | + /** @var IEventDispatcher $dispatcher */ |
|
| 559 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 560 | + $dispatcher->dispatchTyped(new PasswordUpdatedEvent($user, $password, $recoveryPassword)); |
|
| 561 | + }); |
|
| 562 | + $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
| 563 | + \OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]); |
|
| 564 | + |
|
| 565 | + /** @var IEventDispatcher $dispatcher */ |
|
| 566 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 567 | + $dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password)); |
|
| 568 | + }); |
|
| 569 | + $userSession->listen('\OC\User', 'postLogin', function ($user, $password, $isTokenLogin) { |
|
| 570 | + /** @var \OC\User\User $user */ |
|
| 571 | + \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'isTokenLogin' => $isTokenLogin]); |
|
| 572 | + |
|
| 573 | + /** @var IEventDispatcher $dispatcher */ |
|
| 574 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 575 | + $dispatcher->dispatchTyped(new UserLoggedInEvent($user, $password, $isTokenLogin)); |
|
| 576 | + }); |
|
| 577 | + $userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) { |
|
| 578 | + /** @var IEventDispatcher $dispatcher */ |
|
| 579 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 580 | + $dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid)); |
|
| 581 | + }); |
|
| 582 | + $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { |
|
| 583 | + /** @var \OC\User\User $user */ |
|
| 584 | + \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]); |
|
| 585 | + |
|
| 586 | + /** @var IEventDispatcher $dispatcher */ |
|
| 587 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 588 | + $dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password)); |
|
| 589 | + }); |
|
| 590 | + $userSession->listen('\OC\User', 'logout', function ($user) { |
|
| 591 | + \OC_Hook::emit('OC_User', 'logout', []); |
|
| 592 | + |
|
| 593 | + /** @var IEventDispatcher $dispatcher */ |
|
| 594 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 595 | + $dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user)); |
|
| 596 | + }); |
|
| 597 | + $userSession->listen('\OC\User', 'postLogout', function ($user) { |
|
| 598 | + /** @var IEventDispatcher $dispatcher */ |
|
| 599 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 600 | + $dispatcher->dispatchTyped(new UserLoggedOutEvent($user)); |
|
| 601 | + }); |
|
| 602 | + $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) { |
|
| 603 | + /** @var \OC\User\User $user */ |
|
| 604 | + \OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]); |
|
| 605 | + |
|
| 606 | + /** @var IEventDispatcher $dispatcher */ |
|
| 607 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 608 | + $dispatcher->dispatchTyped(new UserChangedEvent($user, $feature, $value, $oldValue)); |
|
| 609 | + }); |
|
| 610 | + return $userSession; |
|
| 611 | + }); |
|
| 612 | + $this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class); |
|
| 613 | + /** @deprecated 19.0.0 */ |
|
| 614 | + $this->registerDeprecatedAlias('UserSession', \OC\User\Session::class); |
|
| 615 | + |
|
| 616 | + $this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class); |
|
| 617 | + |
|
| 618 | + $this->registerAlias(INavigationManager::class, \OC\NavigationManager::class); |
|
| 619 | + /** @deprecated 19.0.0 */ |
|
| 620 | + $this->registerDeprecatedAlias('NavigationManager', INavigationManager::class); |
|
| 621 | + |
|
| 622 | + /** @deprecated 19.0.0 */ |
|
| 623 | + $this->registerDeprecatedAlias('AllConfig', \OC\AllConfig::class); |
|
| 624 | + $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
| 625 | + |
|
| 626 | + $this->registerService(\OC\SystemConfig::class, function ($c) use ($config) { |
|
| 627 | + return new \OC\SystemConfig($config); |
|
| 628 | + }); |
|
| 629 | + /** @deprecated 19.0.0 */ |
|
| 630 | + $this->registerDeprecatedAlias('SystemConfig', \OC\SystemConfig::class); |
|
| 631 | + |
|
| 632 | + /** @deprecated 19.0.0 */ |
|
| 633 | + $this->registerDeprecatedAlias('AppConfig', \OC\AppConfig::class); |
|
| 634 | + $this->registerAlias(IAppConfig::class, \OC\AppConfig::class); |
|
| 635 | + |
|
| 636 | + $this->registerService(IFactory::class, function (Server $c) { |
|
| 637 | + return new \OC\L10N\Factory( |
|
| 638 | + $c->getConfig(), |
|
| 639 | + $c->getRequest(), |
|
| 640 | + $c->getUserSession(), |
|
| 641 | + \OC::$SERVERROOT |
|
| 642 | + ); |
|
| 643 | + }); |
|
| 644 | + /** @deprecated 19.0.0 */ |
|
| 645 | + $this->registerDeprecatedAlias('L10NFactory', IFactory::class); |
|
| 646 | + |
|
| 647 | + $this->registerAlias(IURLGenerator::class, URLGenerator::class); |
|
| 648 | + /** @deprecated 19.0.0 */ |
|
| 649 | + $this->registerDeprecatedAlias('URLGenerator', IURLGenerator::class); |
|
| 650 | + |
|
| 651 | + /** @deprecated 19.0.0 */ |
|
| 652 | + $this->registerDeprecatedAlias('AppFetcher', AppFetcher::class); |
|
| 653 | + /** @deprecated 19.0.0 */ |
|
| 654 | + $this->registerDeprecatedAlias('CategoryFetcher', CategoryFetcher::class); |
|
| 655 | + |
|
| 656 | + $this->registerService(ICache::class, function ($c) { |
|
| 657 | + return new Cache\File(); |
|
| 658 | + }); |
|
| 659 | + /** @deprecated 19.0.0 */ |
|
| 660 | + $this->registerDeprecatedAlias('UserCache', ICache::class); |
|
| 661 | + |
|
| 662 | + $this->registerService(Factory::class, function (Server $c) { |
|
| 663 | + $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), |
|
| 664 | + ArrayCache::class, |
|
| 665 | + ArrayCache::class, |
|
| 666 | + ArrayCache::class |
|
| 667 | + ); |
|
| 668 | + $config = $c->getConfig(); |
|
| 669 | + |
|
| 670 | + if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
| 671 | + $v = \OC_App::getAppVersions(); |
|
| 672 | + $v['core'] = implode(',', \OC_Util::getVersion()); |
|
| 673 | + $version = implode(',', $v); |
|
| 674 | + $instanceId = \OC_Util::getInstanceId(); |
|
| 675 | + $path = \OC::$SERVERROOT; |
|
| 676 | + $prefix = md5($instanceId . '-' . $version . '-' . $path); |
|
| 677 | + return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
| 678 | + $config->getSystemValue('memcache.local', null), |
|
| 679 | + $config->getSystemValue('memcache.distributed', null), |
|
| 680 | + $config->getSystemValue('memcache.locking', null) |
|
| 681 | + ); |
|
| 682 | + } |
|
| 683 | + return $arrayCacheFactory; |
|
| 684 | + }); |
|
| 685 | + /** @deprecated 19.0.0 */ |
|
| 686 | + $this->registerDeprecatedAlias('MemCacheFactory', Factory::class); |
|
| 687 | + $this->registerAlias(ICacheFactory::class, Factory::class); |
|
| 688 | + |
|
| 689 | + $this->registerService('RedisFactory', function (Server $c) { |
|
| 690 | + $systemConfig = $c->getSystemConfig(); |
|
| 691 | + return new RedisFactory($systemConfig); |
|
| 692 | + }); |
|
| 693 | + |
|
| 694 | + $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
| 695 | + $l10n = $this->get(IFactory::class)->get('activity'); |
|
| 696 | + return new \OC\Activity\Manager( |
|
| 697 | + $c->getRequest(), |
|
| 698 | + $c->getUserSession(), |
|
| 699 | + $c->getConfig(), |
|
| 700 | + $c->query(IValidator::class), |
|
| 701 | + $l10n |
|
| 702 | + ); |
|
| 703 | + }); |
|
| 704 | + /** @deprecated 19.0.0 */ |
|
| 705 | + $this->registerDeprecatedAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
| 706 | + |
|
| 707 | + $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
| 708 | + return new \OC\Activity\EventMerger( |
|
| 709 | + $c->getL10N('lib') |
|
| 710 | + ); |
|
| 711 | + }); |
|
| 712 | + $this->registerAlias(IValidator::class, Validator::class); |
|
| 713 | + |
|
| 714 | + $this->registerService(AvatarManager::class, function (Server $c) { |
|
| 715 | + return new AvatarManager( |
|
| 716 | + $c->query(\OC\User\Manager::class), |
|
| 717 | + $c->getAppDataDir('avatar'), |
|
| 718 | + $c->getL10N('lib'), |
|
| 719 | + $c->getLogger(), |
|
| 720 | + $c->getConfig() |
|
| 721 | + ); |
|
| 722 | + }); |
|
| 723 | + $this->registerAlias(IAvatarManager::class, AvatarManager::class); |
|
| 724 | + /** @deprecated 19.0.0 */ |
|
| 725 | + $this->registerDeprecatedAlias('AvatarManager', AvatarManager::class); |
|
| 726 | + |
|
| 727 | + $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); |
|
| 728 | + $this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class); |
|
| 729 | + |
|
| 730 | + $this->registerService(\OC\Log::class, function (Server $c) { |
|
| 731 | + $logType = $c->query(AllConfig::class)->getSystemValue('log_type', 'file'); |
|
| 732 | + $factory = new LogFactory($c, $this->getSystemConfig()); |
|
| 733 | + $logger = $factory->get($logType); |
|
| 734 | + $registry = $c->query(\OCP\Support\CrashReport\IRegistry::class); |
|
| 735 | + |
|
| 736 | + return new Log($logger, $this->getSystemConfig(), null, $registry); |
|
| 737 | + }); |
|
| 738 | + $this->registerAlias(ILogger::class, \OC\Log::class); |
|
| 739 | + /** @deprecated 19.0.0 */ |
|
| 740 | + $this->registerDeprecatedAlias('Logger', \OC\Log::class); |
|
| 741 | + // PSR-3 logger |
|
| 742 | + $this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class); |
|
| 743 | + |
|
| 744 | + $this->registerService(ILogFactory::class, function (Server $c) { |
|
| 745 | + return new LogFactory($c, $this->getSystemConfig()); |
|
| 746 | + }); |
|
| 747 | + |
|
| 748 | + $this->registerAlias(IJobList::class, \OC\BackgroundJob\JobList::class); |
|
| 749 | + /** @deprecated 19.0.0 */ |
|
| 750 | + $this->registerDeprecatedAlias('JobList', IJobList::class); |
|
| 751 | + |
|
| 752 | + $this->registerService(IRouter::class, function (Server $c) { |
|
| 753 | + $cacheFactory = $c->getMemCacheFactory(); |
|
| 754 | + $logger = $c->getLogger(); |
|
| 755 | + if ($cacheFactory->isLocalCacheAvailable()) { |
|
| 756 | + $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger); |
|
| 757 | + } else { |
|
| 758 | + $router = new \OC\Route\Router($logger); |
|
| 759 | + } |
|
| 760 | + return $router; |
|
| 761 | + }); |
|
| 762 | + /** @deprecated 19.0.0 */ |
|
| 763 | + $this->registerDeprecatedAlias('Router', IRouter::class); |
|
| 764 | + |
|
| 765 | + $this->registerAlias(ISearch::class, Search::class); |
|
| 766 | + /** @deprecated 19.0.0 */ |
|
| 767 | + $this->registerDeprecatedAlias('Search', ISearch::class); |
|
| 768 | + |
|
| 769 | + $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { |
|
| 770 | + return new \OC\Security\RateLimiting\Backend\MemoryCache( |
|
| 771 | + $this->getMemCacheFactory(), |
|
| 772 | + new \OC\AppFramework\Utility\TimeFactory() |
|
| 773 | + ); |
|
| 774 | + }); |
|
| 775 | + |
|
| 776 | + $this->registerAlias(\OCP\Security\ISecureRandom::class, SecureRandom::class); |
|
| 777 | + /** @deprecated 19.0.0 */ |
|
| 778 | + $this->registerDeprecatedAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
| 779 | + |
|
| 780 | + $this->registerAlias(ICrypto::class, Crypto::class); |
|
| 781 | + /** @deprecated 19.0.0 */ |
|
| 782 | + $this->registerDeprecatedAlias('Crypto', ICrypto::class); |
|
| 783 | + |
|
| 784 | + $this->registerAlias(IHasher::class, Hasher::class); |
|
| 785 | + /** @deprecated 19.0.0 */ |
|
| 786 | + $this->registerDeprecatedAlias('Hasher', IHasher::class); |
|
| 787 | + |
|
| 788 | + $this->registerAlias(ICredentialsManager::class, CredentialsManager::class); |
|
| 789 | + /** @deprecated 19.0.0 */ |
|
| 790 | + $this->registerDeprecatedAlias('CredentialsManager', ICredentialsManager::class); |
|
| 791 | + |
|
| 792 | + $this->registerService(IDBConnection::class, function (Server $c) { |
|
| 793 | + $systemConfig = $c->getSystemConfig(); |
|
| 794 | + $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
| 795 | + $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
| 796 | + if (!$factory->isValidType($type)) { |
|
| 797 | + throw new \OC\DatabaseException('Invalid database type'); |
|
| 798 | + } |
|
| 799 | + $connectionParams = $factory->createConnectionParams(); |
|
| 800 | + $connection = $factory->getConnection($type, $connectionParams); |
|
| 801 | + $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
| 802 | + return $connection; |
|
| 803 | + }); |
|
| 804 | + /** @deprecated 19.0.0 */ |
|
| 805 | + $this->registerDeprecatedAlias('DatabaseConnection', IDBConnection::class); |
|
| 806 | + |
|
| 807 | + |
|
| 808 | + $this->registerService(IClientService::class, function (Server $c) { |
|
| 809 | + $user = \OC_User::getUser(); |
|
| 810 | + $uid = $user ? $user : null; |
|
| 811 | + return new ClientService( |
|
| 812 | + $c->getConfig(), |
|
| 813 | + $c->getLogger(), |
|
| 814 | + new \OC\Security\CertificateManager( |
|
| 815 | + $uid, |
|
| 816 | + new View(), |
|
| 817 | + $c->getConfig(), |
|
| 818 | + $c->getLogger(), |
|
| 819 | + $c->getSecureRandom() |
|
| 820 | + ) |
|
| 821 | + ); |
|
| 822 | + }); |
|
| 823 | + /** @deprecated 19.0.0 */ |
|
| 824 | + $this->registerDeprecatedAlias('HttpClientService', IClientService::class); |
|
| 825 | + $this->registerService(IEventLogger::class, function (Server $c) { |
|
| 826 | + $eventLogger = new EventLogger(); |
|
| 827 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
| 828 | + // In debug mode, module is being activated by default |
|
| 829 | + $eventLogger->activate(); |
|
| 830 | + } |
|
| 831 | + return $eventLogger; |
|
| 832 | + }); |
|
| 833 | + /** @deprecated 19.0.0 */ |
|
| 834 | + $this->registerDeprecatedAlias('EventLogger', IEventLogger::class); |
|
| 835 | + |
|
| 836 | + $this->registerService(IQueryLogger::class, function (Server $c) { |
|
| 837 | + $queryLogger = new QueryLogger(); |
|
| 838 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
| 839 | + // In debug mode, module is being activated by default |
|
| 840 | + $queryLogger->activate(); |
|
| 841 | + } |
|
| 842 | + return $queryLogger; |
|
| 843 | + }); |
|
| 844 | + /** @deprecated 19.0.0 */ |
|
| 845 | + $this->registerDeprecatedAlias('QueryLogger', IQueryLogger::class); |
|
| 846 | + |
|
| 847 | + /** @deprecated 19.0.0 */ |
|
| 848 | + $this->registerDeprecatedAlias('TempManager', TempManager::class); |
|
| 849 | + $this->registerAlias(ITempManager::class, TempManager::class); |
|
| 850 | + |
|
| 851 | + $this->registerService(AppManager::class, function (Server $c) { |
|
| 852 | + return new \OC\App\AppManager( |
|
| 853 | + $c->getUserSession(), |
|
| 854 | + $c->getConfig(), |
|
| 855 | + $c->query(\OC\AppConfig::class), |
|
| 856 | + $c->getGroupManager(), |
|
| 857 | + $c->getMemCacheFactory(), |
|
| 858 | + $c->getEventDispatcher(), |
|
| 859 | + $c->getLogger() |
|
| 860 | + ); |
|
| 861 | + }); |
|
| 862 | + /** @deprecated 19.0.0 */ |
|
| 863 | + $this->registerDeprecatedAlias('AppManager', AppManager::class); |
|
| 864 | + $this->registerAlias(IAppManager::class, AppManager::class); |
|
| 865 | + |
|
| 866 | + $this->registerAlias(IDateTimeZone::class, DateTimeZone::class); |
|
| 867 | + /** @deprecated 19.0.0 */ |
|
| 868 | + $this->registerDeprecatedAlias('DateTimeZone', IDateTimeZone::class); |
|
| 869 | + |
|
| 870 | + $this->registerService(IDateTimeFormatter::class, function (Server $c) { |
|
| 871 | + $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
| 872 | + |
|
| 873 | + return new DateTimeFormatter( |
|
| 874 | + $c->getDateTimeZone()->getTimeZone(), |
|
| 875 | + $c->getL10N('lib', $language) |
|
| 876 | + ); |
|
| 877 | + }); |
|
| 878 | + /** @deprecated 19.0.0 */ |
|
| 879 | + $this->registerDeprecatedAlias('DateTimeFormatter', IDateTimeFormatter::class); |
|
| 880 | + |
|
| 881 | + $this->registerService(IUserMountCache::class, function (Server $c) { |
|
| 882 | + $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
| 883 | + $listener = new UserMountCacheListener($mountCache); |
|
| 884 | + $listener->listen($c->getUserManager()); |
|
| 885 | + return $mountCache; |
|
| 886 | + }); |
|
| 887 | + /** @deprecated 19.0.0 */ |
|
| 888 | + $this->registerDeprecatedAlias('UserMountCache', IUserMountCache::class); |
|
| 889 | + |
|
| 890 | + $this->registerService(IMountProviderCollection::class, function (Server $c) { |
|
| 891 | + $loader = \OC\Files\Filesystem::getLoader(); |
|
| 892 | + $mountCache = $c->query(IUserMountCache::class); |
|
| 893 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
| 894 | + |
|
| 895 | + // builtin providers |
|
| 896 | + |
|
| 897 | + $config = $c->getConfig(); |
|
| 898 | + $logger = $c->getLogger(); |
|
| 899 | + $manager->registerProvider(new CacheMountProvider($config)); |
|
| 900 | + $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
| 901 | + $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
| 902 | + $manager->registerRootProvider(new ObjectStorePreviewCacheMountProvider($logger, $config)); |
|
| 903 | + |
|
| 904 | + return $manager; |
|
| 905 | + }); |
|
| 906 | + /** @deprecated 19.0.0 */ |
|
| 907 | + $this->registerDeprecatedAlias('MountConfigManager', IMountProviderCollection::class); |
|
| 908 | + |
|
| 909 | + /** @deprecated 20.0.0 */ |
|
| 910 | + $this->registerDeprecatedAlias('IniWrapper', IniGetWrapper::class); |
|
| 911 | + $this->registerService('AsyncCommandBus', function (Server $c) { |
|
| 912 | + $busClass = $c->getConfig()->getSystemValue('commandbus'); |
|
| 913 | + if ($busClass) { |
|
| 914 | + [$app, $class] = explode('::', $busClass, 2); |
|
| 915 | + if ($c->getAppManager()->isInstalled($app)) { |
|
| 916 | + \OC_App::loadApp($app); |
|
| 917 | + return $c->query($class); |
|
| 918 | + } else { |
|
| 919 | + throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled"); |
|
| 920 | + } |
|
| 921 | + } else { |
|
| 922 | + $jobList = $c->getJobList(); |
|
| 923 | + return new CronBus($jobList); |
|
| 924 | + } |
|
| 925 | + }); |
|
| 926 | + $this->registerAlias(IBus::class, 'AsyncCommandBus'); |
|
| 927 | + /** @deprecated 20.0.0 */ |
|
| 928 | + $this->registerDeprecatedAlias('TrustedDomainHelper', TrustedDomainHelper::class); |
|
| 929 | + /** @deprecated 19.0.0 */ |
|
| 930 | + $this->registerDeprecatedAlias('Throttler', Throttler::class); |
|
| 931 | + $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
| 932 | + // IConfig and IAppManager requires a working database. This code |
|
| 933 | + // might however be called when ownCloud is not yet setup. |
|
| 934 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 935 | + $config = $c->getConfig(); |
|
| 936 | + $appManager = $c->getAppManager(); |
|
| 937 | + } else { |
|
| 938 | + $config = null; |
|
| 939 | + $appManager = null; |
|
| 940 | + } |
|
| 941 | + |
|
| 942 | + return new Checker( |
|
| 943 | + new EnvironmentHelper(), |
|
| 944 | + new FileAccessHelper(), |
|
| 945 | + new AppLocator(), |
|
| 946 | + $config, |
|
| 947 | + $c->getMemCacheFactory(), |
|
| 948 | + $appManager, |
|
| 949 | + $c->getTempManager(), |
|
| 950 | + $c->getMimeTypeDetector() |
|
| 951 | + ); |
|
| 952 | + }); |
|
| 953 | + $this->registerService(\OCP\IRequest::class, function ($c) { |
|
| 954 | + if (isset($this['urlParams'])) { |
|
| 955 | + $urlParams = $this['urlParams']; |
|
| 956 | + } else { |
|
| 957 | + $urlParams = []; |
|
| 958 | + } |
|
| 959 | + |
|
| 960 | + if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
| 961 | + && in_array('fakeinput', stream_get_wrappers()) |
|
| 962 | + ) { |
|
| 963 | + $stream = 'fakeinput://data'; |
|
| 964 | + } else { |
|
| 965 | + $stream = 'php://input'; |
|
| 966 | + } |
|
| 967 | + |
|
| 968 | + return new Request( |
|
| 969 | + [ |
|
| 970 | + 'get' => $_GET, |
|
| 971 | + 'post' => $_POST, |
|
| 972 | + 'files' => $_FILES, |
|
| 973 | + 'server' => $_SERVER, |
|
| 974 | + 'env' => $_ENV, |
|
| 975 | + 'cookies' => $_COOKIE, |
|
| 976 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
| 977 | + ? $_SERVER['REQUEST_METHOD'] |
|
| 978 | + : '', |
|
| 979 | + 'urlParams' => $urlParams, |
|
| 980 | + ], |
|
| 981 | + $this->getSecureRandom(), |
|
| 982 | + $this->getConfig(), |
|
| 983 | + $this->getCsrfTokenManager(), |
|
| 984 | + $stream |
|
| 985 | + ); |
|
| 986 | + }); |
|
| 987 | + /** @deprecated 19.0.0 */ |
|
| 988 | + $this->registerDeprecatedAlias('Request', \OCP\IRequest::class); |
|
| 989 | + |
|
| 990 | + $this->registerService(IMailer::class, function (Server $c) { |
|
| 991 | + return new Mailer( |
|
| 992 | + $c->getConfig(), |
|
| 993 | + $c->getLogger(), |
|
| 994 | + $c->query(Defaults::class), |
|
| 995 | + $c->getURLGenerator(), |
|
| 996 | + $c->getL10N('lib'), |
|
| 997 | + $c->query(IEventDispatcher::class), |
|
| 998 | + $c->getL10NFactory() |
|
| 999 | + ); |
|
| 1000 | + }); |
|
| 1001 | + /** @deprecated 19.0.0 */ |
|
| 1002 | + $this->registerDeprecatedAlias('Mailer', IMailer::class); |
|
| 1003 | + |
|
| 1004 | + $this->registerService('LDAPProvider', function (Server $c) { |
|
| 1005 | + $config = $c->getConfig(); |
|
| 1006 | + $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
| 1007 | + if (is_null($factoryClass)) { |
|
| 1008 | + throw new \Exception('ldapProviderFactory not set'); |
|
| 1009 | + } |
|
| 1010 | + /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
| 1011 | + $factory = new $factoryClass($this); |
|
| 1012 | + return $factory->getLDAPProvider(); |
|
| 1013 | + }); |
|
| 1014 | + $this->registerService(ILockingProvider::class, function (Server $c) { |
|
| 1015 | + $ini = $c->getIniWrapper(); |
|
| 1016 | + $config = $c->getConfig(); |
|
| 1017 | + $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
| 1018 | + if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
| 1019 | + /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
| 1020 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
| 1021 | + $memcache = $memcacheFactory->createLocking('lock'); |
|
| 1022 | + if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
| 1023 | + return new MemcacheLockingProvider($memcache, $ttl); |
|
| 1024 | + } |
|
| 1025 | + return new DBLockingProvider( |
|
| 1026 | + $c->getDatabaseConnection(), |
|
| 1027 | + $c->getLogger(), |
|
| 1028 | + new TimeFactory(), |
|
| 1029 | + $ttl, |
|
| 1030 | + !\OC::$CLI |
|
| 1031 | + ); |
|
| 1032 | + } |
|
| 1033 | + return new NoopLockingProvider(); |
|
| 1034 | + }); |
|
| 1035 | + /** @deprecated 19.0.0 */ |
|
| 1036 | + $this->registerDeprecatedAlias('LockingProvider', ILockingProvider::class); |
|
| 1037 | + |
|
| 1038 | + $this->registerAlias(IMountManager::class, \OC\Files\Mount\Manager::class); |
|
| 1039 | + /** @deprecated 19.0.0 */ |
|
| 1040 | + $this->registerDeprecatedAlias('MountManager', IMountManager::class); |
|
| 1041 | + |
|
| 1042 | + $this->registerService(IMimeTypeDetector::class, function (Server $c) { |
|
| 1043 | + return new \OC\Files\Type\Detection( |
|
| 1044 | + $c->getURLGenerator(), |
|
| 1045 | + $c->getLogger(), |
|
| 1046 | + \OC::$configDir, |
|
| 1047 | + \OC::$SERVERROOT . '/resources/config/' |
|
| 1048 | + ); |
|
| 1049 | + }); |
|
| 1050 | + /** @deprecated 19.0.0 */ |
|
| 1051 | + $this->registerDeprecatedAlias('MimeTypeDetector', IMimeTypeDetector::class); |
|
| 1052 | + |
|
| 1053 | + $this->registerAlias(IMimeTypeLoader::class, Loader::class); |
|
| 1054 | + /** @deprecated 19.0.0 */ |
|
| 1055 | + $this->registerDeprecatedAlias('MimeTypeLoader', IMimeTypeLoader::class); |
|
| 1056 | + $this->registerService(BundleFetcher::class, function () { |
|
| 1057 | + return new BundleFetcher($this->getL10N('lib')); |
|
| 1058 | + }); |
|
| 1059 | + $this->registerAlias(\OCP\Notification\IManager::class, Manager::class); |
|
| 1060 | + /** @deprecated 19.0.0 */ |
|
| 1061 | + $this->registerDeprecatedAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
| 1062 | + |
|
| 1063 | + $this->registerService(CapabilitiesManager::class, function (Server $c) { |
|
| 1064 | + $manager = new CapabilitiesManager($c->getLogger()); |
|
| 1065 | + $manager->registerCapability(function () use ($c) { |
|
| 1066 | + return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
| 1067 | + }); |
|
| 1068 | + $manager->registerCapability(function () use ($c) { |
|
| 1069 | + return $c->query(\OC\Security\Bruteforce\Capabilities::class); |
|
| 1070 | + }); |
|
| 1071 | + return $manager; |
|
| 1072 | + }); |
|
| 1073 | + /** @deprecated 19.0.0 */ |
|
| 1074 | + $this->registerDeprecatedAlias('CapabilitiesManager', CapabilitiesManager::class); |
|
| 1075 | + |
|
| 1076 | + $this->registerService(ICommentsManager::class, function (Server $c) { |
|
| 1077 | + $config = $c->getConfig(); |
|
| 1078 | + $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class); |
|
| 1079 | + /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
| 1080 | + $factory = new $factoryClass($this); |
|
| 1081 | + $manager = $factory->getManager(); |
|
| 1082 | + |
|
| 1083 | + $manager->registerDisplayNameResolver('user', function ($id) use ($c) { |
|
| 1084 | + $manager = $c->getUserManager(); |
|
| 1085 | + $user = $manager->get($id); |
|
| 1086 | + if (is_null($user)) { |
|
| 1087 | + $l = $c->getL10N('core'); |
|
| 1088 | + $displayName = $l->t('Unknown user'); |
|
| 1089 | + } else { |
|
| 1090 | + $displayName = $user->getDisplayName(); |
|
| 1091 | + } |
|
| 1092 | + return $displayName; |
|
| 1093 | + }); |
|
| 1094 | + |
|
| 1095 | + return $manager; |
|
| 1096 | + }); |
|
| 1097 | + /** @deprecated 19.0.0 */ |
|
| 1098 | + $this->registerDeprecatedAlias('CommentsManager', ICommentsManager::class); |
|
| 1099 | + |
|
| 1100 | + $this->registerAlias(\OC_Defaults::class, 'ThemingDefaults'); |
|
| 1101 | + $this->registerService('ThemingDefaults', function (Server $c) { |
|
| 1102 | + /* |
|
| 1103 | 1103 | * Dark magic for autoloader. |
| 1104 | 1104 | * If we do a class_exists it will try to load the class which will |
| 1105 | 1105 | * make composer cache the result. Resulting in errors when enabling |
| 1106 | 1106 | * the theming app. |
| 1107 | 1107 | */ |
| 1108 | - $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
| 1109 | - if (isset($prefixes['OCA\\Theming\\'])) { |
|
| 1110 | - $classExists = true; |
|
| 1111 | - } else { |
|
| 1112 | - $classExists = false; |
|
| 1113 | - } |
|
| 1114 | - |
|
| 1115 | - if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) { |
|
| 1116 | - return new ThemingDefaults( |
|
| 1117 | - $c->getConfig(), |
|
| 1118 | - $c->getL10N('theming'), |
|
| 1119 | - $c->getURLGenerator(), |
|
| 1120 | - $c->getMemCacheFactory(), |
|
| 1121 | - new Util($c->getConfig(), $this->getAppManager(), $c->getAppDataDir('theming')), |
|
| 1122 | - new ImageManager($c->getConfig(), $c->getAppDataDir('theming'), $c->getURLGenerator(), $this->getMemCacheFactory(), $this->getLogger()), |
|
| 1123 | - $c->getAppManager(), |
|
| 1124 | - $c->getNavigationManager() |
|
| 1125 | - ); |
|
| 1126 | - } |
|
| 1127 | - return new \OC_Defaults(); |
|
| 1128 | - }); |
|
| 1129 | - $this->registerService(JSCombiner::class, function (Server $c) { |
|
| 1130 | - return new JSCombiner( |
|
| 1131 | - $c->getAppDataDir('js'), |
|
| 1132 | - $c->getURLGenerator(), |
|
| 1133 | - $this->getMemCacheFactory(), |
|
| 1134 | - $c->getSystemConfig(), |
|
| 1135 | - $c->getLogger() |
|
| 1136 | - ); |
|
| 1137 | - }); |
|
| 1138 | - $this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class); |
|
| 1139 | - /** @deprecated 19.0.0 */ |
|
| 1140 | - $this->registerDeprecatedAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class); |
|
| 1141 | - $this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class); |
|
| 1142 | - |
|
| 1143 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
| 1144 | - // FIXME: Instantiiated here due to cyclic dependency |
|
| 1145 | - $request = new Request( |
|
| 1146 | - [ |
|
| 1147 | - 'get' => $_GET, |
|
| 1148 | - 'post' => $_POST, |
|
| 1149 | - 'files' => $_FILES, |
|
| 1150 | - 'server' => $_SERVER, |
|
| 1151 | - 'env' => $_ENV, |
|
| 1152 | - 'cookies' => $_COOKIE, |
|
| 1153 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
| 1154 | - ? $_SERVER['REQUEST_METHOD'] |
|
| 1155 | - : null, |
|
| 1156 | - ], |
|
| 1157 | - $c->getSecureRandom(), |
|
| 1158 | - $c->getConfig() |
|
| 1159 | - ); |
|
| 1160 | - |
|
| 1161 | - return new CryptoWrapper( |
|
| 1162 | - $c->getConfig(), |
|
| 1163 | - $c->getCrypto(), |
|
| 1164 | - $c->getSecureRandom(), |
|
| 1165 | - $request |
|
| 1166 | - ); |
|
| 1167 | - }); |
|
| 1168 | - /** @deprecated 19.0.0 */ |
|
| 1169 | - $this->registerDeprecatedAlias('CsrfTokenManager', CsrfTokenManager::class); |
|
| 1170 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
| 1171 | - return new SessionStorage($c->getSession()); |
|
| 1172 | - }); |
|
| 1173 | - $this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class); |
|
| 1174 | - /** @deprecated 19.0.0 */ |
|
| 1175 | - $this->registerDeprecatedAlias('ContentSecurityPolicyManager', ContentSecurityPolicyManager::class); |
|
| 1176 | - |
|
| 1177 | - $this->registerService(\OCP\Share\IManager::class, function (Server $c) { |
|
| 1178 | - $config = $c->getConfig(); |
|
| 1179 | - $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class); |
|
| 1180 | - /** @var \OCP\Share\IProviderFactory $factory */ |
|
| 1181 | - $factory = new $factoryClass($this); |
|
| 1182 | - |
|
| 1183 | - $manager = new \OC\Share20\Manager( |
|
| 1184 | - $c->getLogger(), |
|
| 1185 | - $c->getConfig(), |
|
| 1186 | - $c->getSecureRandom(), |
|
| 1187 | - $c->getHasher(), |
|
| 1188 | - $c->getMountManager(), |
|
| 1189 | - $c->getGroupManager(), |
|
| 1190 | - $c->getL10N('lib'), |
|
| 1191 | - $c->getL10NFactory(), |
|
| 1192 | - $factory, |
|
| 1193 | - $c->getUserManager(), |
|
| 1194 | - $c->getLazyRootFolder(), |
|
| 1195 | - $c->getEventDispatcher(), |
|
| 1196 | - $c->getMailer(), |
|
| 1197 | - $c->getURLGenerator(), |
|
| 1198 | - $c->getThemingDefaults(), |
|
| 1199 | - $c->query(IEventDispatcher::class) |
|
| 1200 | - ); |
|
| 1201 | - |
|
| 1202 | - return $manager; |
|
| 1203 | - }); |
|
| 1204 | - /** @deprecated 19.0.0 */ |
|
| 1205 | - $this->registerDeprecatedAlias('ShareManager', \OCP\Share\IManager::class); |
|
| 1206 | - |
|
| 1207 | - $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) { |
|
| 1208 | - $instance = new Collaboration\Collaborators\Search($c); |
|
| 1209 | - |
|
| 1210 | - // register default plugins |
|
| 1211 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]); |
|
| 1212 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]); |
|
| 1213 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]); |
|
| 1214 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]); |
|
| 1215 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]); |
|
| 1216 | - |
|
| 1217 | - return $instance; |
|
| 1218 | - }); |
|
| 1219 | - /** @deprecated 19.0.0 */ |
|
| 1220 | - $this->registerDeprecatedAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class); |
|
| 1221 | - $this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class); |
|
| 1222 | - |
|
| 1223 | - $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); |
|
| 1224 | - |
|
| 1225 | - $this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class); |
|
| 1226 | - $this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class); |
|
| 1227 | - |
|
| 1228 | - $this->registerService('SettingsManager', function (Server $c) { |
|
| 1229 | - $manager = new \OC\Settings\Manager( |
|
| 1230 | - $c->getLogger(), |
|
| 1231 | - $c->getL10NFactory(), |
|
| 1232 | - $c->getURLGenerator(), |
|
| 1233 | - $c |
|
| 1234 | - ); |
|
| 1235 | - return $manager; |
|
| 1236 | - }); |
|
| 1237 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
| 1238 | - return new \OC\Files\AppData\Factory( |
|
| 1239 | - $c->getRootFolder(), |
|
| 1240 | - $c->getSystemConfig() |
|
| 1241 | - ); |
|
| 1242 | - }); |
|
| 1243 | - |
|
| 1244 | - $this->registerService('LockdownManager', function (Server $c) { |
|
| 1245 | - return new LockdownManager(function () use ($c) { |
|
| 1246 | - return $c->getSession(); |
|
| 1247 | - }); |
|
| 1248 | - }); |
|
| 1249 | - |
|
| 1250 | - $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
| 1251 | - return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
| 1252 | - }); |
|
| 1253 | - |
|
| 1254 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
| 1255 | - return new CloudIdManager(); |
|
| 1256 | - }); |
|
| 1257 | - |
|
| 1258 | - $this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class); |
|
| 1259 | - |
|
| 1260 | - $this->registerService(ICloudFederationProviderManager::class, function (Server $c) { |
|
| 1261 | - return new CloudFederationProviderManager($c->getAppManager(), $c->getHTTPClientService(), $c->getCloudIdManager(), $c->getLogger()); |
|
| 1262 | - }); |
|
| 1263 | - |
|
| 1264 | - $this->registerService(ICloudFederationFactory::class, function (Server $c) { |
|
| 1265 | - return new CloudFederationFactory(); |
|
| 1266 | - }); |
|
| 1267 | - |
|
| 1268 | - $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
| 1269 | - /** @deprecated 19.0.0 */ |
|
| 1270 | - $this->registerDeprecatedAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
| 1271 | - |
|
| 1272 | - $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
| 1273 | - /** @deprecated 19.0.0 */ |
|
| 1274 | - $this->registerDeprecatedAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
| 1275 | - |
|
| 1276 | - $this->registerService(Defaults::class, function (Server $c) { |
|
| 1277 | - return new Defaults( |
|
| 1278 | - $c->getThemingDefaults() |
|
| 1279 | - ); |
|
| 1280 | - }); |
|
| 1281 | - /** @deprecated 19.0.0 */ |
|
| 1282 | - $this->registerDeprecatedAlias('Defaults', \OCP\Defaults::class); |
|
| 1283 | - |
|
| 1284 | - $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { |
|
| 1285 | - return $c->query(\OCP\IUserSession::class)->getSession(); |
|
| 1286 | - }); |
|
| 1287 | - |
|
| 1288 | - $this->registerService(IShareHelper::class, function (Server $c) { |
|
| 1289 | - return new ShareHelper( |
|
| 1290 | - $c->query(\OCP\Share\IManager::class) |
|
| 1291 | - ); |
|
| 1292 | - }); |
|
| 1293 | - |
|
| 1294 | - $this->registerService(Installer::class, function (Server $c) { |
|
| 1295 | - return new Installer( |
|
| 1296 | - $c->getAppFetcher(), |
|
| 1297 | - $c->getHTTPClientService(), |
|
| 1298 | - $c->getTempManager(), |
|
| 1299 | - $c->getLogger(), |
|
| 1300 | - $c->getConfig(), |
|
| 1301 | - \OC::$CLI |
|
| 1302 | - ); |
|
| 1303 | - }); |
|
| 1304 | - |
|
| 1305 | - $this->registerService(IApiFactory::class, function (Server $c) { |
|
| 1306 | - return new ApiFactory($c->getHTTPClientService()); |
|
| 1307 | - }); |
|
| 1308 | - |
|
| 1309 | - $this->registerService(IInstanceFactory::class, function (Server $c) { |
|
| 1310 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
| 1311 | - return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService()); |
|
| 1312 | - }); |
|
| 1313 | - |
|
| 1314 | - $this->registerAlias(IContactsStore::class, ContactsStore::class); |
|
| 1315 | - $this->registerAlias(IAccountManager::class, AccountManager::class); |
|
| 1316 | - |
|
| 1317 | - $this->registerAlias(IStorageFactory::class, StorageFactory::class); |
|
| 1318 | - |
|
| 1319 | - $this->registerAlias(IDashboardManager::class, DashboardManager::class); |
|
| 1320 | - $this->registerAlias(\OCP\Dashboard\IManager::class, \OC\Dashboard\Manager::class); |
|
| 1321 | - $this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class); |
|
| 1322 | - |
|
| 1323 | - $this->registerAlias(ISubAdmin::class, SubAdmin::class); |
|
| 1324 | - |
|
| 1325 | - $this->registerAlias(IInitialStateService::class, InitialStateService::class); |
|
| 1326 | - |
|
| 1327 | - $this->registerAlias(\OCP\UserStatus\IManager::class, \OC\UserStatus\Manager::class); |
|
| 1328 | - |
|
| 1329 | - $this->connectDispatcher(); |
|
| 1330 | - } |
|
| 1331 | - |
|
| 1332 | - public function boot() { |
|
| 1333 | - /** @var HookConnector $hookConnector */ |
|
| 1334 | - $hookConnector = $this->query(HookConnector::class); |
|
| 1335 | - $hookConnector->viewToNode(); |
|
| 1336 | - } |
|
| 1337 | - |
|
| 1338 | - /** |
|
| 1339 | - * @return \OCP\Calendar\IManager |
|
| 1340 | - * @deprecated |
|
| 1341 | - */ |
|
| 1342 | - public function getCalendarManager() { |
|
| 1343 | - return $this->query(\OC\Calendar\Manager::class); |
|
| 1344 | - } |
|
| 1345 | - |
|
| 1346 | - /** |
|
| 1347 | - * @return \OCP\Calendar\Resource\IManager |
|
| 1348 | - * @deprecated |
|
| 1349 | - */ |
|
| 1350 | - public function getCalendarResourceBackendManager() { |
|
| 1351 | - return $this->query(\OC\Calendar\Resource\Manager::class); |
|
| 1352 | - } |
|
| 1353 | - |
|
| 1354 | - /** |
|
| 1355 | - * @return \OCP\Calendar\Room\IManager |
|
| 1356 | - * @deprecated |
|
| 1357 | - */ |
|
| 1358 | - public function getCalendarRoomBackendManager() { |
|
| 1359 | - return $this->query(\OC\Calendar\Room\Manager::class); |
|
| 1360 | - } |
|
| 1361 | - |
|
| 1362 | - private function connectDispatcher() { |
|
| 1363 | - $dispatcher = $this->getEventDispatcher(); |
|
| 1364 | - |
|
| 1365 | - // Delete avatar on user deletion |
|
| 1366 | - $dispatcher->addListener('OCP\IUser::preDelete', function (GenericEvent $e) { |
|
| 1367 | - $logger = $this->getLogger(); |
|
| 1368 | - $manager = $this->getAvatarManager(); |
|
| 1369 | - /** @var IUser $user */ |
|
| 1370 | - $user = $e->getSubject(); |
|
| 1371 | - |
|
| 1372 | - try { |
|
| 1373 | - $avatar = $manager->getAvatar($user->getUID()); |
|
| 1374 | - $avatar->remove(); |
|
| 1375 | - } catch (NotFoundException $e) { |
|
| 1376 | - // no avatar to remove |
|
| 1377 | - } catch (\Exception $e) { |
|
| 1378 | - // Ignore exceptions |
|
| 1379 | - $logger->info('Could not cleanup avatar of ' . $user->getUID()); |
|
| 1380 | - } |
|
| 1381 | - }); |
|
| 1382 | - |
|
| 1383 | - $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { |
|
| 1384 | - $manager = $this->getAvatarManager(); |
|
| 1385 | - /** @var IUser $user */ |
|
| 1386 | - $user = $e->getSubject(); |
|
| 1387 | - $feature = $e->getArgument('feature'); |
|
| 1388 | - $oldValue = $e->getArgument('oldValue'); |
|
| 1389 | - $value = $e->getArgument('value'); |
|
| 1390 | - |
|
| 1391 | - // We only change the avatar on display name changes |
|
| 1392 | - if ($feature !== 'displayName') { |
|
| 1393 | - return; |
|
| 1394 | - } |
|
| 1395 | - |
|
| 1396 | - try { |
|
| 1397 | - $avatar = $manager->getAvatar($user->getUID()); |
|
| 1398 | - $avatar->userChanged($feature, $oldValue, $value); |
|
| 1399 | - } catch (NotFoundException $e) { |
|
| 1400 | - // no avatar to remove |
|
| 1401 | - } |
|
| 1402 | - }); |
|
| 1403 | - |
|
| 1404 | - /** @var IEventDispatcher $eventDispatched */ |
|
| 1405 | - $eventDispatched = $this->query(IEventDispatcher::class); |
|
| 1406 | - $eventDispatched->addServiceListener(LoginFailed::class, LoginFailedListener::class); |
|
| 1407 | - } |
|
| 1408 | - |
|
| 1409 | - /** |
|
| 1410 | - * @return \OCP\Contacts\IManager |
|
| 1411 | - * @deprecated |
|
| 1412 | - */ |
|
| 1413 | - public function getContactsManager() { |
|
| 1414 | - return $this->query(\OCP\Contacts\IManager::class); |
|
| 1415 | - } |
|
| 1416 | - |
|
| 1417 | - /** |
|
| 1418 | - * @return \OC\Encryption\Manager |
|
| 1419 | - * @deprecated |
|
| 1420 | - */ |
|
| 1421 | - public function getEncryptionManager() { |
|
| 1422 | - return $this->query(\OCP\Encryption\IManager::class); |
|
| 1423 | - } |
|
| 1424 | - |
|
| 1425 | - /** |
|
| 1426 | - * @return \OC\Encryption\File |
|
| 1427 | - * @deprecated |
|
| 1428 | - */ |
|
| 1429 | - public function getEncryptionFilesHelper() { |
|
| 1430 | - return $this->query('EncryptionFileHelper'); |
|
| 1431 | - } |
|
| 1432 | - |
|
| 1433 | - /** |
|
| 1434 | - * @return \OCP\Encryption\Keys\IStorage |
|
| 1435 | - * @deprecated |
|
| 1436 | - */ |
|
| 1437 | - public function getEncryptionKeyStorage() { |
|
| 1438 | - return $this->query('EncryptionKeyStorage'); |
|
| 1439 | - } |
|
| 1440 | - |
|
| 1441 | - /** |
|
| 1442 | - * The current request object holding all information about the request |
|
| 1443 | - * currently being processed is returned from this method. |
|
| 1444 | - * In case the current execution was not initiated by a web request null is returned |
|
| 1445 | - * |
|
| 1446 | - * @return \OCP\IRequest |
|
| 1447 | - * @deprecated |
|
| 1448 | - */ |
|
| 1449 | - public function getRequest() { |
|
| 1450 | - return $this->query(IRequest::class); |
|
| 1451 | - } |
|
| 1452 | - |
|
| 1453 | - /** |
|
| 1454 | - * Returns the preview manager which can create preview images for a given file |
|
| 1455 | - * |
|
| 1456 | - * @return IPreview |
|
| 1457 | - * @deprecated |
|
| 1458 | - */ |
|
| 1459 | - public function getPreviewManager() { |
|
| 1460 | - return $this->query(IPreview::class); |
|
| 1461 | - } |
|
| 1462 | - |
|
| 1463 | - /** |
|
| 1464 | - * Returns the tag manager which can get and set tags for different object types |
|
| 1465 | - * |
|
| 1466 | - * @see \OCP\ITagManager::load() |
|
| 1467 | - * @return ITagManager |
|
| 1468 | - * @deprecated |
|
| 1469 | - */ |
|
| 1470 | - public function getTagManager() { |
|
| 1471 | - return $this->query(ITagManager::class); |
|
| 1472 | - } |
|
| 1473 | - |
|
| 1474 | - /** |
|
| 1475 | - * Returns the system-tag manager |
|
| 1476 | - * |
|
| 1477 | - * @return ISystemTagManager |
|
| 1478 | - * |
|
| 1479 | - * @since 9.0.0 |
|
| 1480 | - * @deprecated |
|
| 1481 | - */ |
|
| 1482 | - public function getSystemTagManager() { |
|
| 1483 | - return $this->query(ISystemTagManager::class); |
|
| 1484 | - } |
|
| 1485 | - |
|
| 1486 | - /** |
|
| 1487 | - * Returns the system-tag object mapper |
|
| 1488 | - * |
|
| 1489 | - * @return ISystemTagObjectMapper |
|
| 1490 | - * |
|
| 1491 | - * @since 9.0.0 |
|
| 1492 | - * @deprecated |
|
| 1493 | - */ |
|
| 1494 | - public function getSystemTagObjectMapper() { |
|
| 1495 | - return $this->query(ISystemTagObjectMapper::class); |
|
| 1496 | - } |
|
| 1497 | - |
|
| 1498 | - /** |
|
| 1499 | - * Returns the avatar manager, used for avatar functionality |
|
| 1500 | - * |
|
| 1501 | - * @return IAvatarManager |
|
| 1502 | - * @deprecated |
|
| 1503 | - */ |
|
| 1504 | - public function getAvatarManager() { |
|
| 1505 | - return $this->query(IAvatarManager::class); |
|
| 1506 | - } |
|
| 1507 | - |
|
| 1508 | - /** |
|
| 1509 | - * Returns the root folder of ownCloud's data directory |
|
| 1510 | - * |
|
| 1511 | - * @return IRootFolder |
|
| 1512 | - * @deprecated |
|
| 1513 | - */ |
|
| 1514 | - public function getRootFolder() { |
|
| 1515 | - return $this->query(IRootFolder::class); |
|
| 1516 | - } |
|
| 1517 | - |
|
| 1518 | - /** |
|
| 1519 | - * Returns the root folder of ownCloud's data directory |
|
| 1520 | - * This is the lazy variant so this gets only initialized once it |
|
| 1521 | - * is actually used. |
|
| 1522 | - * |
|
| 1523 | - * @return IRootFolder |
|
| 1524 | - */ |
|
| 1525 | - public function getLazyRootFolder() { |
|
| 1526 | - return $this->query(IRootFolder::class); |
|
| 1527 | - } |
|
| 1528 | - |
|
| 1529 | - /** |
|
| 1530 | - * Returns a view to ownCloud's files folder |
|
| 1531 | - * |
|
| 1532 | - * @param string $userId user ID |
|
| 1533 | - * @return \OCP\Files\Folder|null |
|
| 1534 | - * @deprecated |
|
| 1535 | - */ |
|
| 1536 | - public function getUserFolder($userId = null) { |
|
| 1537 | - if ($userId === null) { |
|
| 1538 | - $user = $this->getUserSession()->getUser(); |
|
| 1539 | - if (!$user) { |
|
| 1540 | - return null; |
|
| 1541 | - } |
|
| 1542 | - $userId = $user->getUID(); |
|
| 1543 | - } |
|
| 1544 | - $root = $this->getRootFolder(); |
|
| 1545 | - return $root->getUserFolder($userId); |
|
| 1546 | - } |
|
| 1547 | - |
|
| 1548 | - /** |
|
| 1549 | - * @return \OC\User\Manager |
|
| 1550 | - * @deprecated |
|
| 1551 | - */ |
|
| 1552 | - public function getUserManager() { |
|
| 1553 | - return $this->query(IUserManager::class); |
|
| 1554 | - } |
|
| 1555 | - |
|
| 1556 | - /** |
|
| 1557 | - * @return \OC\Group\Manager |
|
| 1558 | - * @deprecated |
|
| 1559 | - */ |
|
| 1560 | - public function getGroupManager() { |
|
| 1561 | - return $this->query(IGroupManager::class); |
|
| 1562 | - } |
|
| 1563 | - |
|
| 1564 | - /** |
|
| 1565 | - * @return \OC\User\Session |
|
| 1566 | - * @deprecated |
|
| 1567 | - */ |
|
| 1568 | - public function getUserSession() { |
|
| 1569 | - return $this->query(IUserSession::class); |
|
| 1570 | - } |
|
| 1571 | - |
|
| 1572 | - /** |
|
| 1573 | - * @return \OCP\ISession |
|
| 1574 | - * @deprecated |
|
| 1575 | - */ |
|
| 1576 | - public function getSession() { |
|
| 1577 | - return $this->getUserSession()->getSession(); |
|
| 1578 | - } |
|
| 1579 | - |
|
| 1580 | - /** |
|
| 1581 | - * @param \OCP\ISession $session |
|
| 1582 | - */ |
|
| 1583 | - public function setSession(\OCP\ISession $session) { |
|
| 1584 | - $this->query(SessionStorage::class)->setSession($session); |
|
| 1585 | - $this->getUserSession()->setSession($session); |
|
| 1586 | - $this->query(Store::class)->setSession($session); |
|
| 1587 | - } |
|
| 1588 | - |
|
| 1589 | - /** |
|
| 1590 | - * @return \OC\Authentication\TwoFactorAuth\Manager |
|
| 1591 | - * @deprecated |
|
| 1592 | - */ |
|
| 1593 | - public function getTwoFactorAuthManager() { |
|
| 1594 | - return $this->query(\OC\Authentication\TwoFactorAuth\Manager::class); |
|
| 1595 | - } |
|
| 1596 | - |
|
| 1597 | - /** |
|
| 1598 | - * @return \OC\NavigationManager |
|
| 1599 | - * @deprecated |
|
| 1600 | - */ |
|
| 1601 | - public function getNavigationManager() { |
|
| 1602 | - return $this->query(INavigationManager::class); |
|
| 1603 | - } |
|
| 1604 | - |
|
| 1605 | - /** |
|
| 1606 | - * @return \OCP\IConfig |
|
| 1607 | - * @deprecated |
|
| 1608 | - */ |
|
| 1609 | - public function getConfig() { |
|
| 1610 | - return $this->query(AllConfig::class); |
|
| 1611 | - } |
|
| 1612 | - |
|
| 1613 | - /** |
|
| 1614 | - * @return \OC\SystemConfig |
|
| 1615 | - * @deprecated |
|
| 1616 | - */ |
|
| 1617 | - public function getSystemConfig() { |
|
| 1618 | - return $this->query(SystemConfig::class); |
|
| 1619 | - } |
|
| 1620 | - |
|
| 1621 | - /** |
|
| 1622 | - * Returns the app config manager |
|
| 1623 | - * |
|
| 1624 | - * @return IAppConfig |
|
| 1625 | - * @deprecated |
|
| 1626 | - */ |
|
| 1627 | - public function getAppConfig() { |
|
| 1628 | - return $this->query(IAppConfig::class); |
|
| 1629 | - } |
|
| 1630 | - |
|
| 1631 | - /** |
|
| 1632 | - * @return IFactory |
|
| 1633 | - * @deprecated |
|
| 1634 | - */ |
|
| 1635 | - public function getL10NFactory() { |
|
| 1636 | - return $this->query(IFactory::class); |
|
| 1637 | - } |
|
| 1638 | - |
|
| 1639 | - /** |
|
| 1640 | - * get an L10N instance |
|
| 1641 | - * |
|
| 1642 | - * @param string $app appid |
|
| 1643 | - * @param string $lang |
|
| 1644 | - * @return IL10N |
|
| 1645 | - * @deprecated |
|
| 1646 | - */ |
|
| 1647 | - public function getL10N($app, $lang = null) { |
|
| 1648 | - return $this->getL10NFactory()->get($app, $lang); |
|
| 1649 | - } |
|
| 1650 | - |
|
| 1651 | - /** |
|
| 1652 | - * @return IURLGenerator |
|
| 1653 | - * @deprecated |
|
| 1654 | - */ |
|
| 1655 | - public function getURLGenerator() { |
|
| 1656 | - return $this->query(IURLGenerator::class); |
|
| 1657 | - } |
|
| 1658 | - |
|
| 1659 | - /** |
|
| 1660 | - * @return AppFetcher |
|
| 1661 | - * @deprecated |
|
| 1662 | - */ |
|
| 1663 | - public function getAppFetcher() { |
|
| 1664 | - return $this->query(AppFetcher::class); |
|
| 1665 | - } |
|
| 1666 | - |
|
| 1667 | - /** |
|
| 1668 | - * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
| 1669 | - * getMemCacheFactory() instead. |
|
| 1670 | - * |
|
| 1671 | - * @return ICache |
|
| 1672 | - * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
| 1673 | - */ |
|
| 1674 | - public function getCache() { |
|
| 1675 | - return $this->query(ICache::class); |
|
| 1676 | - } |
|
| 1677 | - |
|
| 1678 | - /** |
|
| 1679 | - * Returns an \OCP\CacheFactory instance |
|
| 1680 | - * |
|
| 1681 | - * @return \OCP\ICacheFactory |
|
| 1682 | - * @deprecated |
|
| 1683 | - */ |
|
| 1684 | - public function getMemCacheFactory() { |
|
| 1685 | - return $this->query(Factory::class); |
|
| 1686 | - } |
|
| 1687 | - |
|
| 1688 | - /** |
|
| 1689 | - * Returns an \OC\RedisFactory instance |
|
| 1690 | - * |
|
| 1691 | - * @return \OC\RedisFactory |
|
| 1692 | - * @deprecated |
|
| 1693 | - */ |
|
| 1694 | - public function getGetRedisFactory() { |
|
| 1695 | - return $this->query('RedisFactory'); |
|
| 1696 | - } |
|
| 1697 | - |
|
| 1698 | - |
|
| 1699 | - /** |
|
| 1700 | - * Returns the current session |
|
| 1701 | - * |
|
| 1702 | - * @return \OCP\IDBConnection |
|
| 1703 | - * @deprecated |
|
| 1704 | - */ |
|
| 1705 | - public function getDatabaseConnection() { |
|
| 1706 | - return $this->query(IDBConnection::class); |
|
| 1707 | - } |
|
| 1708 | - |
|
| 1709 | - /** |
|
| 1710 | - * Returns the activity manager |
|
| 1711 | - * |
|
| 1712 | - * @return \OCP\Activity\IManager |
|
| 1713 | - * @deprecated |
|
| 1714 | - */ |
|
| 1715 | - public function getActivityManager() { |
|
| 1716 | - return $this->query(\OCP\Activity\IManager::class); |
|
| 1717 | - } |
|
| 1718 | - |
|
| 1719 | - /** |
|
| 1720 | - * Returns an job list for controlling background jobs |
|
| 1721 | - * |
|
| 1722 | - * @return IJobList |
|
| 1723 | - * @deprecated |
|
| 1724 | - */ |
|
| 1725 | - public function getJobList() { |
|
| 1726 | - return $this->query(IJobList::class); |
|
| 1727 | - } |
|
| 1728 | - |
|
| 1729 | - /** |
|
| 1730 | - * Returns a logger instance |
|
| 1731 | - * |
|
| 1732 | - * @return ILogger |
|
| 1733 | - * @deprecated |
|
| 1734 | - */ |
|
| 1735 | - public function getLogger() { |
|
| 1736 | - return $this->query(ILogger::class); |
|
| 1737 | - } |
|
| 1738 | - |
|
| 1739 | - /** |
|
| 1740 | - * @return ILogFactory |
|
| 1741 | - * @throws \OCP\AppFramework\QueryException |
|
| 1742 | - * @deprecated |
|
| 1743 | - */ |
|
| 1744 | - public function getLogFactory() { |
|
| 1745 | - return $this->query(ILogFactory::class); |
|
| 1746 | - } |
|
| 1747 | - |
|
| 1748 | - /** |
|
| 1749 | - * Returns a router for generating and matching urls |
|
| 1750 | - * |
|
| 1751 | - * @return IRouter |
|
| 1752 | - * @deprecated |
|
| 1753 | - */ |
|
| 1754 | - public function getRouter() { |
|
| 1755 | - return $this->query(IRouter::class); |
|
| 1756 | - } |
|
| 1757 | - |
|
| 1758 | - /** |
|
| 1759 | - * Returns a search instance |
|
| 1760 | - * |
|
| 1761 | - * @return ISearch |
|
| 1762 | - * @deprecated |
|
| 1763 | - */ |
|
| 1764 | - public function getSearch() { |
|
| 1765 | - return $this->query(ISearch::class); |
|
| 1766 | - } |
|
| 1767 | - |
|
| 1768 | - /** |
|
| 1769 | - * Returns a SecureRandom instance |
|
| 1770 | - * |
|
| 1771 | - * @return \OCP\Security\ISecureRandom |
|
| 1772 | - * @deprecated |
|
| 1773 | - */ |
|
| 1774 | - public function getSecureRandom() { |
|
| 1775 | - return $this->query(ISecureRandom::class); |
|
| 1776 | - } |
|
| 1777 | - |
|
| 1778 | - /** |
|
| 1779 | - * Returns a Crypto instance |
|
| 1780 | - * |
|
| 1781 | - * @return ICrypto |
|
| 1782 | - * @deprecated |
|
| 1783 | - */ |
|
| 1784 | - public function getCrypto() { |
|
| 1785 | - return $this->query(ICrypto::class); |
|
| 1786 | - } |
|
| 1787 | - |
|
| 1788 | - /** |
|
| 1789 | - * Returns a Hasher instance |
|
| 1790 | - * |
|
| 1791 | - * @return IHasher |
|
| 1792 | - * @deprecated |
|
| 1793 | - */ |
|
| 1794 | - public function getHasher() { |
|
| 1795 | - return $this->query(IHasher::class); |
|
| 1796 | - } |
|
| 1797 | - |
|
| 1798 | - /** |
|
| 1799 | - * Returns a CredentialsManager instance |
|
| 1800 | - * |
|
| 1801 | - * @return ICredentialsManager |
|
| 1802 | - * @deprecated |
|
| 1803 | - */ |
|
| 1804 | - public function getCredentialsManager() { |
|
| 1805 | - return $this->query(ICredentialsManager::class); |
|
| 1806 | - } |
|
| 1807 | - |
|
| 1808 | - /** |
|
| 1809 | - * Get the certificate manager for the user |
|
| 1810 | - * |
|
| 1811 | - * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
| 1812 | - * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
| 1813 | - * @deprecated |
|
| 1814 | - */ |
|
| 1815 | - public function getCertificateManager($userId = '') { |
|
| 1816 | - if ($userId === '') { |
|
| 1817 | - $userSession = $this->getUserSession(); |
|
| 1818 | - $user = $userSession->getUser(); |
|
| 1819 | - if (is_null($user)) { |
|
| 1820 | - return null; |
|
| 1821 | - } |
|
| 1822 | - $userId = $user->getUID(); |
|
| 1823 | - } |
|
| 1824 | - return new CertificateManager( |
|
| 1825 | - $userId, |
|
| 1826 | - new View(), |
|
| 1827 | - $this->getConfig(), |
|
| 1828 | - $this->getLogger(), |
|
| 1829 | - $this->getSecureRandom() |
|
| 1830 | - ); |
|
| 1831 | - } |
|
| 1832 | - |
|
| 1833 | - /** |
|
| 1834 | - * Returns an instance of the HTTP client service |
|
| 1835 | - * |
|
| 1836 | - * @return IClientService |
|
| 1837 | - * @deprecated |
|
| 1838 | - */ |
|
| 1839 | - public function getHTTPClientService() { |
|
| 1840 | - return $this->query(IClientService::class); |
|
| 1841 | - } |
|
| 1842 | - |
|
| 1843 | - /** |
|
| 1844 | - * Create a new event source |
|
| 1845 | - * |
|
| 1846 | - * @return \OCP\IEventSource |
|
| 1847 | - * @deprecated |
|
| 1848 | - */ |
|
| 1849 | - public function createEventSource() { |
|
| 1850 | - return new \OC_EventSource(); |
|
| 1851 | - } |
|
| 1852 | - |
|
| 1853 | - /** |
|
| 1854 | - * Get the active event logger |
|
| 1855 | - * |
|
| 1856 | - * The returned logger only logs data when debug mode is enabled |
|
| 1857 | - * |
|
| 1858 | - * @return IEventLogger |
|
| 1859 | - * @deprecated |
|
| 1860 | - */ |
|
| 1861 | - public function getEventLogger() { |
|
| 1862 | - return $this->query(IEventLogger::class); |
|
| 1863 | - } |
|
| 1864 | - |
|
| 1865 | - /** |
|
| 1866 | - * Get the active query logger |
|
| 1867 | - * |
|
| 1868 | - * The returned logger only logs data when debug mode is enabled |
|
| 1869 | - * |
|
| 1870 | - * @return IQueryLogger |
|
| 1871 | - * @deprecated |
|
| 1872 | - */ |
|
| 1873 | - public function getQueryLogger() { |
|
| 1874 | - return $this->query(IQueryLogger::class); |
|
| 1875 | - } |
|
| 1876 | - |
|
| 1877 | - /** |
|
| 1878 | - * Get the manager for temporary files and folders |
|
| 1879 | - * |
|
| 1880 | - * @return \OCP\ITempManager |
|
| 1881 | - * @deprecated |
|
| 1882 | - */ |
|
| 1883 | - public function getTempManager() { |
|
| 1884 | - return $this->query(ITempManager::class); |
|
| 1885 | - } |
|
| 1886 | - |
|
| 1887 | - /** |
|
| 1888 | - * Get the app manager |
|
| 1889 | - * |
|
| 1890 | - * @return \OCP\App\IAppManager |
|
| 1891 | - * @deprecated |
|
| 1892 | - */ |
|
| 1893 | - public function getAppManager() { |
|
| 1894 | - return $this->query(IAppManager::class); |
|
| 1895 | - } |
|
| 1896 | - |
|
| 1897 | - /** |
|
| 1898 | - * Creates a new mailer |
|
| 1899 | - * |
|
| 1900 | - * @return IMailer |
|
| 1901 | - * @deprecated |
|
| 1902 | - */ |
|
| 1903 | - public function getMailer() { |
|
| 1904 | - return $this->query(IMailer::class); |
|
| 1905 | - } |
|
| 1906 | - |
|
| 1907 | - /** |
|
| 1908 | - * Get the webroot |
|
| 1909 | - * |
|
| 1910 | - * @return string |
|
| 1911 | - * @deprecated |
|
| 1912 | - */ |
|
| 1913 | - public function getWebRoot() { |
|
| 1914 | - return $this->webRoot; |
|
| 1915 | - } |
|
| 1916 | - |
|
| 1917 | - /** |
|
| 1918 | - * @return \OC\OCSClient |
|
| 1919 | - * @deprecated |
|
| 1920 | - */ |
|
| 1921 | - public function getOcsClient() { |
|
| 1922 | - return $this->query('OcsClient'); |
|
| 1923 | - } |
|
| 1924 | - |
|
| 1925 | - /** |
|
| 1926 | - * @return IDateTimeZone |
|
| 1927 | - * @deprecated |
|
| 1928 | - */ |
|
| 1929 | - public function getDateTimeZone() { |
|
| 1930 | - return $this->query(IDateTimeZone::class); |
|
| 1931 | - } |
|
| 1932 | - |
|
| 1933 | - /** |
|
| 1934 | - * @return IDateTimeFormatter |
|
| 1935 | - * @deprecated |
|
| 1936 | - */ |
|
| 1937 | - public function getDateTimeFormatter() { |
|
| 1938 | - return $this->query(IDateTimeFormatter::class); |
|
| 1939 | - } |
|
| 1940 | - |
|
| 1941 | - /** |
|
| 1942 | - * @return IMountProviderCollection |
|
| 1943 | - * @deprecated |
|
| 1944 | - */ |
|
| 1945 | - public function getMountProviderCollection() { |
|
| 1946 | - return $this->query(IMountProviderCollection::class); |
|
| 1947 | - } |
|
| 1948 | - |
|
| 1949 | - /** |
|
| 1950 | - * Get the IniWrapper |
|
| 1951 | - * |
|
| 1952 | - * @return IniGetWrapper |
|
| 1953 | - * @deprecated |
|
| 1954 | - */ |
|
| 1955 | - public function getIniWrapper() { |
|
| 1956 | - return $this->query('IniWrapper'); |
|
| 1957 | - } |
|
| 1958 | - |
|
| 1959 | - /** |
|
| 1960 | - * @return \OCP\Command\IBus |
|
| 1961 | - * @deprecated |
|
| 1962 | - */ |
|
| 1963 | - public function getCommandBus() { |
|
| 1964 | - return $this->query('AsyncCommandBus'); |
|
| 1965 | - } |
|
| 1966 | - |
|
| 1967 | - /** |
|
| 1968 | - * Get the trusted domain helper |
|
| 1969 | - * |
|
| 1970 | - * @return TrustedDomainHelper |
|
| 1971 | - * @deprecated |
|
| 1972 | - */ |
|
| 1973 | - public function getTrustedDomainHelper() { |
|
| 1974 | - return $this->query('TrustedDomainHelper'); |
|
| 1975 | - } |
|
| 1976 | - |
|
| 1977 | - /** |
|
| 1978 | - * Get the locking provider |
|
| 1979 | - * |
|
| 1980 | - * @return ILockingProvider |
|
| 1981 | - * @since 8.1.0 |
|
| 1982 | - * @deprecated |
|
| 1983 | - */ |
|
| 1984 | - public function getLockingProvider() { |
|
| 1985 | - return $this->query(ILockingProvider::class); |
|
| 1986 | - } |
|
| 1987 | - |
|
| 1988 | - /** |
|
| 1989 | - * @return IMountManager |
|
| 1990 | - * @deprecated |
|
| 1991 | - **/ |
|
| 1992 | - public function getMountManager() { |
|
| 1993 | - return $this->query(IMountManager::class); |
|
| 1994 | - } |
|
| 1995 | - |
|
| 1996 | - /** |
|
| 1997 | - * @return IUserMountCache |
|
| 1998 | - * @deprecated |
|
| 1999 | - */ |
|
| 2000 | - public function getUserMountCache() { |
|
| 2001 | - return $this->query(IUserMountCache::class); |
|
| 2002 | - } |
|
| 2003 | - |
|
| 2004 | - /** |
|
| 2005 | - * Get the MimeTypeDetector |
|
| 2006 | - * |
|
| 2007 | - * @return IMimeTypeDetector |
|
| 2008 | - * @deprecated |
|
| 2009 | - */ |
|
| 2010 | - public function getMimeTypeDetector() { |
|
| 2011 | - return $this->query(IMimeTypeDetector::class); |
|
| 2012 | - } |
|
| 2013 | - |
|
| 2014 | - /** |
|
| 2015 | - * Get the MimeTypeLoader |
|
| 2016 | - * |
|
| 2017 | - * @return IMimeTypeLoader |
|
| 2018 | - * @deprecated |
|
| 2019 | - */ |
|
| 2020 | - public function getMimeTypeLoader() { |
|
| 2021 | - return $this->query(IMimeTypeLoader::class); |
|
| 2022 | - } |
|
| 2023 | - |
|
| 2024 | - /** |
|
| 2025 | - * Get the manager of all the capabilities |
|
| 2026 | - * |
|
| 2027 | - * @return CapabilitiesManager |
|
| 2028 | - * @deprecated |
|
| 2029 | - */ |
|
| 2030 | - public function getCapabilitiesManager() { |
|
| 2031 | - return $this->query(CapabilitiesManager::class); |
|
| 2032 | - } |
|
| 2033 | - |
|
| 2034 | - /** |
|
| 2035 | - * Get the EventDispatcher |
|
| 2036 | - * |
|
| 2037 | - * @return EventDispatcherInterface |
|
| 2038 | - * @since 8.2.0 |
|
| 2039 | - * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher |
|
| 2040 | - */ |
|
| 2041 | - public function getEventDispatcher() { |
|
| 2042 | - return $this->query(\OC\EventDispatcher\SymfonyAdapter::class); |
|
| 2043 | - } |
|
| 2044 | - |
|
| 2045 | - /** |
|
| 2046 | - * Get the Notification Manager |
|
| 2047 | - * |
|
| 2048 | - * @return \OCP\Notification\IManager |
|
| 2049 | - * @since 8.2.0 |
|
| 2050 | - * @deprecated |
|
| 2051 | - */ |
|
| 2052 | - public function getNotificationManager() { |
|
| 2053 | - return $this->query(\OCP\Notification\IManager::class); |
|
| 2054 | - } |
|
| 2055 | - |
|
| 2056 | - /** |
|
| 2057 | - * @return ICommentsManager |
|
| 2058 | - * @deprecated |
|
| 2059 | - */ |
|
| 2060 | - public function getCommentsManager() { |
|
| 2061 | - return $this->query(ICommentsManager::class); |
|
| 2062 | - } |
|
| 2063 | - |
|
| 2064 | - /** |
|
| 2065 | - * @return \OCA\Theming\ThemingDefaults |
|
| 2066 | - * @deprecated |
|
| 2067 | - */ |
|
| 2068 | - public function getThemingDefaults() { |
|
| 2069 | - return $this->query('ThemingDefaults'); |
|
| 2070 | - } |
|
| 2071 | - |
|
| 2072 | - /** |
|
| 2073 | - * @return \OC\IntegrityCheck\Checker |
|
| 2074 | - * @deprecated |
|
| 2075 | - */ |
|
| 2076 | - public function getIntegrityCodeChecker() { |
|
| 2077 | - return $this->query('IntegrityCodeChecker'); |
|
| 2078 | - } |
|
| 2079 | - |
|
| 2080 | - /** |
|
| 2081 | - * @return \OC\Session\CryptoWrapper |
|
| 2082 | - * @deprecated |
|
| 2083 | - */ |
|
| 2084 | - public function getSessionCryptoWrapper() { |
|
| 2085 | - return $this->query('CryptoWrapper'); |
|
| 2086 | - } |
|
| 2087 | - |
|
| 2088 | - /** |
|
| 2089 | - * @return CsrfTokenManager |
|
| 2090 | - * @deprecated |
|
| 2091 | - */ |
|
| 2092 | - public function getCsrfTokenManager() { |
|
| 2093 | - return $this->query(CsrfTokenManager::class); |
|
| 2094 | - } |
|
| 2095 | - |
|
| 2096 | - /** |
|
| 2097 | - * @return Throttler |
|
| 2098 | - * @deprecated |
|
| 2099 | - */ |
|
| 2100 | - public function getBruteForceThrottler() { |
|
| 2101 | - return $this->query(Throttler::class); |
|
| 2102 | - } |
|
| 2103 | - |
|
| 2104 | - /** |
|
| 2105 | - * @return IContentSecurityPolicyManager |
|
| 2106 | - * @deprecated |
|
| 2107 | - */ |
|
| 2108 | - public function getContentSecurityPolicyManager() { |
|
| 2109 | - return $this->query(ContentSecurityPolicyManager::class); |
|
| 2110 | - } |
|
| 2111 | - |
|
| 2112 | - /** |
|
| 2113 | - * @return ContentSecurityPolicyNonceManager |
|
| 2114 | - * @deprecated |
|
| 2115 | - */ |
|
| 2116 | - public function getContentSecurityPolicyNonceManager() { |
|
| 2117 | - return $this->query(ContentSecurityPolicyNonceManager::class); |
|
| 2118 | - } |
|
| 2119 | - |
|
| 2120 | - /** |
|
| 2121 | - * Not a public API as of 8.2, wait for 9.0 |
|
| 2122 | - * |
|
| 2123 | - * @return \OCA\Files_External\Service\BackendService |
|
| 2124 | - * @deprecated |
|
| 2125 | - */ |
|
| 2126 | - public function getStoragesBackendService() { |
|
| 2127 | - return $this->query(BackendService::class); |
|
| 2128 | - } |
|
| 2129 | - |
|
| 2130 | - /** |
|
| 2131 | - * Not a public API as of 8.2, wait for 9.0 |
|
| 2132 | - * |
|
| 2133 | - * @return \OCA\Files_External\Service\GlobalStoragesService |
|
| 2134 | - * @deprecated |
|
| 2135 | - */ |
|
| 2136 | - public function getGlobalStoragesService() { |
|
| 2137 | - return $this->query(GlobalStoragesService::class); |
|
| 2138 | - } |
|
| 2139 | - |
|
| 2140 | - /** |
|
| 2141 | - * Not a public API as of 8.2, wait for 9.0 |
|
| 2142 | - * |
|
| 2143 | - * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
| 2144 | - * @deprecated |
|
| 2145 | - */ |
|
| 2146 | - public function getUserGlobalStoragesService() { |
|
| 2147 | - return $this->query(UserGlobalStoragesService::class); |
|
| 2148 | - } |
|
| 2149 | - |
|
| 2150 | - /** |
|
| 2151 | - * Not a public API as of 8.2, wait for 9.0 |
|
| 2152 | - * |
|
| 2153 | - * @return \OCA\Files_External\Service\UserStoragesService |
|
| 2154 | - * @deprecated |
|
| 2155 | - */ |
|
| 2156 | - public function getUserStoragesService() { |
|
| 2157 | - return $this->query(UserStoragesService::class); |
|
| 2158 | - } |
|
| 2159 | - |
|
| 2160 | - /** |
|
| 2161 | - * @return \OCP\Share\IManager |
|
| 2162 | - * @deprecated |
|
| 2163 | - */ |
|
| 2164 | - public function getShareManager() { |
|
| 2165 | - return $this->query(\OCP\Share\IManager::class); |
|
| 2166 | - } |
|
| 2167 | - |
|
| 2168 | - /** |
|
| 2169 | - * @return \OCP\Collaboration\Collaborators\ISearch |
|
| 2170 | - * @deprecated |
|
| 2171 | - */ |
|
| 2172 | - public function getCollaboratorSearch() { |
|
| 2173 | - return $this->query(\OCP\Collaboration\Collaborators\ISearch::class); |
|
| 2174 | - } |
|
| 2175 | - |
|
| 2176 | - /** |
|
| 2177 | - * @return \OCP\Collaboration\AutoComplete\IManager |
|
| 2178 | - * @deprecated |
|
| 2179 | - */ |
|
| 2180 | - public function getAutoCompleteManager() { |
|
| 2181 | - return $this->query(IManager::class); |
|
| 2182 | - } |
|
| 2183 | - |
|
| 2184 | - /** |
|
| 2185 | - * Returns the LDAP Provider |
|
| 2186 | - * |
|
| 2187 | - * @return \OCP\LDAP\ILDAPProvider |
|
| 2188 | - * @deprecated |
|
| 2189 | - */ |
|
| 2190 | - public function getLDAPProvider() { |
|
| 2191 | - return $this->query('LDAPProvider'); |
|
| 2192 | - } |
|
| 2193 | - |
|
| 2194 | - /** |
|
| 2195 | - * @return \OCP\Settings\IManager |
|
| 2196 | - * @deprecated |
|
| 2197 | - */ |
|
| 2198 | - public function getSettingsManager() { |
|
| 2199 | - return $this->query('SettingsManager'); |
|
| 2200 | - } |
|
| 2201 | - |
|
| 2202 | - /** |
|
| 2203 | - * @return \OCP\Files\IAppData |
|
| 2204 | - * @deprecated |
|
| 2205 | - */ |
|
| 2206 | - public function getAppDataDir($app) { |
|
| 2207 | - /** @var \OC\Files\AppData\Factory $factory */ |
|
| 2208 | - $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
| 2209 | - return $factory->get($app); |
|
| 2210 | - } |
|
| 2211 | - |
|
| 2212 | - /** |
|
| 2213 | - * @return \OCP\Lockdown\ILockdownManager |
|
| 2214 | - * @deprecated |
|
| 2215 | - */ |
|
| 2216 | - public function getLockdownManager() { |
|
| 2217 | - return $this->query('LockdownManager'); |
|
| 2218 | - } |
|
| 2219 | - |
|
| 2220 | - /** |
|
| 2221 | - * @return \OCP\Federation\ICloudIdManager |
|
| 2222 | - * @deprecated |
|
| 2223 | - */ |
|
| 2224 | - public function getCloudIdManager() { |
|
| 2225 | - return $this->query(ICloudIdManager::class); |
|
| 2226 | - } |
|
| 2227 | - |
|
| 2228 | - /** |
|
| 2229 | - * @return \OCP\GlobalScale\IConfig |
|
| 2230 | - * @deprecated |
|
| 2231 | - */ |
|
| 2232 | - public function getGlobalScaleConfig() { |
|
| 2233 | - return $this->query(IConfig::class); |
|
| 2234 | - } |
|
| 2235 | - |
|
| 2236 | - /** |
|
| 2237 | - * @return \OCP\Federation\ICloudFederationProviderManager |
|
| 2238 | - * @deprecated |
|
| 2239 | - */ |
|
| 2240 | - public function getCloudFederationProviderManager() { |
|
| 2241 | - return $this->query(ICloudFederationProviderManager::class); |
|
| 2242 | - } |
|
| 2243 | - |
|
| 2244 | - /** |
|
| 2245 | - * @return \OCP\Remote\Api\IApiFactory |
|
| 2246 | - * @deprecated |
|
| 2247 | - */ |
|
| 2248 | - public function getRemoteApiFactory() { |
|
| 2249 | - return $this->query(IApiFactory::class); |
|
| 2250 | - } |
|
| 2251 | - |
|
| 2252 | - /** |
|
| 2253 | - * @return \OCP\Federation\ICloudFederationFactory |
|
| 2254 | - * @deprecated |
|
| 2255 | - */ |
|
| 2256 | - public function getCloudFederationFactory() { |
|
| 2257 | - return $this->query(ICloudFederationFactory::class); |
|
| 2258 | - } |
|
| 2259 | - |
|
| 2260 | - /** |
|
| 2261 | - * @return \OCP\Remote\IInstanceFactory |
|
| 2262 | - * @deprecated |
|
| 2263 | - */ |
|
| 2264 | - public function getRemoteInstanceFactory() { |
|
| 2265 | - return $this->query(IInstanceFactory::class); |
|
| 2266 | - } |
|
| 2267 | - |
|
| 2268 | - /** |
|
| 2269 | - * @return IStorageFactory |
|
| 2270 | - * @deprecated |
|
| 2271 | - */ |
|
| 2272 | - public function getStorageFactory() { |
|
| 2273 | - return $this->query(IStorageFactory::class); |
|
| 2274 | - } |
|
| 2275 | - |
|
| 2276 | - /** |
|
| 2277 | - * Get the Preview GeneratorHelper |
|
| 2278 | - * |
|
| 2279 | - * @return GeneratorHelper |
|
| 2280 | - * @since 17.0.0 |
|
| 2281 | - * @deprecated |
|
| 2282 | - */ |
|
| 2283 | - public function getGeneratorHelper() { |
|
| 2284 | - return $this->query(\OC\Preview\GeneratorHelper::class); |
|
| 2285 | - } |
|
| 2286 | - |
|
| 2287 | - private function registerDeprecatedAlias(string $alias, string $target) { |
|
| 2288 | - $this->registerService($alias, function (ContainerInterface $container) use ($target, $alias) { |
|
| 2289 | - try { |
|
| 2290 | - /** @var ILogger $logger */ |
|
| 2291 | - $logger = $container->get(ILogger::class); |
|
| 2292 | - $logger->debug('The requested alias "' . $alias . '" is depreacted. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']); |
|
| 2293 | - } catch (ContainerExceptionInterface $e) { |
|
| 2294 | - // Could not get logger. Continue |
|
| 2295 | - } |
|
| 2296 | - |
|
| 2297 | - return $container->get($target); |
|
| 2298 | - }, false); |
|
| 2299 | - } |
|
| 1108 | + $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
| 1109 | + if (isset($prefixes['OCA\\Theming\\'])) { |
|
| 1110 | + $classExists = true; |
|
| 1111 | + } else { |
|
| 1112 | + $classExists = false; |
|
| 1113 | + } |
|
| 1114 | + |
|
| 1115 | + if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) { |
|
| 1116 | + return new ThemingDefaults( |
|
| 1117 | + $c->getConfig(), |
|
| 1118 | + $c->getL10N('theming'), |
|
| 1119 | + $c->getURLGenerator(), |
|
| 1120 | + $c->getMemCacheFactory(), |
|
| 1121 | + new Util($c->getConfig(), $this->getAppManager(), $c->getAppDataDir('theming')), |
|
| 1122 | + new ImageManager($c->getConfig(), $c->getAppDataDir('theming'), $c->getURLGenerator(), $this->getMemCacheFactory(), $this->getLogger()), |
|
| 1123 | + $c->getAppManager(), |
|
| 1124 | + $c->getNavigationManager() |
|
| 1125 | + ); |
|
| 1126 | + } |
|
| 1127 | + return new \OC_Defaults(); |
|
| 1128 | + }); |
|
| 1129 | + $this->registerService(JSCombiner::class, function (Server $c) { |
|
| 1130 | + return new JSCombiner( |
|
| 1131 | + $c->getAppDataDir('js'), |
|
| 1132 | + $c->getURLGenerator(), |
|
| 1133 | + $this->getMemCacheFactory(), |
|
| 1134 | + $c->getSystemConfig(), |
|
| 1135 | + $c->getLogger() |
|
| 1136 | + ); |
|
| 1137 | + }); |
|
| 1138 | + $this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class); |
|
| 1139 | + /** @deprecated 19.0.0 */ |
|
| 1140 | + $this->registerDeprecatedAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class); |
|
| 1141 | + $this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class); |
|
| 1142 | + |
|
| 1143 | + $this->registerService('CryptoWrapper', function (Server $c) { |
|
| 1144 | + // FIXME: Instantiiated here due to cyclic dependency |
|
| 1145 | + $request = new Request( |
|
| 1146 | + [ |
|
| 1147 | + 'get' => $_GET, |
|
| 1148 | + 'post' => $_POST, |
|
| 1149 | + 'files' => $_FILES, |
|
| 1150 | + 'server' => $_SERVER, |
|
| 1151 | + 'env' => $_ENV, |
|
| 1152 | + 'cookies' => $_COOKIE, |
|
| 1153 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
| 1154 | + ? $_SERVER['REQUEST_METHOD'] |
|
| 1155 | + : null, |
|
| 1156 | + ], |
|
| 1157 | + $c->getSecureRandom(), |
|
| 1158 | + $c->getConfig() |
|
| 1159 | + ); |
|
| 1160 | + |
|
| 1161 | + return new CryptoWrapper( |
|
| 1162 | + $c->getConfig(), |
|
| 1163 | + $c->getCrypto(), |
|
| 1164 | + $c->getSecureRandom(), |
|
| 1165 | + $request |
|
| 1166 | + ); |
|
| 1167 | + }); |
|
| 1168 | + /** @deprecated 19.0.0 */ |
|
| 1169 | + $this->registerDeprecatedAlias('CsrfTokenManager', CsrfTokenManager::class); |
|
| 1170 | + $this->registerService(SessionStorage::class, function (Server $c) { |
|
| 1171 | + return new SessionStorage($c->getSession()); |
|
| 1172 | + }); |
|
| 1173 | + $this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class); |
|
| 1174 | + /** @deprecated 19.0.0 */ |
|
| 1175 | + $this->registerDeprecatedAlias('ContentSecurityPolicyManager', ContentSecurityPolicyManager::class); |
|
| 1176 | + |
|
| 1177 | + $this->registerService(\OCP\Share\IManager::class, function (Server $c) { |
|
| 1178 | + $config = $c->getConfig(); |
|
| 1179 | + $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class); |
|
| 1180 | + /** @var \OCP\Share\IProviderFactory $factory */ |
|
| 1181 | + $factory = new $factoryClass($this); |
|
| 1182 | + |
|
| 1183 | + $manager = new \OC\Share20\Manager( |
|
| 1184 | + $c->getLogger(), |
|
| 1185 | + $c->getConfig(), |
|
| 1186 | + $c->getSecureRandom(), |
|
| 1187 | + $c->getHasher(), |
|
| 1188 | + $c->getMountManager(), |
|
| 1189 | + $c->getGroupManager(), |
|
| 1190 | + $c->getL10N('lib'), |
|
| 1191 | + $c->getL10NFactory(), |
|
| 1192 | + $factory, |
|
| 1193 | + $c->getUserManager(), |
|
| 1194 | + $c->getLazyRootFolder(), |
|
| 1195 | + $c->getEventDispatcher(), |
|
| 1196 | + $c->getMailer(), |
|
| 1197 | + $c->getURLGenerator(), |
|
| 1198 | + $c->getThemingDefaults(), |
|
| 1199 | + $c->query(IEventDispatcher::class) |
|
| 1200 | + ); |
|
| 1201 | + |
|
| 1202 | + return $manager; |
|
| 1203 | + }); |
|
| 1204 | + /** @deprecated 19.0.0 */ |
|
| 1205 | + $this->registerDeprecatedAlias('ShareManager', \OCP\Share\IManager::class); |
|
| 1206 | + |
|
| 1207 | + $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) { |
|
| 1208 | + $instance = new Collaboration\Collaborators\Search($c); |
|
| 1209 | + |
|
| 1210 | + // register default plugins |
|
| 1211 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]); |
|
| 1212 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]); |
|
| 1213 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]); |
|
| 1214 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]); |
|
| 1215 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]); |
|
| 1216 | + |
|
| 1217 | + return $instance; |
|
| 1218 | + }); |
|
| 1219 | + /** @deprecated 19.0.0 */ |
|
| 1220 | + $this->registerDeprecatedAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class); |
|
| 1221 | + $this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class); |
|
| 1222 | + |
|
| 1223 | + $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); |
|
| 1224 | + |
|
| 1225 | + $this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class); |
|
| 1226 | + $this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class); |
|
| 1227 | + |
|
| 1228 | + $this->registerService('SettingsManager', function (Server $c) { |
|
| 1229 | + $manager = new \OC\Settings\Manager( |
|
| 1230 | + $c->getLogger(), |
|
| 1231 | + $c->getL10NFactory(), |
|
| 1232 | + $c->getURLGenerator(), |
|
| 1233 | + $c |
|
| 1234 | + ); |
|
| 1235 | + return $manager; |
|
| 1236 | + }); |
|
| 1237 | + $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
| 1238 | + return new \OC\Files\AppData\Factory( |
|
| 1239 | + $c->getRootFolder(), |
|
| 1240 | + $c->getSystemConfig() |
|
| 1241 | + ); |
|
| 1242 | + }); |
|
| 1243 | + |
|
| 1244 | + $this->registerService('LockdownManager', function (Server $c) { |
|
| 1245 | + return new LockdownManager(function () use ($c) { |
|
| 1246 | + return $c->getSession(); |
|
| 1247 | + }); |
|
| 1248 | + }); |
|
| 1249 | + |
|
| 1250 | + $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
| 1251 | + return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
| 1252 | + }); |
|
| 1253 | + |
|
| 1254 | + $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
| 1255 | + return new CloudIdManager(); |
|
| 1256 | + }); |
|
| 1257 | + |
|
| 1258 | + $this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class); |
|
| 1259 | + |
|
| 1260 | + $this->registerService(ICloudFederationProviderManager::class, function (Server $c) { |
|
| 1261 | + return new CloudFederationProviderManager($c->getAppManager(), $c->getHTTPClientService(), $c->getCloudIdManager(), $c->getLogger()); |
|
| 1262 | + }); |
|
| 1263 | + |
|
| 1264 | + $this->registerService(ICloudFederationFactory::class, function (Server $c) { |
|
| 1265 | + return new CloudFederationFactory(); |
|
| 1266 | + }); |
|
| 1267 | + |
|
| 1268 | + $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
| 1269 | + /** @deprecated 19.0.0 */ |
|
| 1270 | + $this->registerDeprecatedAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
| 1271 | + |
|
| 1272 | + $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
| 1273 | + /** @deprecated 19.0.0 */ |
|
| 1274 | + $this->registerDeprecatedAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
| 1275 | + |
|
| 1276 | + $this->registerService(Defaults::class, function (Server $c) { |
|
| 1277 | + return new Defaults( |
|
| 1278 | + $c->getThemingDefaults() |
|
| 1279 | + ); |
|
| 1280 | + }); |
|
| 1281 | + /** @deprecated 19.0.0 */ |
|
| 1282 | + $this->registerDeprecatedAlias('Defaults', \OCP\Defaults::class); |
|
| 1283 | + |
|
| 1284 | + $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { |
|
| 1285 | + return $c->query(\OCP\IUserSession::class)->getSession(); |
|
| 1286 | + }); |
|
| 1287 | + |
|
| 1288 | + $this->registerService(IShareHelper::class, function (Server $c) { |
|
| 1289 | + return new ShareHelper( |
|
| 1290 | + $c->query(\OCP\Share\IManager::class) |
|
| 1291 | + ); |
|
| 1292 | + }); |
|
| 1293 | + |
|
| 1294 | + $this->registerService(Installer::class, function (Server $c) { |
|
| 1295 | + return new Installer( |
|
| 1296 | + $c->getAppFetcher(), |
|
| 1297 | + $c->getHTTPClientService(), |
|
| 1298 | + $c->getTempManager(), |
|
| 1299 | + $c->getLogger(), |
|
| 1300 | + $c->getConfig(), |
|
| 1301 | + \OC::$CLI |
|
| 1302 | + ); |
|
| 1303 | + }); |
|
| 1304 | + |
|
| 1305 | + $this->registerService(IApiFactory::class, function (Server $c) { |
|
| 1306 | + return new ApiFactory($c->getHTTPClientService()); |
|
| 1307 | + }); |
|
| 1308 | + |
|
| 1309 | + $this->registerService(IInstanceFactory::class, function (Server $c) { |
|
| 1310 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
| 1311 | + return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService()); |
|
| 1312 | + }); |
|
| 1313 | + |
|
| 1314 | + $this->registerAlias(IContactsStore::class, ContactsStore::class); |
|
| 1315 | + $this->registerAlias(IAccountManager::class, AccountManager::class); |
|
| 1316 | + |
|
| 1317 | + $this->registerAlias(IStorageFactory::class, StorageFactory::class); |
|
| 1318 | + |
|
| 1319 | + $this->registerAlias(IDashboardManager::class, DashboardManager::class); |
|
| 1320 | + $this->registerAlias(\OCP\Dashboard\IManager::class, \OC\Dashboard\Manager::class); |
|
| 1321 | + $this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class); |
|
| 1322 | + |
|
| 1323 | + $this->registerAlias(ISubAdmin::class, SubAdmin::class); |
|
| 1324 | + |
|
| 1325 | + $this->registerAlias(IInitialStateService::class, InitialStateService::class); |
|
| 1326 | + |
|
| 1327 | + $this->registerAlias(\OCP\UserStatus\IManager::class, \OC\UserStatus\Manager::class); |
|
| 1328 | + |
|
| 1329 | + $this->connectDispatcher(); |
|
| 1330 | + } |
|
| 1331 | + |
|
| 1332 | + public function boot() { |
|
| 1333 | + /** @var HookConnector $hookConnector */ |
|
| 1334 | + $hookConnector = $this->query(HookConnector::class); |
|
| 1335 | + $hookConnector->viewToNode(); |
|
| 1336 | + } |
|
| 1337 | + |
|
| 1338 | + /** |
|
| 1339 | + * @return \OCP\Calendar\IManager |
|
| 1340 | + * @deprecated |
|
| 1341 | + */ |
|
| 1342 | + public function getCalendarManager() { |
|
| 1343 | + return $this->query(\OC\Calendar\Manager::class); |
|
| 1344 | + } |
|
| 1345 | + |
|
| 1346 | + /** |
|
| 1347 | + * @return \OCP\Calendar\Resource\IManager |
|
| 1348 | + * @deprecated |
|
| 1349 | + */ |
|
| 1350 | + public function getCalendarResourceBackendManager() { |
|
| 1351 | + return $this->query(\OC\Calendar\Resource\Manager::class); |
|
| 1352 | + } |
|
| 1353 | + |
|
| 1354 | + /** |
|
| 1355 | + * @return \OCP\Calendar\Room\IManager |
|
| 1356 | + * @deprecated |
|
| 1357 | + */ |
|
| 1358 | + public function getCalendarRoomBackendManager() { |
|
| 1359 | + return $this->query(\OC\Calendar\Room\Manager::class); |
|
| 1360 | + } |
|
| 1361 | + |
|
| 1362 | + private function connectDispatcher() { |
|
| 1363 | + $dispatcher = $this->getEventDispatcher(); |
|
| 1364 | + |
|
| 1365 | + // Delete avatar on user deletion |
|
| 1366 | + $dispatcher->addListener('OCP\IUser::preDelete', function (GenericEvent $e) { |
|
| 1367 | + $logger = $this->getLogger(); |
|
| 1368 | + $manager = $this->getAvatarManager(); |
|
| 1369 | + /** @var IUser $user */ |
|
| 1370 | + $user = $e->getSubject(); |
|
| 1371 | + |
|
| 1372 | + try { |
|
| 1373 | + $avatar = $manager->getAvatar($user->getUID()); |
|
| 1374 | + $avatar->remove(); |
|
| 1375 | + } catch (NotFoundException $e) { |
|
| 1376 | + // no avatar to remove |
|
| 1377 | + } catch (\Exception $e) { |
|
| 1378 | + // Ignore exceptions |
|
| 1379 | + $logger->info('Could not cleanup avatar of ' . $user->getUID()); |
|
| 1380 | + } |
|
| 1381 | + }); |
|
| 1382 | + |
|
| 1383 | + $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { |
|
| 1384 | + $manager = $this->getAvatarManager(); |
|
| 1385 | + /** @var IUser $user */ |
|
| 1386 | + $user = $e->getSubject(); |
|
| 1387 | + $feature = $e->getArgument('feature'); |
|
| 1388 | + $oldValue = $e->getArgument('oldValue'); |
|
| 1389 | + $value = $e->getArgument('value'); |
|
| 1390 | + |
|
| 1391 | + // We only change the avatar on display name changes |
|
| 1392 | + if ($feature !== 'displayName') { |
|
| 1393 | + return; |
|
| 1394 | + } |
|
| 1395 | + |
|
| 1396 | + try { |
|
| 1397 | + $avatar = $manager->getAvatar($user->getUID()); |
|
| 1398 | + $avatar->userChanged($feature, $oldValue, $value); |
|
| 1399 | + } catch (NotFoundException $e) { |
|
| 1400 | + // no avatar to remove |
|
| 1401 | + } |
|
| 1402 | + }); |
|
| 1403 | + |
|
| 1404 | + /** @var IEventDispatcher $eventDispatched */ |
|
| 1405 | + $eventDispatched = $this->query(IEventDispatcher::class); |
|
| 1406 | + $eventDispatched->addServiceListener(LoginFailed::class, LoginFailedListener::class); |
|
| 1407 | + } |
|
| 1408 | + |
|
| 1409 | + /** |
|
| 1410 | + * @return \OCP\Contacts\IManager |
|
| 1411 | + * @deprecated |
|
| 1412 | + */ |
|
| 1413 | + public function getContactsManager() { |
|
| 1414 | + return $this->query(\OCP\Contacts\IManager::class); |
|
| 1415 | + } |
|
| 1416 | + |
|
| 1417 | + /** |
|
| 1418 | + * @return \OC\Encryption\Manager |
|
| 1419 | + * @deprecated |
|
| 1420 | + */ |
|
| 1421 | + public function getEncryptionManager() { |
|
| 1422 | + return $this->query(\OCP\Encryption\IManager::class); |
|
| 1423 | + } |
|
| 1424 | + |
|
| 1425 | + /** |
|
| 1426 | + * @return \OC\Encryption\File |
|
| 1427 | + * @deprecated |
|
| 1428 | + */ |
|
| 1429 | + public function getEncryptionFilesHelper() { |
|
| 1430 | + return $this->query('EncryptionFileHelper'); |
|
| 1431 | + } |
|
| 1432 | + |
|
| 1433 | + /** |
|
| 1434 | + * @return \OCP\Encryption\Keys\IStorage |
|
| 1435 | + * @deprecated |
|
| 1436 | + */ |
|
| 1437 | + public function getEncryptionKeyStorage() { |
|
| 1438 | + return $this->query('EncryptionKeyStorage'); |
|
| 1439 | + } |
|
| 1440 | + |
|
| 1441 | + /** |
|
| 1442 | + * The current request object holding all information about the request |
|
| 1443 | + * currently being processed is returned from this method. |
|
| 1444 | + * In case the current execution was not initiated by a web request null is returned |
|
| 1445 | + * |
|
| 1446 | + * @return \OCP\IRequest |
|
| 1447 | + * @deprecated |
|
| 1448 | + */ |
|
| 1449 | + public function getRequest() { |
|
| 1450 | + return $this->query(IRequest::class); |
|
| 1451 | + } |
|
| 1452 | + |
|
| 1453 | + /** |
|
| 1454 | + * Returns the preview manager which can create preview images for a given file |
|
| 1455 | + * |
|
| 1456 | + * @return IPreview |
|
| 1457 | + * @deprecated |
|
| 1458 | + */ |
|
| 1459 | + public function getPreviewManager() { |
|
| 1460 | + return $this->query(IPreview::class); |
|
| 1461 | + } |
|
| 1462 | + |
|
| 1463 | + /** |
|
| 1464 | + * Returns the tag manager which can get and set tags for different object types |
|
| 1465 | + * |
|
| 1466 | + * @see \OCP\ITagManager::load() |
|
| 1467 | + * @return ITagManager |
|
| 1468 | + * @deprecated |
|
| 1469 | + */ |
|
| 1470 | + public function getTagManager() { |
|
| 1471 | + return $this->query(ITagManager::class); |
|
| 1472 | + } |
|
| 1473 | + |
|
| 1474 | + /** |
|
| 1475 | + * Returns the system-tag manager |
|
| 1476 | + * |
|
| 1477 | + * @return ISystemTagManager |
|
| 1478 | + * |
|
| 1479 | + * @since 9.0.0 |
|
| 1480 | + * @deprecated |
|
| 1481 | + */ |
|
| 1482 | + public function getSystemTagManager() { |
|
| 1483 | + return $this->query(ISystemTagManager::class); |
|
| 1484 | + } |
|
| 1485 | + |
|
| 1486 | + /** |
|
| 1487 | + * Returns the system-tag object mapper |
|
| 1488 | + * |
|
| 1489 | + * @return ISystemTagObjectMapper |
|
| 1490 | + * |
|
| 1491 | + * @since 9.0.0 |
|
| 1492 | + * @deprecated |
|
| 1493 | + */ |
|
| 1494 | + public function getSystemTagObjectMapper() { |
|
| 1495 | + return $this->query(ISystemTagObjectMapper::class); |
|
| 1496 | + } |
|
| 1497 | + |
|
| 1498 | + /** |
|
| 1499 | + * Returns the avatar manager, used for avatar functionality |
|
| 1500 | + * |
|
| 1501 | + * @return IAvatarManager |
|
| 1502 | + * @deprecated |
|
| 1503 | + */ |
|
| 1504 | + public function getAvatarManager() { |
|
| 1505 | + return $this->query(IAvatarManager::class); |
|
| 1506 | + } |
|
| 1507 | + |
|
| 1508 | + /** |
|
| 1509 | + * Returns the root folder of ownCloud's data directory |
|
| 1510 | + * |
|
| 1511 | + * @return IRootFolder |
|
| 1512 | + * @deprecated |
|
| 1513 | + */ |
|
| 1514 | + public function getRootFolder() { |
|
| 1515 | + return $this->query(IRootFolder::class); |
|
| 1516 | + } |
|
| 1517 | + |
|
| 1518 | + /** |
|
| 1519 | + * Returns the root folder of ownCloud's data directory |
|
| 1520 | + * This is the lazy variant so this gets only initialized once it |
|
| 1521 | + * is actually used. |
|
| 1522 | + * |
|
| 1523 | + * @return IRootFolder |
|
| 1524 | + */ |
|
| 1525 | + public function getLazyRootFolder() { |
|
| 1526 | + return $this->query(IRootFolder::class); |
|
| 1527 | + } |
|
| 1528 | + |
|
| 1529 | + /** |
|
| 1530 | + * Returns a view to ownCloud's files folder |
|
| 1531 | + * |
|
| 1532 | + * @param string $userId user ID |
|
| 1533 | + * @return \OCP\Files\Folder|null |
|
| 1534 | + * @deprecated |
|
| 1535 | + */ |
|
| 1536 | + public function getUserFolder($userId = null) { |
|
| 1537 | + if ($userId === null) { |
|
| 1538 | + $user = $this->getUserSession()->getUser(); |
|
| 1539 | + if (!$user) { |
|
| 1540 | + return null; |
|
| 1541 | + } |
|
| 1542 | + $userId = $user->getUID(); |
|
| 1543 | + } |
|
| 1544 | + $root = $this->getRootFolder(); |
|
| 1545 | + return $root->getUserFolder($userId); |
|
| 1546 | + } |
|
| 1547 | + |
|
| 1548 | + /** |
|
| 1549 | + * @return \OC\User\Manager |
|
| 1550 | + * @deprecated |
|
| 1551 | + */ |
|
| 1552 | + public function getUserManager() { |
|
| 1553 | + return $this->query(IUserManager::class); |
|
| 1554 | + } |
|
| 1555 | + |
|
| 1556 | + /** |
|
| 1557 | + * @return \OC\Group\Manager |
|
| 1558 | + * @deprecated |
|
| 1559 | + */ |
|
| 1560 | + public function getGroupManager() { |
|
| 1561 | + return $this->query(IGroupManager::class); |
|
| 1562 | + } |
|
| 1563 | + |
|
| 1564 | + /** |
|
| 1565 | + * @return \OC\User\Session |
|
| 1566 | + * @deprecated |
|
| 1567 | + */ |
|
| 1568 | + public function getUserSession() { |
|
| 1569 | + return $this->query(IUserSession::class); |
|
| 1570 | + } |
|
| 1571 | + |
|
| 1572 | + /** |
|
| 1573 | + * @return \OCP\ISession |
|
| 1574 | + * @deprecated |
|
| 1575 | + */ |
|
| 1576 | + public function getSession() { |
|
| 1577 | + return $this->getUserSession()->getSession(); |
|
| 1578 | + } |
|
| 1579 | + |
|
| 1580 | + /** |
|
| 1581 | + * @param \OCP\ISession $session |
|
| 1582 | + */ |
|
| 1583 | + public function setSession(\OCP\ISession $session) { |
|
| 1584 | + $this->query(SessionStorage::class)->setSession($session); |
|
| 1585 | + $this->getUserSession()->setSession($session); |
|
| 1586 | + $this->query(Store::class)->setSession($session); |
|
| 1587 | + } |
|
| 1588 | + |
|
| 1589 | + /** |
|
| 1590 | + * @return \OC\Authentication\TwoFactorAuth\Manager |
|
| 1591 | + * @deprecated |
|
| 1592 | + */ |
|
| 1593 | + public function getTwoFactorAuthManager() { |
|
| 1594 | + return $this->query(\OC\Authentication\TwoFactorAuth\Manager::class); |
|
| 1595 | + } |
|
| 1596 | + |
|
| 1597 | + /** |
|
| 1598 | + * @return \OC\NavigationManager |
|
| 1599 | + * @deprecated |
|
| 1600 | + */ |
|
| 1601 | + public function getNavigationManager() { |
|
| 1602 | + return $this->query(INavigationManager::class); |
|
| 1603 | + } |
|
| 1604 | + |
|
| 1605 | + /** |
|
| 1606 | + * @return \OCP\IConfig |
|
| 1607 | + * @deprecated |
|
| 1608 | + */ |
|
| 1609 | + public function getConfig() { |
|
| 1610 | + return $this->query(AllConfig::class); |
|
| 1611 | + } |
|
| 1612 | + |
|
| 1613 | + /** |
|
| 1614 | + * @return \OC\SystemConfig |
|
| 1615 | + * @deprecated |
|
| 1616 | + */ |
|
| 1617 | + public function getSystemConfig() { |
|
| 1618 | + return $this->query(SystemConfig::class); |
|
| 1619 | + } |
|
| 1620 | + |
|
| 1621 | + /** |
|
| 1622 | + * Returns the app config manager |
|
| 1623 | + * |
|
| 1624 | + * @return IAppConfig |
|
| 1625 | + * @deprecated |
|
| 1626 | + */ |
|
| 1627 | + public function getAppConfig() { |
|
| 1628 | + return $this->query(IAppConfig::class); |
|
| 1629 | + } |
|
| 1630 | + |
|
| 1631 | + /** |
|
| 1632 | + * @return IFactory |
|
| 1633 | + * @deprecated |
|
| 1634 | + */ |
|
| 1635 | + public function getL10NFactory() { |
|
| 1636 | + return $this->query(IFactory::class); |
|
| 1637 | + } |
|
| 1638 | + |
|
| 1639 | + /** |
|
| 1640 | + * get an L10N instance |
|
| 1641 | + * |
|
| 1642 | + * @param string $app appid |
|
| 1643 | + * @param string $lang |
|
| 1644 | + * @return IL10N |
|
| 1645 | + * @deprecated |
|
| 1646 | + */ |
|
| 1647 | + public function getL10N($app, $lang = null) { |
|
| 1648 | + return $this->getL10NFactory()->get($app, $lang); |
|
| 1649 | + } |
|
| 1650 | + |
|
| 1651 | + /** |
|
| 1652 | + * @return IURLGenerator |
|
| 1653 | + * @deprecated |
|
| 1654 | + */ |
|
| 1655 | + public function getURLGenerator() { |
|
| 1656 | + return $this->query(IURLGenerator::class); |
|
| 1657 | + } |
|
| 1658 | + |
|
| 1659 | + /** |
|
| 1660 | + * @return AppFetcher |
|
| 1661 | + * @deprecated |
|
| 1662 | + */ |
|
| 1663 | + public function getAppFetcher() { |
|
| 1664 | + return $this->query(AppFetcher::class); |
|
| 1665 | + } |
|
| 1666 | + |
|
| 1667 | + /** |
|
| 1668 | + * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
| 1669 | + * getMemCacheFactory() instead. |
|
| 1670 | + * |
|
| 1671 | + * @return ICache |
|
| 1672 | + * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
| 1673 | + */ |
|
| 1674 | + public function getCache() { |
|
| 1675 | + return $this->query(ICache::class); |
|
| 1676 | + } |
|
| 1677 | + |
|
| 1678 | + /** |
|
| 1679 | + * Returns an \OCP\CacheFactory instance |
|
| 1680 | + * |
|
| 1681 | + * @return \OCP\ICacheFactory |
|
| 1682 | + * @deprecated |
|
| 1683 | + */ |
|
| 1684 | + public function getMemCacheFactory() { |
|
| 1685 | + return $this->query(Factory::class); |
|
| 1686 | + } |
|
| 1687 | + |
|
| 1688 | + /** |
|
| 1689 | + * Returns an \OC\RedisFactory instance |
|
| 1690 | + * |
|
| 1691 | + * @return \OC\RedisFactory |
|
| 1692 | + * @deprecated |
|
| 1693 | + */ |
|
| 1694 | + public function getGetRedisFactory() { |
|
| 1695 | + return $this->query('RedisFactory'); |
|
| 1696 | + } |
|
| 1697 | + |
|
| 1698 | + |
|
| 1699 | + /** |
|
| 1700 | + * Returns the current session |
|
| 1701 | + * |
|
| 1702 | + * @return \OCP\IDBConnection |
|
| 1703 | + * @deprecated |
|
| 1704 | + */ |
|
| 1705 | + public function getDatabaseConnection() { |
|
| 1706 | + return $this->query(IDBConnection::class); |
|
| 1707 | + } |
|
| 1708 | + |
|
| 1709 | + /** |
|
| 1710 | + * Returns the activity manager |
|
| 1711 | + * |
|
| 1712 | + * @return \OCP\Activity\IManager |
|
| 1713 | + * @deprecated |
|
| 1714 | + */ |
|
| 1715 | + public function getActivityManager() { |
|
| 1716 | + return $this->query(\OCP\Activity\IManager::class); |
|
| 1717 | + } |
|
| 1718 | + |
|
| 1719 | + /** |
|
| 1720 | + * Returns an job list for controlling background jobs |
|
| 1721 | + * |
|
| 1722 | + * @return IJobList |
|
| 1723 | + * @deprecated |
|
| 1724 | + */ |
|
| 1725 | + public function getJobList() { |
|
| 1726 | + return $this->query(IJobList::class); |
|
| 1727 | + } |
|
| 1728 | + |
|
| 1729 | + /** |
|
| 1730 | + * Returns a logger instance |
|
| 1731 | + * |
|
| 1732 | + * @return ILogger |
|
| 1733 | + * @deprecated |
|
| 1734 | + */ |
|
| 1735 | + public function getLogger() { |
|
| 1736 | + return $this->query(ILogger::class); |
|
| 1737 | + } |
|
| 1738 | + |
|
| 1739 | + /** |
|
| 1740 | + * @return ILogFactory |
|
| 1741 | + * @throws \OCP\AppFramework\QueryException |
|
| 1742 | + * @deprecated |
|
| 1743 | + */ |
|
| 1744 | + public function getLogFactory() { |
|
| 1745 | + return $this->query(ILogFactory::class); |
|
| 1746 | + } |
|
| 1747 | + |
|
| 1748 | + /** |
|
| 1749 | + * Returns a router for generating and matching urls |
|
| 1750 | + * |
|
| 1751 | + * @return IRouter |
|
| 1752 | + * @deprecated |
|
| 1753 | + */ |
|
| 1754 | + public function getRouter() { |
|
| 1755 | + return $this->query(IRouter::class); |
|
| 1756 | + } |
|
| 1757 | + |
|
| 1758 | + /** |
|
| 1759 | + * Returns a search instance |
|
| 1760 | + * |
|
| 1761 | + * @return ISearch |
|
| 1762 | + * @deprecated |
|
| 1763 | + */ |
|
| 1764 | + public function getSearch() { |
|
| 1765 | + return $this->query(ISearch::class); |
|
| 1766 | + } |
|
| 1767 | + |
|
| 1768 | + /** |
|
| 1769 | + * Returns a SecureRandom instance |
|
| 1770 | + * |
|
| 1771 | + * @return \OCP\Security\ISecureRandom |
|
| 1772 | + * @deprecated |
|
| 1773 | + */ |
|
| 1774 | + public function getSecureRandom() { |
|
| 1775 | + return $this->query(ISecureRandom::class); |
|
| 1776 | + } |
|
| 1777 | + |
|
| 1778 | + /** |
|
| 1779 | + * Returns a Crypto instance |
|
| 1780 | + * |
|
| 1781 | + * @return ICrypto |
|
| 1782 | + * @deprecated |
|
| 1783 | + */ |
|
| 1784 | + public function getCrypto() { |
|
| 1785 | + return $this->query(ICrypto::class); |
|
| 1786 | + } |
|
| 1787 | + |
|
| 1788 | + /** |
|
| 1789 | + * Returns a Hasher instance |
|
| 1790 | + * |
|
| 1791 | + * @return IHasher |
|
| 1792 | + * @deprecated |
|
| 1793 | + */ |
|
| 1794 | + public function getHasher() { |
|
| 1795 | + return $this->query(IHasher::class); |
|
| 1796 | + } |
|
| 1797 | + |
|
| 1798 | + /** |
|
| 1799 | + * Returns a CredentialsManager instance |
|
| 1800 | + * |
|
| 1801 | + * @return ICredentialsManager |
|
| 1802 | + * @deprecated |
|
| 1803 | + */ |
|
| 1804 | + public function getCredentialsManager() { |
|
| 1805 | + return $this->query(ICredentialsManager::class); |
|
| 1806 | + } |
|
| 1807 | + |
|
| 1808 | + /** |
|
| 1809 | + * Get the certificate manager for the user |
|
| 1810 | + * |
|
| 1811 | + * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
| 1812 | + * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
| 1813 | + * @deprecated |
|
| 1814 | + */ |
|
| 1815 | + public function getCertificateManager($userId = '') { |
|
| 1816 | + if ($userId === '') { |
|
| 1817 | + $userSession = $this->getUserSession(); |
|
| 1818 | + $user = $userSession->getUser(); |
|
| 1819 | + if (is_null($user)) { |
|
| 1820 | + return null; |
|
| 1821 | + } |
|
| 1822 | + $userId = $user->getUID(); |
|
| 1823 | + } |
|
| 1824 | + return new CertificateManager( |
|
| 1825 | + $userId, |
|
| 1826 | + new View(), |
|
| 1827 | + $this->getConfig(), |
|
| 1828 | + $this->getLogger(), |
|
| 1829 | + $this->getSecureRandom() |
|
| 1830 | + ); |
|
| 1831 | + } |
|
| 1832 | + |
|
| 1833 | + /** |
|
| 1834 | + * Returns an instance of the HTTP client service |
|
| 1835 | + * |
|
| 1836 | + * @return IClientService |
|
| 1837 | + * @deprecated |
|
| 1838 | + */ |
|
| 1839 | + public function getHTTPClientService() { |
|
| 1840 | + return $this->query(IClientService::class); |
|
| 1841 | + } |
|
| 1842 | + |
|
| 1843 | + /** |
|
| 1844 | + * Create a new event source |
|
| 1845 | + * |
|
| 1846 | + * @return \OCP\IEventSource |
|
| 1847 | + * @deprecated |
|
| 1848 | + */ |
|
| 1849 | + public function createEventSource() { |
|
| 1850 | + return new \OC_EventSource(); |
|
| 1851 | + } |
|
| 1852 | + |
|
| 1853 | + /** |
|
| 1854 | + * Get the active event logger |
|
| 1855 | + * |
|
| 1856 | + * The returned logger only logs data when debug mode is enabled |
|
| 1857 | + * |
|
| 1858 | + * @return IEventLogger |
|
| 1859 | + * @deprecated |
|
| 1860 | + */ |
|
| 1861 | + public function getEventLogger() { |
|
| 1862 | + return $this->query(IEventLogger::class); |
|
| 1863 | + } |
|
| 1864 | + |
|
| 1865 | + /** |
|
| 1866 | + * Get the active query logger |
|
| 1867 | + * |
|
| 1868 | + * The returned logger only logs data when debug mode is enabled |
|
| 1869 | + * |
|
| 1870 | + * @return IQueryLogger |
|
| 1871 | + * @deprecated |
|
| 1872 | + */ |
|
| 1873 | + public function getQueryLogger() { |
|
| 1874 | + return $this->query(IQueryLogger::class); |
|
| 1875 | + } |
|
| 1876 | + |
|
| 1877 | + /** |
|
| 1878 | + * Get the manager for temporary files and folders |
|
| 1879 | + * |
|
| 1880 | + * @return \OCP\ITempManager |
|
| 1881 | + * @deprecated |
|
| 1882 | + */ |
|
| 1883 | + public function getTempManager() { |
|
| 1884 | + return $this->query(ITempManager::class); |
|
| 1885 | + } |
|
| 1886 | + |
|
| 1887 | + /** |
|
| 1888 | + * Get the app manager |
|
| 1889 | + * |
|
| 1890 | + * @return \OCP\App\IAppManager |
|
| 1891 | + * @deprecated |
|
| 1892 | + */ |
|
| 1893 | + public function getAppManager() { |
|
| 1894 | + return $this->query(IAppManager::class); |
|
| 1895 | + } |
|
| 1896 | + |
|
| 1897 | + /** |
|
| 1898 | + * Creates a new mailer |
|
| 1899 | + * |
|
| 1900 | + * @return IMailer |
|
| 1901 | + * @deprecated |
|
| 1902 | + */ |
|
| 1903 | + public function getMailer() { |
|
| 1904 | + return $this->query(IMailer::class); |
|
| 1905 | + } |
|
| 1906 | + |
|
| 1907 | + /** |
|
| 1908 | + * Get the webroot |
|
| 1909 | + * |
|
| 1910 | + * @return string |
|
| 1911 | + * @deprecated |
|
| 1912 | + */ |
|
| 1913 | + public function getWebRoot() { |
|
| 1914 | + return $this->webRoot; |
|
| 1915 | + } |
|
| 1916 | + |
|
| 1917 | + /** |
|
| 1918 | + * @return \OC\OCSClient |
|
| 1919 | + * @deprecated |
|
| 1920 | + */ |
|
| 1921 | + public function getOcsClient() { |
|
| 1922 | + return $this->query('OcsClient'); |
|
| 1923 | + } |
|
| 1924 | + |
|
| 1925 | + /** |
|
| 1926 | + * @return IDateTimeZone |
|
| 1927 | + * @deprecated |
|
| 1928 | + */ |
|
| 1929 | + public function getDateTimeZone() { |
|
| 1930 | + return $this->query(IDateTimeZone::class); |
|
| 1931 | + } |
|
| 1932 | + |
|
| 1933 | + /** |
|
| 1934 | + * @return IDateTimeFormatter |
|
| 1935 | + * @deprecated |
|
| 1936 | + */ |
|
| 1937 | + public function getDateTimeFormatter() { |
|
| 1938 | + return $this->query(IDateTimeFormatter::class); |
|
| 1939 | + } |
|
| 1940 | + |
|
| 1941 | + /** |
|
| 1942 | + * @return IMountProviderCollection |
|
| 1943 | + * @deprecated |
|
| 1944 | + */ |
|
| 1945 | + public function getMountProviderCollection() { |
|
| 1946 | + return $this->query(IMountProviderCollection::class); |
|
| 1947 | + } |
|
| 1948 | + |
|
| 1949 | + /** |
|
| 1950 | + * Get the IniWrapper |
|
| 1951 | + * |
|
| 1952 | + * @return IniGetWrapper |
|
| 1953 | + * @deprecated |
|
| 1954 | + */ |
|
| 1955 | + public function getIniWrapper() { |
|
| 1956 | + return $this->query('IniWrapper'); |
|
| 1957 | + } |
|
| 1958 | + |
|
| 1959 | + /** |
|
| 1960 | + * @return \OCP\Command\IBus |
|
| 1961 | + * @deprecated |
|
| 1962 | + */ |
|
| 1963 | + public function getCommandBus() { |
|
| 1964 | + return $this->query('AsyncCommandBus'); |
|
| 1965 | + } |
|
| 1966 | + |
|
| 1967 | + /** |
|
| 1968 | + * Get the trusted domain helper |
|
| 1969 | + * |
|
| 1970 | + * @return TrustedDomainHelper |
|
| 1971 | + * @deprecated |
|
| 1972 | + */ |
|
| 1973 | + public function getTrustedDomainHelper() { |
|
| 1974 | + return $this->query('TrustedDomainHelper'); |
|
| 1975 | + } |
|
| 1976 | + |
|
| 1977 | + /** |
|
| 1978 | + * Get the locking provider |
|
| 1979 | + * |
|
| 1980 | + * @return ILockingProvider |
|
| 1981 | + * @since 8.1.0 |
|
| 1982 | + * @deprecated |
|
| 1983 | + */ |
|
| 1984 | + public function getLockingProvider() { |
|
| 1985 | + return $this->query(ILockingProvider::class); |
|
| 1986 | + } |
|
| 1987 | + |
|
| 1988 | + /** |
|
| 1989 | + * @return IMountManager |
|
| 1990 | + * @deprecated |
|
| 1991 | + **/ |
|
| 1992 | + public function getMountManager() { |
|
| 1993 | + return $this->query(IMountManager::class); |
|
| 1994 | + } |
|
| 1995 | + |
|
| 1996 | + /** |
|
| 1997 | + * @return IUserMountCache |
|
| 1998 | + * @deprecated |
|
| 1999 | + */ |
|
| 2000 | + public function getUserMountCache() { |
|
| 2001 | + return $this->query(IUserMountCache::class); |
|
| 2002 | + } |
|
| 2003 | + |
|
| 2004 | + /** |
|
| 2005 | + * Get the MimeTypeDetector |
|
| 2006 | + * |
|
| 2007 | + * @return IMimeTypeDetector |
|
| 2008 | + * @deprecated |
|
| 2009 | + */ |
|
| 2010 | + public function getMimeTypeDetector() { |
|
| 2011 | + return $this->query(IMimeTypeDetector::class); |
|
| 2012 | + } |
|
| 2013 | + |
|
| 2014 | + /** |
|
| 2015 | + * Get the MimeTypeLoader |
|
| 2016 | + * |
|
| 2017 | + * @return IMimeTypeLoader |
|
| 2018 | + * @deprecated |
|
| 2019 | + */ |
|
| 2020 | + public function getMimeTypeLoader() { |
|
| 2021 | + return $this->query(IMimeTypeLoader::class); |
|
| 2022 | + } |
|
| 2023 | + |
|
| 2024 | + /** |
|
| 2025 | + * Get the manager of all the capabilities |
|
| 2026 | + * |
|
| 2027 | + * @return CapabilitiesManager |
|
| 2028 | + * @deprecated |
|
| 2029 | + */ |
|
| 2030 | + public function getCapabilitiesManager() { |
|
| 2031 | + return $this->query(CapabilitiesManager::class); |
|
| 2032 | + } |
|
| 2033 | + |
|
| 2034 | + /** |
|
| 2035 | + * Get the EventDispatcher |
|
| 2036 | + * |
|
| 2037 | + * @return EventDispatcherInterface |
|
| 2038 | + * @since 8.2.0 |
|
| 2039 | + * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher |
|
| 2040 | + */ |
|
| 2041 | + public function getEventDispatcher() { |
|
| 2042 | + return $this->query(\OC\EventDispatcher\SymfonyAdapter::class); |
|
| 2043 | + } |
|
| 2044 | + |
|
| 2045 | + /** |
|
| 2046 | + * Get the Notification Manager |
|
| 2047 | + * |
|
| 2048 | + * @return \OCP\Notification\IManager |
|
| 2049 | + * @since 8.2.0 |
|
| 2050 | + * @deprecated |
|
| 2051 | + */ |
|
| 2052 | + public function getNotificationManager() { |
|
| 2053 | + return $this->query(\OCP\Notification\IManager::class); |
|
| 2054 | + } |
|
| 2055 | + |
|
| 2056 | + /** |
|
| 2057 | + * @return ICommentsManager |
|
| 2058 | + * @deprecated |
|
| 2059 | + */ |
|
| 2060 | + public function getCommentsManager() { |
|
| 2061 | + return $this->query(ICommentsManager::class); |
|
| 2062 | + } |
|
| 2063 | + |
|
| 2064 | + /** |
|
| 2065 | + * @return \OCA\Theming\ThemingDefaults |
|
| 2066 | + * @deprecated |
|
| 2067 | + */ |
|
| 2068 | + public function getThemingDefaults() { |
|
| 2069 | + return $this->query('ThemingDefaults'); |
|
| 2070 | + } |
|
| 2071 | + |
|
| 2072 | + /** |
|
| 2073 | + * @return \OC\IntegrityCheck\Checker |
|
| 2074 | + * @deprecated |
|
| 2075 | + */ |
|
| 2076 | + public function getIntegrityCodeChecker() { |
|
| 2077 | + return $this->query('IntegrityCodeChecker'); |
|
| 2078 | + } |
|
| 2079 | + |
|
| 2080 | + /** |
|
| 2081 | + * @return \OC\Session\CryptoWrapper |
|
| 2082 | + * @deprecated |
|
| 2083 | + */ |
|
| 2084 | + public function getSessionCryptoWrapper() { |
|
| 2085 | + return $this->query('CryptoWrapper'); |
|
| 2086 | + } |
|
| 2087 | + |
|
| 2088 | + /** |
|
| 2089 | + * @return CsrfTokenManager |
|
| 2090 | + * @deprecated |
|
| 2091 | + */ |
|
| 2092 | + public function getCsrfTokenManager() { |
|
| 2093 | + return $this->query(CsrfTokenManager::class); |
|
| 2094 | + } |
|
| 2095 | + |
|
| 2096 | + /** |
|
| 2097 | + * @return Throttler |
|
| 2098 | + * @deprecated |
|
| 2099 | + */ |
|
| 2100 | + public function getBruteForceThrottler() { |
|
| 2101 | + return $this->query(Throttler::class); |
|
| 2102 | + } |
|
| 2103 | + |
|
| 2104 | + /** |
|
| 2105 | + * @return IContentSecurityPolicyManager |
|
| 2106 | + * @deprecated |
|
| 2107 | + */ |
|
| 2108 | + public function getContentSecurityPolicyManager() { |
|
| 2109 | + return $this->query(ContentSecurityPolicyManager::class); |
|
| 2110 | + } |
|
| 2111 | + |
|
| 2112 | + /** |
|
| 2113 | + * @return ContentSecurityPolicyNonceManager |
|
| 2114 | + * @deprecated |
|
| 2115 | + */ |
|
| 2116 | + public function getContentSecurityPolicyNonceManager() { |
|
| 2117 | + return $this->query(ContentSecurityPolicyNonceManager::class); |
|
| 2118 | + } |
|
| 2119 | + |
|
| 2120 | + /** |
|
| 2121 | + * Not a public API as of 8.2, wait for 9.0 |
|
| 2122 | + * |
|
| 2123 | + * @return \OCA\Files_External\Service\BackendService |
|
| 2124 | + * @deprecated |
|
| 2125 | + */ |
|
| 2126 | + public function getStoragesBackendService() { |
|
| 2127 | + return $this->query(BackendService::class); |
|
| 2128 | + } |
|
| 2129 | + |
|
| 2130 | + /** |
|
| 2131 | + * Not a public API as of 8.2, wait for 9.0 |
|
| 2132 | + * |
|
| 2133 | + * @return \OCA\Files_External\Service\GlobalStoragesService |
|
| 2134 | + * @deprecated |
|
| 2135 | + */ |
|
| 2136 | + public function getGlobalStoragesService() { |
|
| 2137 | + return $this->query(GlobalStoragesService::class); |
|
| 2138 | + } |
|
| 2139 | + |
|
| 2140 | + /** |
|
| 2141 | + * Not a public API as of 8.2, wait for 9.0 |
|
| 2142 | + * |
|
| 2143 | + * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
| 2144 | + * @deprecated |
|
| 2145 | + */ |
|
| 2146 | + public function getUserGlobalStoragesService() { |
|
| 2147 | + return $this->query(UserGlobalStoragesService::class); |
|
| 2148 | + } |
|
| 2149 | + |
|
| 2150 | + /** |
|
| 2151 | + * Not a public API as of 8.2, wait for 9.0 |
|
| 2152 | + * |
|
| 2153 | + * @return \OCA\Files_External\Service\UserStoragesService |
|
| 2154 | + * @deprecated |
|
| 2155 | + */ |
|
| 2156 | + public function getUserStoragesService() { |
|
| 2157 | + return $this->query(UserStoragesService::class); |
|
| 2158 | + } |
|
| 2159 | + |
|
| 2160 | + /** |
|
| 2161 | + * @return \OCP\Share\IManager |
|
| 2162 | + * @deprecated |
|
| 2163 | + */ |
|
| 2164 | + public function getShareManager() { |
|
| 2165 | + return $this->query(\OCP\Share\IManager::class); |
|
| 2166 | + } |
|
| 2167 | + |
|
| 2168 | + /** |
|
| 2169 | + * @return \OCP\Collaboration\Collaborators\ISearch |
|
| 2170 | + * @deprecated |
|
| 2171 | + */ |
|
| 2172 | + public function getCollaboratorSearch() { |
|
| 2173 | + return $this->query(\OCP\Collaboration\Collaborators\ISearch::class); |
|
| 2174 | + } |
|
| 2175 | + |
|
| 2176 | + /** |
|
| 2177 | + * @return \OCP\Collaboration\AutoComplete\IManager |
|
| 2178 | + * @deprecated |
|
| 2179 | + */ |
|
| 2180 | + public function getAutoCompleteManager() { |
|
| 2181 | + return $this->query(IManager::class); |
|
| 2182 | + } |
|
| 2183 | + |
|
| 2184 | + /** |
|
| 2185 | + * Returns the LDAP Provider |
|
| 2186 | + * |
|
| 2187 | + * @return \OCP\LDAP\ILDAPProvider |
|
| 2188 | + * @deprecated |
|
| 2189 | + */ |
|
| 2190 | + public function getLDAPProvider() { |
|
| 2191 | + return $this->query('LDAPProvider'); |
|
| 2192 | + } |
|
| 2193 | + |
|
| 2194 | + /** |
|
| 2195 | + * @return \OCP\Settings\IManager |
|
| 2196 | + * @deprecated |
|
| 2197 | + */ |
|
| 2198 | + public function getSettingsManager() { |
|
| 2199 | + return $this->query('SettingsManager'); |
|
| 2200 | + } |
|
| 2201 | + |
|
| 2202 | + /** |
|
| 2203 | + * @return \OCP\Files\IAppData |
|
| 2204 | + * @deprecated |
|
| 2205 | + */ |
|
| 2206 | + public function getAppDataDir($app) { |
|
| 2207 | + /** @var \OC\Files\AppData\Factory $factory */ |
|
| 2208 | + $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
| 2209 | + return $factory->get($app); |
|
| 2210 | + } |
|
| 2211 | + |
|
| 2212 | + /** |
|
| 2213 | + * @return \OCP\Lockdown\ILockdownManager |
|
| 2214 | + * @deprecated |
|
| 2215 | + */ |
|
| 2216 | + public function getLockdownManager() { |
|
| 2217 | + return $this->query('LockdownManager'); |
|
| 2218 | + } |
|
| 2219 | + |
|
| 2220 | + /** |
|
| 2221 | + * @return \OCP\Federation\ICloudIdManager |
|
| 2222 | + * @deprecated |
|
| 2223 | + */ |
|
| 2224 | + public function getCloudIdManager() { |
|
| 2225 | + return $this->query(ICloudIdManager::class); |
|
| 2226 | + } |
|
| 2227 | + |
|
| 2228 | + /** |
|
| 2229 | + * @return \OCP\GlobalScale\IConfig |
|
| 2230 | + * @deprecated |
|
| 2231 | + */ |
|
| 2232 | + public function getGlobalScaleConfig() { |
|
| 2233 | + return $this->query(IConfig::class); |
|
| 2234 | + } |
|
| 2235 | + |
|
| 2236 | + /** |
|
| 2237 | + * @return \OCP\Federation\ICloudFederationProviderManager |
|
| 2238 | + * @deprecated |
|
| 2239 | + */ |
|
| 2240 | + public function getCloudFederationProviderManager() { |
|
| 2241 | + return $this->query(ICloudFederationProviderManager::class); |
|
| 2242 | + } |
|
| 2243 | + |
|
| 2244 | + /** |
|
| 2245 | + * @return \OCP\Remote\Api\IApiFactory |
|
| 2246 | + * @deprecated |
|
| 2247 | + */ |
|
| 2248 | + public function getRemoteApiFactory() { |
|
| 2249 | + return $this->query(IApiFactory::class); |
|
| 2250 | + } |
|
| 2251 | + |
|
| 2252 | + /** |
|
| 2253 | + * @return \OCP\Federation\ICloudFederationFactory |
|
| 2254 | + * @deprecated |
|
| 2255 | + */ |
|
| 2256 | + public function getCloudFederationFactory() { |
|
| 2257 | + return $this->query(ICloudFederationFactory::class); |
|
| 2258 | + } |
|
| 2259 | + |
|
| 2260 | + /** |
|
| 2261 | + * @return \OCP\Remote\IInstanceFactory |
|
| 2262 | + * @deprecated |
|
| 2263 | + */ |
|
| 2264 | + public function getRemoteInstanceFactory() { |
|
| 2265 | + return $this->query(IInstanceFactory::class); |
|
| 2266 | + } |
|
| 2267 | + |
|
| 2268 | + /** |
|
| 2269 | + * @return IStorageFactory |
|
| 2270 | + * @deprecated |
|
| 2271 | + */ |
|
| 2272 | + public function getStorageFactory() { |
|
| 2273 | + return $this->query(IStorageFactory::class); |
|
| 2274 | + } |
|
| 2275 | + |
|
| 2276 | + /** |
|
| 2277 | + * Get the Preview GeneratorHelper |
|
| 2278 | + * |
|
| 2279 | + * @return GeneratorHelper |
|
| 2280 | + * @since 17.0.0 |
|
| 2281 | + * @deprecated |
|
| 2282 | + */ |
|
| 2283 | + public function getGeneratorHelper() { |
|
| 2284 | + return $this->query(\OC\Preview\GeneratorHelper::class); |
|
| 2285 | + } |
|
| 2286 | + |
|
| 2287 | + private function registerDeprecatedAlias(string $alias, string $target) { |
|
| 2288 | + $this->registerService($alias, function (ContainerInterface $container) use ($target, $alias) { |
|
| 2289 | + try { |
|
| 2290 | + /** @var ILogger $logger */ |
|
| 2291 | + $logger = $container->get(ILogger::class); |
|
| 2292 | + $logger->debug('The requested alias "' . $alias . '" is depreacted. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']); |
|
| 2293 | + } catch (ContainerExceptionInterface $e) { |
|
| 2294 | + // Could not get logger. Continue |
|
| 2295 | + } |
|
| 2296 | + |
|
| 2297 | + return $container->get($target); |
|
| 2298 | + }, false); |
|
| 2299 | + } |
|
| 2300 | 2300 | } |
@@ -258,10 +258,10 @@ discard block |
||
| 258 | 258 | $this->registerParameter('isCLI', \OC::$CLI); |
| 259 | 259 | $this->registerParameter('serverRoot', \OC::$SERVERROOT); |
| 260 | 260 | |
| 261 | - $this->registerService(ContainerInterface::class, function (ContainerInterface $c) { |
|
| 261 | + $this->registerService(ContainerInterface::class, function(ContainerInterface $c) { |
|
| 262 | 262 | return $c; |
| 263 | 263 | }); |
| 264 | - $this->registerService(\OCP\IServerContainer::class, function (ContainerInterface $c) { |
|
| 264 | + $this->registerService(\OCP\IServerContainer::class, function(ContainerInterface $c) { |
|
| 265 | 265 | return $c; |
| 266 | 266 | }); |
| 267 | 267 | |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | $this->registerAlias(IActionFactory::class, ActionFactory::class); |
| 287 | 287 | |
| 288 | 288 | |
| 289 | - $this->registerService(IPreview::class, function (Server $c) { |
|
| 289 | + $this->registerService(IPreview::class, function(Server $c) { |
|
| 290 | 290 | return new PreviewManager( |
| 291 | 291 | $c->getConfig(), |
| 292 | 292 | $c->getRootFolder(), |
@@ -299,13 +299,13 @@ discard block |
||
| 299 | 299 | /** @deprecated 19.0.0 */ |
| 300 | 300 | $this->registerDeprecatedAlias('PreviewManager', IPreview::class); |
| 301 | 301 | |
| 302 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
| 302 | + $this->registerService(\OC\Preview\Watcher::class, function(Server $c) { |
|
| 303 | 303 | return new \OC\Preview\Watcher( |
| 304 | 304 | new \OC\Preview\Storage\Root($c->getRootFolder(), $c->getSystemConfig()) |
| 305 | 305 | ); |
| 306 | 306 | }); |
| 307 | 307 | |
| 308 | - $this->registerService(\OCP\Encryption\IManager::class, function (Server $c) { |
|
| 308 | + $this->registerService(\OCP\Encryption\IManager::class, function(Server $c) { |
|
| 309 | 309 | $view = new View(); |
| 310 | 310 | $util = new Encryption\Util( |
| 311 | 311 | $view, |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | /** @deprecated 19.0.0 */ |
| 326 | 326 | $this->registerDeprecatedAlias('EncryptionManager', \OCP\Encryption\IManager::class); |
| 327 | 327 | |
| 328 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
| 328 | + $this->registerService('EncryptionFileHelper', function(Server $c) { |
|
| 329 | 329 | $util = new Encryption\Util( |
| 330 | 330 | new View(), |
| 331 | 331 | $c->getUserManager(), |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | ); |
| 340 | 340 | }); |
| 341 | 341 | |
| 342 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
| 342 | + $this->registerService('EncryptionKeyStorage', function(Server $c) { |
|
| 343 | 343 | $view = new View(); |
| 344 | 344 | $util = new Encryption\Util( |
| 345 | 345 | $view, |
@@ -357,21 +357,21 @@ discard block |
||
| 357 | 357 | /** @deprecated 19.0.0 */ |
| 358 | 358 | $this->registerDeprecatedAlias('TagManager', \OCP\ITagManager::class); |
| 359 | 359 | |
| 360 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
| 360 | + $this->registerService('SystemTagManagerFactory', function(Server $c) { |
|
| 361 | 361 | $config = $c->getConfig(); |
| 362 | 362 | $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class); |
| 363 | 363 | return new $factoryClass($this); |
| 364 | 364 | }); |
| 365 | - $this->registerService(ISystemTagManager::class, function (Server $c) { |
|
| 365 | + $this->registerService(ISystemTagManager::class, function(Server $c) { |
|
| 366 | 366 | return $c->query('SystemTagManagerFactory')->getManager(); |
| 367 | 367 | }); |
| 368 | 368 | /** @deprecated 19.0.0 */ |
| 369 | 369 | $this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class); |
| 370 | 370 | |
| 371 | - $this->registerService(ISystemTagObjectMapper::class, function (Server $c) { |
|
| 371 | + $this->registerService(ISystemTagObjectMapper::class, function(Server $c) { |
|
| 372 | 372 | return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
| 373 | 373 | }); |
| 374 | - $this->registerService('RootFolder', function (Server $c) { |
|
| 374 | + $this->registerService('RootFolder', function(Server $c) { |
|
| 375 | 375 | $manager = \OC\Files\Filesystem::getMountManager(null); |
| 376 | 376 | $view = new View(); |
| 377 | 377 | $root = new Root( |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | |
| 389 | 389 | return $root; |
| 390 | 390 | }); |
| 391 | - $this->registerService(HookConnector::class, function (Server $c) { |
|
| 391 | + $this->registerService(HookConnector::class, function(Server $c) { |
|
| 392 | 392 | return new HookConnector( |
| 393 | 393 | $c->query(IRootFolder::class), |
| 394 | 394 | new View(), |
@@ -400,8 +400,8 @@ discard block |
||
| 400 | 400 | /** @deprecated 19.0.0 */ |
| 401 | 401 | $this->registerDeprecatedAlias('SystemTagObjectMapper', ISystemTagObjectMapper::class); |
| 402 | 402 | |
| 403 | - $this->registerService(IRootFolder::class, function (Server $c) { |
|
| 404 | - return new LazyRoot(function () use ($c) { |
|
| 403 | + $this->registerService(IRootFolder::class, function(Server $c) { |
|
| 404 | + return new LazyRoot(function() use ($c) { |
|
| 405 | 405 | return $c->query('RootFolder'); |
| 406 | 406 | }); |
| 407 | 407 | }); |
@@ -412,44 +412,44 @@ discard block |
||
| 412 | 412 | $this->registerDeprecatedAlias('UserManager', \OC\User\Manager::class); |
| 413 | 413 | $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); |
| 414 | 414 | |
| 415 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
| 415 | + $this->registerService(\OCP\IGroupManager::class, function(Server $c) { |
|
| 416 | 416 | $groupManager = new \OC\Group\Manager($this->getUserManager(), $c->getEventDispatcher(), $this->getLogger()); |
| 417 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
| 417 | + $groupManager->listen('\OC\Group', 'preCreate', function($gid) { |
|
| 418 | 418 | \OC_Hook::emit('OC_Group', 'pre_createGroup', ['run' => true, 'gid' => $gid]); |
| 419 | 419 | |
| 420 | 420 | /** @var IEventDispatcher $dispatcher */ |
| 421 | 421 | $dispatcher = $this->query(IEventDispatcher::class); |
| 422 | 422 | $dispatcher->dispatchTyped(new BeforeGroupCreatedEvent($gid)); |
| 423 | 423 | }); |
| 424 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $group) { |
|
| 424 | + $groupManager->listen('\OC\Group', 'postCreate', function(\OC\Group\Group $group) { |
|
| 425 | 425 | \OC_Hook::emit('OC_User', 'post_createGroup', ['gid' => $group->getGID()]); |
| 426 | 426 | |
| 427 | 427 | /** @var IEventDispatcher $dispatcher */ |
| 428 | 428 | $dispatcher = $this->query(IEventDispatcher::class); |
| 429 | 429 | $dispatcher->dispatchTyped(new GroupCreatedEvent($group)); |
| 430 | 430 | }); |
| 431 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
| 431 | + $groupManager->listen('\OC\Group', 'preDelete', function(\OC\Group\Group $group) { |
|
| 432 | 432 | \OC_Hook::emit('OC_Group', 'pre_deleteGroup', ['run' => true, 'gid' => $group->getGID()]); |
| 433 | 433 | |
| 434 | 434 | /** @var IEventDispatcher $dispatcher */ |
| 435 | 435 | $dispatcher = $this->query(IEventDispatcher::class); |
| 436 | 436 | $dispatcher->dispatchTyped(new BeforeGroupDeletedEvent($group)); |
| 437 | 437 | }); |
| 438 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
| 438 | + $groupManager->listen('\OC\Group', 'postDelete', function(\OC\Group\Group $group) { |
|
| 439 | 439 | \OC_Hook::emit('OC_User', 'post_deleteGroup', ['gid' => $group->getGID()]); |
| 440 | 440 | |
| 441 | 441 | /** @var IEventDispatcher $dispatcher */ |
| 442 | 442 | $dispatcher = $this->query(IEventDispatcher::class); |
| 443 | 443 | $dispatcher->dispatchTyped(new GroupDeletedEvent($group)); |
| 444 | 444 | }); |
| 445 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 445 | + $groupManager->listen('\OC\Group', 'preAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
| 446 | 446 | \OC_Hook::emit('OC_Group', 'pre_addToGroup', ['run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()]); |
| 447 | 447 | |
| 448 | 448 | /** @var IEventDispatcher $dispatcher */ |
| 449 | 449 | $dispatcher = $this->query(IEventDispatcher::class); |
| 450 | 450 | $dispatcher->dispatchTyped(new BeforeUserAddedEvent($group, $user)); |
| 451 | 451 | }); |
| 452 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 452 | + $groupManager->listen('\OC\Group', 'postAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
| 453 | 453 | \OC_Hook::emit('OC_Group', 'post_addToGroup', ['uid' => $user->getUID(), 'gid' => $group->getGID()]); |
| 454 | 454 | //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
| 455 | 455 | \OC_Hook::emit('OC_User', 'post_addToGroup', ['uid' => $user->getUID(), 'gid' => $group->getGID()]); |
@@ -458,12 +458,12 @@ discard block |
||
| 458 | 458 | $dispatcher = $this->query(IEventDispatcher::class); |
| 459 | 459 | $dispatcher->dispatchTyped(new UserAddedEvent($group, $user)); |
| 460 | 460 | }); |
| 461 | - $groupManager->listen('\OC\Group', 'preRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 461 | + $groupManager->listen('\OC\Group', 'preRemoveUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
| 462 | 462 | /** @var IEventDispatcher $dispatcher */ |
| 463 | 463 | $dispatcher = $this->query(IEventDispatcher::class); |
| 464 | 464 | $dispatcher->dispatchTyped(new BeforeUserRemovedEvent($group, $user)); |
| 465 | 465 | }); |
| 466 | - $groupManager->listen('\OC\Group', 'postRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 466 | + $groupManager->listen('\OC\Group', 'postRemoveUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
| 467 | 467 | /** @var IEventDispatcher $dispatcher */ |
| 468 | 468 | $dispatcher = $this->query(IEventDispatcher::class); |
| 469 | 469 | $dispatcher->dispatchTyped(new UserRemovedEvent($group, $user)); |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | /** @deprecated 19.0.0 */ |
| 474 | 474 | $this->registerDeprecatedAlias('GroupManager', \OCP\IGroupManager::class); |
| 475 | 475 | |
| 476 | - $this->registerService(Store::class, function (Server $c) { |
|
| 476 | + $this->registerService(Store::class, function(Server $c) { |
|
| 477 | 477 | $session = $c->getSession(); |
| 478 | 478 | if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
| 479 | 479 | $tokenProvider = $c->query(IProvider::class); |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | $this->registerAlias(IStore::class, Store::class); |
| 487 | 487 | $this->registerAlias(IProvider::class, Authentication\Token\Manager::class); |
| 488 | 488 | |
| 489 | - $this->registerService(\OC\User\Session::class, function (Server $c) { |
|
| 489 | + $this->registerService(\OC\User\Session::class, function(Server $c) { |
|
| 490 | 490 | $manager = $c->getUserManager(); |
| 491 | 491 | $session = new \OC\Session\Memory(''); |
| 492 | 492 | $timeFactory = new TimeFactory(); |
@@ -511,14 +511,14 @@ discard block |
||
| 511 | 511 | $c->getLogger(), |
| 512 | 512 | $c->query(IEventDispatcher::class) |
| 513 | 513 | ); |
| 514 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
| 514 | + $userSession->listen('\OC\User', 'preCreateUser', function($uid, $password) { |
|
| 515 | 515 | \OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]); |
| 516 | 516 | |
| 517 | 517 | /** @var IEventDispatcher $dispatcher */ |
| 518 | 518 | $dispatcher = $this->query(IEventDispatcher::class); |
| 519 | 519 | $dispatcher->dispatchTyped(new BeforeUserCreatedEvent($uid, $password)); |
| 520 | 520 | }); |
| 521 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
| 521 | + $userSession->listen('\OC\User', 'postCreateUser', function($user, $password) { |
|
| 522 | 522 | /** @var \OC\User\User $user */ |
| 523 | 523 | \OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]); |
| 524 | 524 | |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | $dispatcher = $this->query(IEventDispatcher::class); |
| 527 | 527 | $dispatcher->dispatchTyped(new UserCreatedEvent($user, $password)); |
| 528 | 528 | }); |
| 529 | - $userSession->listen('\OC\User', 'preDelete', function ($user) use ($legacyDispatcher) { |
|
| 529 | + $userSession->listen('\OC\User', 'preDelete', function($user) use ($legacyDispatcher) { |
|
| 530 | 530 | /** @var \OC\User\User $user */ |
| 531 | 531 | \OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]); |
| 532 | 532 | $legacyDispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); |
@@ -535,7 +535,7 @@ discard block |
||
| 535 | 535 | $dispatcher = $this->query(IEventDispatcher::class); |
| 536 | 536 | $dispatcher->dispatchTyped(new BeforeUserDeletedEvent($user)); |
| 537 | 537 | }); |
| 538 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
| 538 | + $userSession->listen('\OC\User', 'postDelete', function($user) { |
|
| 539 | 539 | /** @var \OC\User\User $user */ |
| 540 | 540 | \OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]); |
| 541 | 541 | |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | $dispatcher = $this->query(IEventDispatcher::class); |
| 544 | 544 | $dispatcher->dispatchTyped(new UserDeletedEvent($user)); |
| 545 | 545 | }); |
| 546 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 546 | + $userSession->listen('\OC\User', 'preSetPassword', function($user, $password, $recoveryPassword) { |
|
| 547 | 547 | /** @var \OC\User\User $user */ |
| 548 | 548 | \OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]); |
| 549 | 549 | |
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | $dispatcher = $this->query(IEventDispatcher::class); |
| 552 | 552 | $dispatcher->dispatchTyped(new BeforePasswordUpdatedEvent($user, $password, $recoveryPassword)); |
| 553 | 553 | }); |
| 554 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 554 | + $userSession->listen('\OC\User', 'postSetPassword', function($user, $password, $recoveryPassword) { |
|
| 555 | 555 | /** @var \OC\User\User $user */ |
| 556 | 556 | \OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]); |
| 557 | 557 | |
@@ -559,14 +559,14 @@ discard block |
||
| 559 | 559 | $dispatcher = $this->query(IEventDispatcher::class); |
| 560 | 560 | $dispatcher->dispatchTyped(new PasswordUpdatedEvent($user, $password, $recoveryPassword)); |
| 561 | 561 | }); |
| 562 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
| 562 | + $userSession->listen('\OC\User', 'preLogin', function($uid, $password) { |
|
| 563 | 563 | \OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]); |
| 564 | 564 | |
| 565 | 565 | /** @var IEventDispatcher $dispatcher */ |
| 566 | 566 | $dispatcher = $this->query(IEventDispatcher::class); |
| 567 | 567 | $dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password)); |
| 568 | 568 | }); |
| 569 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password, $isTokenLogin) { |
|
| 569 | + $userSession->listen('\OC\User', 'postLogin', function($user, $password, $isTokenLogin) { |
|
| 570 | 570 | /** @var \OC\User\User $user */ |
| 571 | 571 | \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'isTokenLogin' => $isTokenLogin]); |
| 572 | 572 | |
@@ -574,12 +574,12 @@ discard block |
||
| 574 | 574 | $dispatcher = $this->query(IEventDispatcher::class); |
| 575 | 575 | $dispatcher->dispatchTyped(new UserLoggedInEvent($user, $password, $isTokenLogin)); |
| 576 | 576 | }); |
| 577 | - $userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) { |
|
| 577 | + $userSession->listen('\OC\User', 'preRememberedLogin', function($uid) { |
|
| 578 | 578 | /** @var IEventDispatcher $dispatcher */ |
| 579 | 579 | $dispatcher = $this->query(IEventDispatcher::class); |
| 580 | 580 | $dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid)); |
| 581 | 581 | }); |
| 582 | - $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { |
|
| 582 | + $userSession->listen('\OC\User', 'postRememberedLogin', function($user, $password) { |
|
| 583 | 583 | /** @var \OC\User\User $user */ |
| 584 | 584 | \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]); |
| 585 | 585 | |
@@ -587,19 +587,19 @@ discard block |
||
| 587 | 587 | $dispatcher = $this->query(IEventDispatcher::class); |
| 588 | 588 | $dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password)); |
| 589 | 589 | }); |
| 590 | - $userSession->listen('\OC\User', 'logout', function ($user) { |
|
| 590 | + $userSession->listen('\OC\User', 'logout', function($user) { |
|
| 591 | 591 | \OC_Hook::emit('OC_User', 'logout', []); |
| 592 | 592 | |
| 593 | 593 | /** @var IEventDispatcher $dispatcher */ |
| 594 | 594 | $dispatcher = $this->query(IEventDispatcher::class); |
| 595 | 595 | $dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user)); |
| 596 | 596 | }); |
| 597 | - $userSession->listen('\OC\User', 'postLogout', function ($user) { |
|
| 597 | + $userSession->listen('\OC\User', 'postLogout', function($user) { |
|
| 598 | 598 | /** @var IEventDispatcher $dispatcher */ |
| 599 | 599 | $dispatcher = $this->query(IEventDispatcher::class); |
| 600 | 600 | $dispatcher->dispatchTyped(new UserLoggedOutEvent($user)); |
| 601 | 601 | }); |
| 602 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) { |
|
| 602 | + $userSession->listen('\OC\User', 'changeUser', function($user, $feature, $value, $oldValue) { |
|
| 603 | 603 | /** @var \OC\User\User $user */ |
| 604 | 604 | \OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]); |
| 605 | 605 | |
@@ -623,7 +623,7 @@ discard block |
||
| 623 | 623 | $this->registerDeprecatedAlias('AllConfig', \OC\AllConfig::class); |
| 624 | 624 | $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
| 625 | 625 | |
| 626 | - $this->registerService(\OC\SystemConfig::class, function ($c) use ($config) { |
|
| 626 | + $this->registerService(\OC\SystemConfig::class, function($c) use ($config) { |
|
| 627 | 627 | return new \OC\SystemConfig($config); |
| 628 | 628 | }); |
| 629 | 629 | /** @deprecated 19.0.0 */ |
@@ -633,7 +633,7 @@ discard block |
||
| 633 | 633 | $this->registerDeprecatedAlias('AppConfig', \OC\AppConfig::class); |
| 634 | 634 | $this->registerAlias(IAppConfig::class, \OC\AppConfig::class); |
| 635 | 635 | |
| 636 | - $this->registerService(IFactory::class, function (Server $c) { |
|
| 636 | + $this->registerService(IFactory::class, function(Server $c) { |
|
| 637 | 637 | return new \OC\L10N\Factory( |
| 638 | 638 | $c->getConfig(), |
| 639 | 639 | $c->getRequest(), |
@@ -653,13 +653,13 @@ discard block |
||
| 653 | 653 | /** @deprecated 19.0.0 */ |
| 654 | 654 | $this->registerDeprecatedAlias('CategoryFetcher', CategoryFetcher::class); |
| 655 | 655 | |
| 656 | - $this->registerService(ICache::class, function ($c) { |
|
| 656 | + $this->registerService(ICache::class, function($c) { |
|
| 657 | 657 | return new Cache\File(); |
| 658 | 658 | }); |
| 659 | 659 | /** @deprecated 19.0.0 */ |
| 660 | 660 | $this->registerDeprecatedAlias('UserCache', ICache::class); |
| 661 | 661 | |
| 662 | - $this->registerService(Factory::class, function (Server $c) { |
|
| 662 | + $this->registerService(Factory::class, function(Server $c) { |
|
| 663 | 663 | $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), |
| 664 | 664 | ArrayCache::class, |
| 665 | 665 | ArrayCache::class, |
@@ -673,7 +673,7 @@ discard block |
||
| 673 | 673 | $version = implode(',', $v); |
| 674 | 674 | $instanceId = \OC_Util::getInstanceId(); |
| 675 | 675 | $path = \OC::$SERVERROOT; |
| 676 | - $prefix = md5($instanceId . '-' . $version . '-' . $path); |
|
| 676 | + $prefix = md5($instanceId.'-'.$version.'-'.$path); |
|
| 677 | 677 | return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
| 678 | 678 | $config->getSystemValue('memcache.local', null), |
| 679 | 679 | $config->getSystemValue('memcache.distributed', null), |
@@ -686,12 +686,12 @@ discard block |
||
| 686 | 686 | $this->registerDeprecatedAlias('MemCacheFactory', Factory::class); |
| 687 | 687 | $this->registerAlias(ICacheFactory::class, Factory::class); |
| 688 | 688 | |
| 689 | - $this->registerService('RedisFactory', function (Server $c) { |
|
| 689 | + $this->registerService('RedisFactory', function(Server $c) { |
|
| 690 | 690 | $systemConfig = $c->getSystemConfig(); |
| 691 | 691 | return new RedisFactory($systemConfig); |
| 692 | 692 | }); |
| 693 | 693 | |
| 694 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
| 694 | + $this->registerService(\OCP\Activity\IManager::class, function(Server $c) { |
|
| 695 | 695 | $l10n = $this->get(IFactory::class)->get('activity'); |
| 696 | 696 | return new \OC\Activity\Manager( |
| 697 | 697 | $c->getRequest(), |
@@ -704,14 +704,14 @@ discard block |
||
| 704 | 704 | /** @deprecated 19.0.0 */ |
| 705 | 705 | $this->registerDeprecatedAlias('ActivityManager', \OCP\Activity\IManager::class); |
| 706 | 706 | |
| 707 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
| 707 | + $this->registerService(\OCP\Activity\IEventMerger::class, function(Server $c) { |
|
| 708 | 708 | return new \OC\Activity\EventMerger( |
| 709 | 709 | $c->getL10N('lib') |
| 710 | 710 | ); |
| 711 | 711 | }); |
| 712 | 712 | $this->registerAlias(IValidator::class, Validator::class); |
| 713 | 713 | |
| 714 | - $this->registerService(AvatarManager::class, function (Server $c) { |
|
| 714 | + $this->registerService(AvatarManager::class, function(Server $c) { |
|
| 715 | 715 | return new AvatarManager( |
| 716 | 716 | $c->query(\OC\User\Manager::class), |
| 717 | 717 | $c->getAppDataDir('avatar'), |
@@ -727,7 +727,7 @@ discard block |
||
| 727 | 727 | $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); |
| 728 | 728 | $this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class); |
| 729 | 729 | |
| 730 | - $this->registerService(\OC\Log::class, function (Server $c) { |
|
| 730 | + $this->registerService(\OC\Log::class, function(Server $c) { |
|
| 731 | 731 | $logType = $c->query(AllConfig::class)->getSystemValue('log_type', 'file'); |
| 732 | 732 | $factory = new LogFactory($c, $this->getSystemConfig()); |
| 733 | 733 | $logger = $factory->get($logType); |
@@ -741,7 +741,7 @@ discard block |
||
| 741 | 741 | // PSR-3 logger |
| 742 | 742 | $this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class); |
| 743 | 743 | |
| 744 | - $this->registerService(ILogFactory::class, function (Server $c) { |
|
| 744 | + $this->registerService(ILogFactory::class, function(Server $c) { |
|
| 745 | 745 | return new LogFactory($c, $this->getSystemConfig()); |
| 746 | 746 | }); |
| 747 | 747 | |
@@ -749,7 +749,7 @@ discard block |
||
| 749 | 749 | /** @deprecated 19.0.0 */ |
| 750 | 750 | $this->registerDeprecatedAlias('JobList', IJobList::class); |
| 751 | 751 | |
| 752 | - $this->registerService(IRouter::class, function (Server $c) { |
|
| 752 | + $this->registerService(IRouter::class, function(Server $c) { |
|
| 753 | 753 | $cacheFactory = $c->getMemCacheFactory(); |
| 754 | 754 | $logger = $c->getLogger(); |
| 755 | 755 | if ($cacheFactory->isLocalCacheAvailable()) { |
@@ -766,7 +766,7 @@ discard block |
||
| 766 | 766 | /** @deprecated 19.0.0 */ |
| 767 | 767 | $this->registerDeprecatedAlias('Search', ISearch::class); |
| 768 | 768 | |
| 769 | - $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { |
|
| 769 | + $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function($c) { |
|
| 770 | 770 | return new \OC\Security\RateLimiting\Backend\MemoryCache( |
| 771 | 771 | $this->getMemCacheFactory(), |
| 772 | 772 | new \OC\AppFramework\Utility\TimeFactory() |
@@ -789,7 +789,7 @@ discard block |
||
| 789 | 789 | /** @deprecated 19.0.0 */ |
| 790 | 790 | $this->registerDeprecatedAlias('CredentialsManager', ICredentialsManager::class); |
| 791 | 791 | |
| 792 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
| 792 | + $this->registerService(IDBConnection::class, function(Server $c) { |
|
| 793 | 793 | $systemConfig = $c->getSystemConfig(); |
| 794 | 794 | $factory = new \OC\DB\ConnectionFactory($systemConfig); |
| 795 | 795 | $type = $systemConfig->getValue('dbtype', 'sqlite'); |
@@ -805,7 +805,7 @@ discard block |
||
| 805 | 805 | $this->registerDeprecatedAlias('DatabaseConnection', IDBConnection::class); |
| 806 | 806 | |
| 807 | 807 | |
| 808 | - $this->registerService(IClientService::class, function (Server $c) { |
|
| 808 | + $this->registerService(IClientService::class, function(Server $c) { |
|
| 809 | 809 | $user = \OC_User::getUser(); |
| 810 | 810 | $uid = $user ? $user : null; |
| 811 | 811 | return new ClientService( |
@@ -822,7 +822,7 @@ discard block |
||
| 822 | 822 | }); |
| 823 | 823 | /** @deprecated 19.0.0 */ |
| 824 | 824 | $this->registerDeprecatedAlias('HttpClientService', IClientService::class); |
| 825 | - $this->registerService(IEventLogger::class, function (Server $c) { |
|
| 825 | + $this->registerService(IEventLogger::class, function(Server $c) { |
|
| 826 | 826 | $eventLogger = new EventLogger(); |
| 827 | 827 | if ($c->getSystemConfig()->getValue('debug', false)) { |
| 828 | 828 | // In debug mode, module is being activated by default |
@@ -833,7 +833,7 @@ discard block |
||
| 833 | 833 | /** @deprecated 19.0.0 */ |
| 834 | 834 | $this->registerDeprecatedAlias('EventLogger', IEventLogger::class); |
| 835 | 835 | |
| 836 | - $this->registerService(IQueryLogger::class, function (Server $c) { |
|
| 836 | + $this->registerService(IQueryLogger::class, function(Server $c) { |
|
| 837 | 837 | $queryLogger = new QueryLogger(); |
| 838 | 838 | if ($c->getSystemConfig()->getValue('debug', false)) { |
| 839 | 839 | // In debug mode, module is being activated by default |
@@ -848,7 +848,7 @@ discard block |
||
| 848 | 848 | $this->registerDeprecatedAlias('TempManager', TempManager::class); |
| 849 | 849 | $this->registerAlias(ITempManager::class, TempManager::class); |
| 850 | 850 | |
| 851 | - $this->registerService(AppManager::class, function (Server $c) { |
|
| 851 | + $this->registerService(AppManager::class, function(Server $c) { |
|
| 852 | 852 | return new \OC\App\AppManager( |
| 853 | 853 | $c->getUserSession(), |
| 854 | 854 | $c->getConfig(), |
@@ -867,7 +867,7 @@ discard block |
||
| 867 | 867 | /** @deprecated 19.0.0 */ |
| 868 | 868 | $this->registerDeprecatedAlias('DateTimeZone', IDateTimeZone::class); |
| 869 | 869 | |
| 870 | - $this->registerService(IDateTimeFormatter::class, function (Server $c) { |
|
| 870 | + $this->registerService(IDateTimeFormatter::class, function(Server $c) { |
|
| 871 | 871 | $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
| 872 | 872 | |
| 873 | 873 | return new DateTimeFormatter( |
@@ -878,7 +878,7 @@ discard block |
||
| 878 | 878 | /** @deprecated 19.0.0 */ |
| 879 | 879 | $this->registerDeprecatedAlias('DateTimeFormatter', IDateTimeFormatter::class); |
| 880 | 880 | |
| 881 | - $this->registerService(IUserMountCache::class, function (Server $c) { |
|
| 881 | + $this->registerService(IUserMountCache::class, function(Server $c) { |
|
| 882 | 882 | $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
| 883 | 883 | $listener = new UserMountCacheListener($mountCache); |
| 884 | 884 | $listener->listen($c->getUserManager()); |
@@ -887,7 +887,7 @@ discard block |
||
| 887 | 887 | /** @deprecated 19.0.0 */ |
| 888 | 888 | $this->registerDeprecatedAlias('UserMountCache', IUserMountCache::class); |
| 889 | 889 | |
| 890 | - $this->registerService(IMountProviderCollection::class, function (Server $c) { |
|
| 890 | + $this->registerService(IMountProviderCollection::class, function(Server $c) { |
|
| 891 | 891 | $loader = \OC\Files\Filesystem::getLoader(); |
| 892 | 892 | $mountCache = $c->query(IUserMountCache::class); |
| 893 | 893 | $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
@@ -908,7 +908,7 @@ discard block |
||
| 908 | 908 | |
| 909 | 909 | /** @deprecated 20.0.0 */ |
| 910 | 910 | $this->registerDeprecatedAlias('IniWrapper', IniGetWrapper::class); |
| 911 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
| 911 | + $this->registerService('AsyncCommandBus', function(Server $c) { |
|
| 912 | 912 | $busClass = $c->getConfig()->getSystemValue('commandbus'); |
| 913 | 913 | if ($busClass) { |
| 914 | 914 | [$app, $class] = explode('::', $busClass, 2); |
@@ -928,7 +928,7 @@ discard block |
||
| 928 | 928 | $this->registerDeprecatedAlias('TrustedDomainHelper', TrustedDomainHelper::class); |
| 929 | 929 | /** @deprecated 19.0.0 */ |
| 930 | 930 | $this->registerDeprecatedAlias('Throttler', Throttler::class); |
| 931 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
| 931 | + $this->registerService('IntegrityCodeChecker', function(Server $c) { |
|
| 932 | 932 | // IConfig and IAppManager requires a working database. This code |
| 933 | 933 | // might however be called when ownCloud is not yet setup. |
| 934 | 934 | if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
@@ -950,7 +950,7 @@ discard block |
||
| 950 | 950 | $c->getMimeTypeDetector() |
| 951 | 951 | ); |
| 952 | 952 | }); |
| 953 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
| 953 | + $this->registerService(\OCP\IRequest::class, function($c) { |
|
| 954 | 954 | if (isset($this['urlParams'])) { |
| 955 | 955 | $urlParams = $this['urlParams']; |
| 956 | 956 | } else { |
@@ -987,7 +987,7 @@ discard block |
||
| 987 | 987 | /** @deprecated 19.0.0 */ |
| 988 | 988 | $this->registerDeprecatedAlias('Request', \OCP\IRequest::class); |
| 989 | 989 | |
| 990 | - $this->registerService(IMailer::class, function (Server $c) { |
|
| 990 | + $this->registerService(IMailer::class, function(Server $c) { |
|
| 991 | 991 | return new Mailer( |
| 992 | 992 | $c->getConfig(), |
| 993 | 993 | $c->getLogger(), |
@@ -1001,7 +1001,7 @@ discard block |
||
| 1001 | 1001 | /** @deprecated 19.0.0 */ |
| 1002 | 1002 | $this->registerDeprecatedAlias('Mailer', IMailer::class); |
| 1003 | 1003 | |
| 1004 | - $this->registerService('LDAPProvider', function (Server $c) { |
|
| 1004 | + $this->registerService('LDAPProvider', function(Server $c) { |
|
| 1005 | 1005 | $config = $c->getConfig(); |
| 1006 | 1006 | $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
| 1007 | 1007 | if (is_null($factoryClass)) { |
@@ -1011,7 +1011,7 @@ discard block |
||
| 1011 | 1011 | $factory = new $factoryClass($this); |
| 1012 | 1012 | return $factory->getLDAPProvider(); |
| 1013 | 1013 | }); |
| 1014 | - $this->registerService(ILockingProvider::class, function (Server $c) { |
|
| 1014 | + $this->registerService(ILockingProvider::class, function(Server $c) { |
|
| 1015 | 1015 | $ini = $c->getIniWrapper(); |
| 1016 | 1016 | $config = $c->getConfig(); |
| 1017 | 1017 | $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
@@ -1039,12 +1039,12 @@ discard block |
||
| 1039 | 1039 | /** @deprecated 19.0.0 */ |
| 1040 | 1040 | $this->registerDeprecatedAlias('MountManager', IMountManager::class); |
| 1041 | 1041 | |
| 1042 | - $this->registerService(IMimeTypeDetector::class, function (Server $c) { |
|
| 1042 | + $this->registerService(IMimeTypeDetector::class, function(Server $c) { |
|
| 1043 | 1043 | return new \OC\Files\Type\Detection( |
| 1044 | 1044 | $c->getURLGenerator(), |
| 1045 | 1045 | $c->getLogger(), |
| 1046 | 1046 | \OC::$configDir, |
| 1047 | - \OC::$SERVERROOT . '/resources/config/' |
|
| 1047 | + \OC::$SERVERROOT.'/resources/config/' |
|
| 1048 | 1048 | ); |
| 1049 | 1049 | }); |
| 1050 | 1050 | /** @deprecated 19.0.0 */ |
@@ -1053,19 +1053,19 @@ discard block |
||
| 1053 | 1053 | $this->registerAlias(IMimeTypeLoader::class, Loader::class); |
| 1054 | 1054 | /** @deprecated 19.0.0 */ |
| 1055 | 1055 | $this->registerDeprecatedAlias('MimeTypeLoader', IMimeTypeLoader::class); |
| 1056 | - $this->registerService(BundleFetcher::class, function () { |
|
| 1056 | + $this->registerService(BundleFetcher::class, function() { |
|
| 1057 | 1057 | return new BundleFetcher($this->getL10N('lib')); |
| 1058 | 1058 | }); |
| 1059 | 1059 | $this->registerAlias(\OCP\Notification\IManager::class, Manager::class); |
| 1060 | 1060 | /** @deprecated 19.0.0 */ |
| 1061 | 1061 | $this->registerDeprecatedAlias('NotificationManager', \OCP\Notification\IManager::class); |
| 1062 | 1062 | |
| 1063 | - $this->registerService(CapabilitiesManager::class, function (Server $c) { |
|
| 1063 | + $this->registerService(CapabilitiesManager::class, function(Server $c) { |
|
| 1064 | 1064 | $manager = new CapabilitiesManager($c->getLogger()); |
| 1065 | - $manager->registerCapability(function () use ($c) { |
|
| 1065 | + $manager->registerCapability(function() use ($c) { |
|
| 1066 | 1066 | return new \OC\OCS\CoreCapabilities($c->getConfig()); |
| 1067 | 1067 | }); |
| 1068 | - $manager->registerCapability(function () use ($c) { |
|
| 1068 | + $manager->registerCapability(function() use ($c) { |
|
| 1069 | 1069 | return $c->query(\OC\Security\Bruteforce\Capabilities::class); |
| 1070 | 1070 | }); |
| 1071 | 1071 | return $manager; |
@@ -1073,14 +1073,14 @@ discard block |
||
| 1073 | 1073 | /** @deprecated 19.0.0 */ |
| 1074 | 1074 | $this->registerDeprecatedAlias('CapabilitiesManager', CapabilitiesManager::class); |
| 1075 | 1075 | |
| 1076 | - $this->registerService(ICommentsManager::class, function (Server $c) { |
|
| 1076 | + $this->registerService(ICommentsManager::class, function(Server $c) { |
|
| 1077 | 1077 | $config = $c->getConfig(); |
| 1078 | 1078 | $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class); |
| 1079 | 1079 | /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
| 1080 | 1080 | $factory = new $factoryClass($this); |
| 1081 | 1081 | $manager = $factory->getManager(); |
| 1082 | 1082 | |
| 1083 | - $manager->registerDisplayNameResolver('user', function ($id) use ($c) { |
|
| 1083 | + $manager->registerDisplayNameResolver('user', function($id) use ($c) { |
|
| 1084 | 1084 | $manager = $c->getUserManager(); |
| 1085 | 1085 | $user = $manager->get($id); |
| 1086 | 1086 | if (is_null($user)) { |
@@ -1098,7 +1098,7 @@ discard block |
||
| 1098 | 1098 | $this->registerDeprecatedAlias('CommentsManager', ICommentsManager::class); |
| 1099 | 1099 | |
| 1100 | 1100 | $this->registerAlias(\OC_Defaults::class, 'ThemingDefaults'); |
| 1101 | - $this->registerService('ThemingDefaults', function (Server $c) { |
|
| 1101 | + $this->registerService('ThemingDefaults', function(Server $c) { |
|
| 1102 | 1102 | /* |
| 1103 | 1103 | * Dark magic for autoloader. |
| 1104 | 1104 | * If we do a class_exists it will try to load the class which will |
@@ -1126,7 +1126,7 @@ discard block |
||
| 1126 | 1126 | } |
| 1127 | 1127 | return new \OC_Defaults(); |
| 1128 | 1128 | }); |
| 1129 | - $this->registerService(JSCombiner::class, function (Server $c) { |
|
| 1129 | + $this->registerService(JSCombiner::class, function(Server $c) { |
|
| 1130 | 1130 | return new JSCombiner( |
| 1131 | 1131 | $c->getAppDataDir('js'), |
| 1132 | 1132 | $c->getURLGenerator(), |
@@ -1140,7 +1140,7 @@ discard block |
||
| 1140 | 1140 | $this->registerDeprecatedAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class); |
| 1141 | 1141 | $this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class); |
| 1142 | 1142 | |
| 1143 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
| 1143 | + $this->registerService('CryptoWrapper', function(Server $c) { |
|
| 1144 | 1144 | // FIXME: Instantiiated here due to cyclic dependency |
| 1145 | 1145 | $request = new Request( |
| 1146 | 1146 | [ |
@@ -1167,14 +1167,14 @@ discard block |
||
| 1167 | 1167 | }); |
| 1168 | 1168 | /** @deprecated 19.0.0 */ |
| 1169 | 1169 | $this->registerDeprecatedAlias('CsrfTokenManager', CsrfTokenManager::class); |
| 1170 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
| 1170 | + $this->registerService(SessionStorage::class, function(Server $c) { |
|
| 1171 | 1171 | return new SessionStorage($c->getSession()); |
| 1172 | 1172 | }); |
| 1173 | 1173 | $this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class); |
| 1174 | 1174 | /** @deprecated 19.0.0 */ |
| 1175 | 1175 | $this->registerDeprecatedAlias('ContentSecurityPolicyManager', ContentSecurityPolicyManager::class); |
| 1176 | 1176 | |
| 1177 | - $this->registerService(\OCP\Share\IManager::class, function (Server $c) { |
|
| 1177 | + $this->registerService(\OCP\Share\IManager::class, function(Server $c) { |
|
| 1178 | 1178 | $config = $c->getConfig(); |
| 1179 | 1179 | $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class); |
| 1180 | 1180 | /** @var \OCP\Share\IProviderFactory $factory */ |
@@ -1204,7 +1204,7 @@ discard block |
||
| 1204 | 1204 | /** @deprecated 19.0.0 */ |
| 1205 | 1205 | $this->registerDeprecatedAlias('ShareManager', \OCP\Share\IManager::class); |
| 1206 | 1206 | |
| 1207 | - $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) { |
|
| 1207 | + $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) { |
|
| 1208 | 1208 | $instance = new Collaboration\Collaborators\Search($c); |
| 1209 | 1209 | |
| 1210 | 1210 | // register default plugins |
@@ -1225,7 +1225,7 @@ discard block |
||
| 1225 | 1225 | $this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class); |
| 1226 | 1226 | $this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class); |
| 1227 | 1227 | |
| 1228 | - $this->registerService('SettingsManager', function (Server $c) { |
|
| 1228 | + $this->registerService('SettingsManager', function(Server $c) { |
|
| 1229 | 1229 | $manager = new \OC\Settings\Manager( |
| 1230 | 1230 | $c->getLogger(), |
| 1231 | 1231 | $c->getL10NFactory(), |
@@ -1234,34 +1234,34 @@ discard block |
||
| 1234 | 1234 | ); |
| 1235 | 1235 | return $manager; |
| 1236 | 1236 | }); |
| 1237 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
| 1237 | + $this->registerService(\OC\Files\AppData\Factory::class, function(Server $c) { |
|
| 1238 | 1238 | return new \OC\Files\AppData\Factory( |
| 1239 | 1239 | $c->getRootFolder(), |
| 1240 | 1240 | $c->getSystemConfig() |
| 1241 | 1241 | ); |
| 1242 | 1242 | }); |
| 1243 | 1243 | |
| 1244 | - $this->registerService('LockdownManager', function (Server $c) { |
|
| 1245 | - return new LockdownManager(function () use ($c) { |
|
| 1244 | + $this->registerService('LockdownManager', function(Server $c) { |
|
| 1245 | + return new LockdownManager(function() use ($c) { |
|
| 1246 | 1246 | return $c->getSession(); |
| 1247 | 1247 | }); |
| 1248 | 1248 | }); |
| 1249 | 1249 | |
| 1250 | - $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
| 1250 | + $this->registerService(\OCP\OCS\IDiscoveryService::class, function(Server $c) { |
|
| 1251 | 1251 | return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
| 1252 | 1252 | }); |
| 1253 | 1253 | |
| 1254 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
| 1254 | + $this->registerService(ICloudIdManager::class, function(Server $c) { |
|
| 1255 | 1255 | return new CloudIdManager(); |
| 1256 | 1256 | }); |
| 1257 | 1257 | |
| 1258 | 1258 | $this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class); |
| 1259 | 1259 | |
| 1260 | - $this->registerService(ICloudFederationProviderManager::class, function (Server $c) { |
|
| 1260 | + $this->registerService(ICloudFederationProviderManager::class, function(Server $c) { |
|
| 1261 | 1261 | return new CloudFederationProviderManager($c->getAppManager(), $c->getHTTPClientService(), $c->getCloudIdManager(), $c->getLogger()); |
| 1262 | 1262 | }); |
| 1263 | 1263 | |
| 1264 | - $this->registerService(ICloudFederationFactory::class, function (Server $c) { |
|
| 1264 | + $this->registerService(ICloudFederationFactory::class, function(Server $c) { |
|
| 1265 | 1265 | return new CloudFederationFactory(); |
| 1266 | 1266 | }); |
| 1267 | 1267 | |
@@ -1273,7 +1273,7 @@ discard block |
||
| 1273 | 1273 | /** @deprecated 19.0.0 */ |
| 1274 | 1274 | $this->registerDeprecatedAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
| 1275 | 1275 | |
| 1276 | - $this->registerService(Defaults::class, function (Server $c) { |
|
| 1276 | + $this->registerService(Defaults::class, function(Server $c) { |
|
| 1277 | 1277 | return new Defaults( |
| 1278 | 1278 | $c->getThemingDefaults() |
| 1279 | 1279 | ); |
@@ -1281,17 +1281,17 @@ discard block |
||
| 1281 | 1281 | /** @deprecated 19.0.0 */ |
| 1282 | 1282 | $this->registerDeprecatedAlias('Defaults', \OCP\Defaults::class); |
| 1283 | 1283 | |
| 1284 | - $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { |
|
| 1284 | + $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) { |
|
| 1285 | 1285 | return $c->query(\OCP\IUserSession::class)->getSession(); |
| 1286 | 1286 | }); |
| 1287 | 1287 | |
| 1288 | - $this->registerService(IShareHelper::class, function (Server $c) { |
|
| 1288 | + $this->registerService(IShareHelper::class, function(Server $c) { |
|
| 1289 | 1289 | return new ShareHelper( |
| 1290 | 1290 | $c->query(\OCP\Share\IManager::class) |
| 1291 | 1291 | ); |
| 1292 | 1292 | }); |
| 1293 | 1293 | |
| 1294 | - $this->registerService(Installer::class, function (Server $c) { |
|
| 1294 | + $this->registerService(Installer::class, function(Server $c) { |
|
| 1295 | 1295 | return new Installer( |
| 1296 | 1296 | $c->getAppFetcher(), |
| 1297 | 1297 | $c->getHTTPClientService(), |
@@ -1302,11 +1302,11 @@ discard block |
||
| 1302 | 1302 | ); |
| 1303 | 1303 | }); |
| 1304 | 1304 | |
| 1305 | - $this->registerService(IApiFactory::class, function (Server $c) { |
|
| 1305 | + $this->registerService(IApiFactory::class, function(Server $c) { |
|
| 1306 | 1306 | return new ApiFactory($c->getHTTPClientService()); |
| 1307 | 1307 | }); |
| 1308 | 1308 | |
| 1309 | - $this->registerService(IInstanceFactory::class, function (Server $c) { |
|
| 1309 | + $this->registerService(IInstanceFactory::class, function(Server $c) { |
|
| 1310 | 1310 | $memcacheFactory = $c->getMemCacheFactory(); |
| 1311 | 1311 | return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService()); |
| 1312 | 1312 | }); |
@@ -1363,7 +1363,7 @@ discard block |
||
| 1363 | 1363 | $dispatcher = $this->getEventDispatcher(); |
| 1364 | 1364 | |
| 1365 | 1365 | // Delete avatar on user deletion |
| 1366 | - $dispatcher->addListener('OCP\IUser::preDelete', function (GenericEvent $e) { |
|
| 1366 | + $dispatcher->addListener('OCP\IUser::preDelete', function(GenericEvent $e) { |
|
| 1367 | 1367 | $logger = $this->getLogger(); |
| 1368 | 1368 | $manager = $this->getAvatarManager(); |
| 1369 | 1369 | /** @var IUser $user */ |
@@ -1376,11 +1376,11 @@ discard block |
||
| 1376 | 1376 | // no avatar to remove |
| 1377 | 1377 | } catch (\Exception $e) { |
| 1378 | 1378 | // Ignore exceptions |
| 1379 | - $logger->info('Could not cleanup avatar of ' . $user->getUID()); |
|
| 1379 | + $logger->info('Could not cleanup avatar of '.$user->getUID()); |
|
| 1380 | 1380 | } |
| 1381 | 1381 | }); |
| 1382 | 1382 | |
| 1383 | - $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { |
|
| 1383 | + $dispatcher->addListener('OCP\IUser::changeUser', function(GenericEvent $e) { |
|
| 1384 | 1384 | $manager = $this->getAvatarManager(); |
| 1385 | 1385 | /** @var IUser $user */ |
| 1386 | 1386 | $user = $e->getSubject(); |
@@ -2285,11 +2285,11 @@ discard block |
||
| 2285 | 2285 | } |
| 2286 | 2286 | |
| 2287 | 2287 | private function registerDeprecatedAlias(string $alias, string $target) { |
| 2288 | - $this->registerService($alias, function (ContainerInterface $container) use ($target, $alias) { |
|
| 2288 | + $this->registerService($alias, function(ContainerInterface $container) use ($target, $alias) { |
|
| 2289 | 2289 | try { |
| 2290 | 2290 | /** @var ILogger $logger */ |
| 2291 | 2291 | $logger = $container->get(ILogger::class); |
| 2292 | - $logger->debug('The requested alias "' . $alias . '" is depreacted. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']); |
|
| 2292 | + $logger->debug('The requested alias "'.$alias.'" is depreacted. Please request "'.$target.'" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']); |
|
| 2293 | 2293 | } catch (ContainerExceptionInterface $e) { |
| 2294 | 2294 | // Could not get logger. Continue |
| 2295 | 2295 | } |
@@ -51,224 +51,224 @@ |
||
| 51 | 51 | * Class to generate URLs |
| 52 | 52 | */ |
| 53 | 53 | class URLGenerator implements IURLGenerator { |
| 54 | - /** @var IConfig */ |
|
| 55 | - private $config; |
|
| 56 | - /** @var ICacheFactory */ |
|
| 57 | - private $cacheFactory; |
|
| 58 | - /** @var IRequest */ |
|
| 59 | - private $request; |
|
| 60 | - /** @var IRouter*/ |
|
| 61 | - private $router; |
|
| 54 | + /** @var IConfig */ |
|
| 55 | + private $config; |
|
| 56 | + /** @var ICacheFactory */ |
|
| 57 | + private $cacheFactory; |
|
| 58 | + /** @var IRequest */ |
|
| 59 | + private $request; |
|
| 60 | + /** @var IRouter*/ |
|
| 61 | + private $router; |
|
| 62 | 62 | |
| 63 | - public function __construct(IConfig $config, |
|
| 64 | - ICacheFactory $cacheFactory, |
|
| 65 | - IRequest $request, |
|
| 66 | - IRouter $router) { |
|
| 67 | - $this->config = $config; |
|
| 68 | - $this->cacheFactory = $cacheFactory; |
|
| 69 | - $this->request = $request; |
|
| 70 | - $this->router = $router; |
|
| 71 | - } |
|
| 63 | + public function __construct(IConfig $config, |
|
| 64 | + ICacheFactory $cacheFactory, |
|
| 65 | + IRequest $request, |
|
| 66 | + IRouter $router) { |
|
| 67 | + $this->config = $config; |
|
| 68 | + $this->cacheFactory = $cacheFactory; |
|
| 69 | + $this->request = $request; |
|
| 70 | + $this->router = $router; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Creates an url using a defined route |
|
| 75 | - * |
|
| 76 | - * @param string $routeName |
|
| 77 | - * @param array $arguments args with param=>value, will be appended to the returned url |
|
| 78 | - * @return string the url |
|
| 79 | - * |
|
| 80 | - * Returns a url to the given route. |
|
| 81 | - */ |
|
| 82 | - public function linkToRoute(string $routeName, array $arguments = []): string { |
|
| 83 | - return $this->router->generate($routeName, $arguments); |
|
| 84 | - } |
|
| 73 | + /** |
|
| 74 | + * Creates an url using a defined route |
|
| 75 | + * |
|
| 76 | + * @param string $routeName |
|
| 77 | + * @param array $arguments args with param=>value, will be appended to the returned url |
|
| 78 | + * @return string the url |
|
| 79 | + * |
|
| 80 | + * Returns a url to the given route. |
|
| 81 | + */ |
|
| 82 | + public function linkToRoute(string $routeName, array $arguments = []): string { |
|
| 83 | + return $this->router->generate($routeName, $arguments); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * Creates an absolute url using a defined route |
|
| 88 | - * @param string $routeName |
|
| 89 | - * @param array $arguments args with param=>value, will be appended to the returned url |
|
| 90 | - * @return string the url |
|
| 91 | - * |
|
| 92 | - * Returns an absolute url to the given route. |
|
| 93 | - */ |
|
| 94 | - public function linkToRouteAbsolute(string $routeName, array $arguments = []): string { |
|
| 95 | - return $this->getAbsoluteURL($this->linkToRoute($routeName, $arguments)); |
|
| 96 | - } |
|
| 86 | + /** |
|
| 87 | + * Creates an absolute url using a defined route |
|
| 88 | + * @param string $routeName |
|
| 89 | + * @param array $arguments args with param=>value, will be appended to the returned url |
|
| 90 | + * @return string the url |
|
| 91 | + * |
|
| 92 | + * Returns an absolute url to the given route. |
|
| 93 | + */ |
|
| 94 | + public function linkToRouteAbsolute(string $routeName, array $arguments = []): string { |
|
| 95 | + return $this->getAbsoluteURL($this->linkToRoute($routeName, $arguments)); |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - public function linkToOCSRouteAbsolute(string $routeName, array $arguments = []): string { |
|
| 99 | - $route = $this->router->generate('ocs.'.$routeName, $arguments, false); |
|
| 98 | + public function linkToOCSRouteAbsolute(string $routeName, array $arguments = []): string { |
|
| 99 | + $route = $this->router->generate('ocs.'.$routeName, $arguments, false); |
|
| 100 | 100 | |
| 101 | - $indexPhpPos = strpos($route, '/index.php/'); |
|
| 102 | - if ($indexPhpPos !== false) { |
|
| 103 | - $route = substr($route, $indexPhpPos + 10); |
|
| 104 | - } |
|
| 101 | + $indexPhpPos = strpos($route, '/index.php/'); |
|
| 102 | + if ($indexPhpPos !== false) { |
|
| 103 | + $route = substr($route, $indexPhpPos + 10); |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - $route = substr($route, 7); |
|
| 107 | - $route = '/ocs/v2.php' . $route; |
|
| 106 | + $route = substr($route, 7); |
|
| 107 | + $route = '/ocs/v2.php' . $route; |
|
| 108 | 108 | |
| 109 | - return $this->getAbsoluteURL($route); |
|
| 110 | - } |
|
| 109 | + return $this->getAbsoluteURL($route); |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - /** |
|
| 113 | - * Creates an url |
|
| 114 | - * |
|
| 115 | - * @param string $appName app |
|
| 116 | - * @param string $file file |
|
| 117 | - * @param array $args array with param=>value, will be appended to the returned url |
|
| 118 | - * The value of $args will be urlencoded |
|
| 119 | - * @return string the url |
|
| 120 | - * |
|
| 121 | - * Returns a url to the given app and file. |
|
| 122 | - */ |
|
| 123 | - public function linkTo(string $appName, string $file, array $args = []): string { |
|
| 124 | - $frontControllerActive = ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true'); |
|
| 112 | + /** |
|
| 113 | + * Creates an url |
|
| 114 | + * |
|
| 115 | + * @param string $appName app |
|
| 116 | + * @param string $file file |
|
| 117 | + * @param array $args array with param=>value, will be appended to the returned url |
|
| 118 | + * The value of $args will be urlencoded |
|
| 119 | + * @return string the url |
|
| 120 | + * |
|
| 121 | + * Returns a url to the given app and file. |
|
| 122 | + */ |
|
| 123 | + public function linkTo(string $appName, string $file, array $args = []): string { |
|
| 124 | + $frontControllerActive = ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true'); |
|
| 125 | 125 | |
| 126 | - if ($appName !== '') { |
|
| 127 | - $app_path = \OC_App::getAppPath($appName); |
|
| 128 | - // Check if the app is in the app folder |
|
| 129 | - if ($app_path && file_exists($app_path . '/' . $file)) { |
|
| 130 | - if (substr($file, -3) === 'php') { |
|
| 131 | - $urlLinkTo = \OC::$WEBROOT . '/index.php/apps/' . $appName; |
|
| 132 | - if ($frontControllerActive) { |
|
| 133 | - $urlLinkTo = \OC::$WEBROOT . '/apps/' . $appName; |
|
| 134 | - } |
|
| 135 | - $urlLinkTo .= ($file !== 'index.php') ? '/' . $file : ''; |
|
| 136 | - } else { |
|
| 137 | - $urlLinkTo = \OC_App::getAppWebPath($appName) . '/' . $file; |
|
| 138 | - } |
|
| 139 | - } else { |
|
| 140 | - $urlLinkTo = \OC::$WEBROOT . '/' . $appName . '/' . $file; |
|
| 141 | - } |
|
| 142 | - } else { |
|
| 143 | - if (file_exists(\OC::$SERVERROOT . '/core/' . $file)) { |
|
| 144 | - $urlLinkTo = \OC::$WEBROOT . '/core/' . $file; |
|
| 145 | - } else { |
|
| 146 | - if ($frontControllerActive && $file === 'index.php') { |
|
| 147 | - $urlLinkTo = \OC::$WEBROOT . '/'; |
|
| 148 | - } else { |
|
| 149 | - $urlLinkTo = \OC::$WEBROOT . '/' . $file; |
|
| 150 | - } |
|
| 151 | - } |
|
| 152 | - } |
|
| 126 | + if ($appName !== '') { |
|
| 127 | + $app_path = \OC_App::getAppPath($appName); |
|
| 128 | + // Check if the app is in the app folder |
|
| 129 | + if ($app_path && file_exists($app_path . '/' . $file)) { |
|
| 130 | + if (substr($file, -3) === 'php') { |
|
| 131 | + $urlLinkTo = \OC::$WEBROOT . '/index.php/apps/' . $appName; |
|
| 132 | + if ($frontControllerActive) { |
|
| 133 | + $urlLinkTo = \OC::$WEBROOT . '/apps/' . $appName; |
|
| 134 | + } |
|
| 135 | + $urlLinkTo .= ($file !== 'index.php') ? '/' . $file : ''; |
|
| 136 | + } else { |
|
| 137 | + $urlLinkTo = \OC_App::getAppWebPath($appName) . '/' . $file; |
|
| 138 | + } |
|
| 139 | + } else { |
|
| 140 | + $urlLinkTo = \OC::$WEBROOT . '/' . $appName . '/' . $file; |
|
| 141 | + } |
|
| 142 | + } else { |
|
| 143 | + if (file_exists(\OC::$SERVERROOT . '/core/' . $file)) { |
|
| 144 | + $urlLinkTo = \OC::$WEBROOT . '/core/' . $file; |
|
| 145 | + } else { |
|
| 146 | + if ($frontControllerActive && $file === 'index.php') { |
|
| 147 | + $urlLinkTo = \OC::$WEBROOT . '/'; |
|
| 148 | + } else { |
|
| 149 | + $urlLinkTo = \OC::$WEBROOT . '/' . $file; |
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | 153 | |
| 154 | - if ($args && $query = http_build_query($args, '', '&')) { |
|
| 155 | - $urlLinkTo .= '?' . $query; |
|
| 156 | - } |
|
| 154 | + if ($args && $query = http_build_query($args, '', '&')) { |
|
| 155 | + $urlLinkTo .= '?' . $query; |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - return $urlLinkTo; |
|
| 159 | - } |
|
| 158 | + return $urlLinkTo; |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | - /** |
|
| 162 | - * Creates path to an image |
|
| 163 | - * |
|
| 164 | - * @param string $appName app |
|
| 165 | - * @param string $file image name |
|
| 166 | - * @throws \RuntimeException If the image does not exist |
|
| 167 | - * @return string the url |
|
| 168 | - * |
|
| 169 | - * Returns the path to the image. |
|
| 170 | - */ |
|
| 171 | - public function imagePath(string $appName, string $file): string { |
|
| 172 | - $cache = $this->cacheFactory->createDistributed('imagePath-'.md5($this->getBaseUrl()).'-'); |
|
| 173 | - $cacheKey = $appName.'-'.$file; |
|
| 174 | - if ($key = $cache->get($cacheKey)) { |
|
| 175 | - return $key; |
|
| 176 | - } |
|
| 161 | + /** |
|
| 162 | + * Creates path to an image |
|
| 163 | + * |
|
| 164 | + * @param string $appName app |
|
| 165 | + * @param string $file image name |
|
| 166 | + * @throws \RuntimeException If the image does not exist |
|
| 167 | + * @return string the url |
|
| 168 | + * |
|
| 169 | + * Returns the path to the image. |
|
| 170 | + */ |
|
| 171 | + public function imagePath(string $appName, string $file): string { |
|
| 172 | + $cache = $this->cacheFactory->createDistributed('imagePath-'.md5($this->getBaseUrl()).'-'); |
|
| 173 | + $cacheKey = $appName.'-'.$file; |
|
| 174 | + if ($key = $cache->get($cacheKey)) { |
|
| 175 | + return $key; |
|
| 176 | + } |
|
| 177 | 177 | |
| 178 | - // Read the selected theme from the config file |
|
| 179 | - $theme = \OC_Util::getTheme(); |
|
| 178 | + // Read the selected theme from the config file |
|
| 179 | + $theme = \OC_Util::getTheme(); |
|
| 180 | 180 | |
| 181 | - //if a theme has a png but not an svg always use the png |
|
| 182 | - $basename = substr(basename($file),0,-4); |
|
| 181 | + //if a theme has a png but not an svg always use the png |
|
| 182 | + $basename = substr(basename($file),0,-4); |
|
| 183 | 183 | |
| 184 | - $appPath = \OC_App::getAppPath($appName); |
|
| 184 | + $appPath = \OC_App::getAppPath($appName); |
|
| 185 | 185 | |
| 186 | - // Check if the app is in the app folder |
|
| 187 | - $path = ''; |
|
| 188 | - $themingEnabled = $this->config->getSystemValue('installed', false) && \OCP\App::isEnabled('theming') && \OC_App::isAppLoaded('theming'); |
|
| 189 | - $themingImagePath = false; |
|
| 190 | - if ($themingEnabled) { |
|
| 191 | - $themingDefaults = \OC::$server->getThemingDefaults(); |
|
| 192 | - if ($themingDefaults instanceof ThemingDefaults) { |
|
| 193 | - $themingImagePath = $themingDefaults->replaceImagePath($appName, $file); |
|
| 194 | - } |
|
| 195 | - } |
|
| 186 | + // Check if the app is in the app folder |
|
| 187 | + $path = ''; |
|
| 188 | + $themingEnabled = $this->config->getSystemValue('installed', false) && \OCP\App::isEnabled('theming') && \OC_App::isAppLoaded('theming'); |
|
| 189 | + $themingImagePath = false; |
|
| 190 | + if ($themingEnabled) { |
|
| 191 | + $themingDefaults = \OC::$server->getThemingDefaults(); |
|
| 192 | + if ($themingDefaults instanceof ThemingDefaults) { |
|
| 193 | + $themingImagePath = $themingDefaults->replaceImagePath($appName, $file); |
|
| 194 | + } |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | - if (file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$appName/img/$file")) { |
|
| 198 | - $path = \OC::$WEBROOT . "/themes/$theme/apps/$appName/img/$file"; |
|
| 199 | - } elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$appName/img/$basename.svg") |
|
| 200 | - && file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$appName/img/$basename.png")) { |
|
| 201 | - $path = \OC::$WEBROOT . "/themes/$theme/apps/$appName/img/$basename.png"; |
|
| 202 | - } elseif (!empty($appName) and file_exists(\OC::$SERVERROOT . "/themes/$theme/$appName/img/$file")) { |
|
| 203 | - $path = \OC::$WEBROOT . "/themes/$theme/$appName/img/$file"; |
|
| 204 | - } elseif (!empty($appName) and (!file_exists(\OC::$SERVERROOT . "/themes/$theme/$appName/img/$basename.svg") |
|
| 205 | - && file_exists(\OC::$SERVERROOT . "/themes/$theme/$appName/img/$basename.png"))) { |
|
| 206 | - $path = \OC::$WEBROOT . "/themes/$theme/$appName/img/$basename.png"; |
|
| 207 | - } elseif (file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$file")) { |
|
| 208 | - $path = \OC::$WEBROOT . "/themes/$theme/core/img/$file"; |
|
| 209 | - } elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.svg") |
|
| 210 | - && file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.png")) { |
|
| 211 | - $path = \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png"; |
|
| 212 | - } elseif ($themingEnabled && $themingImagePath) { |
|
| 213 | - $path = $themingImagePath; |
|
| 214 | - } elseif ($appPath && file_exists($appPath . "/img/$file")) { |
|
| 215 | - $path = \OC_App::getAppWebPath($appName) . "/img/$file"; |
|
| 216 | - } elseif ($appPath && !file_exists($appPath . "/img/$basename.svg") |
|
| 217 | - && file_exists($appPath . "/img/$basename.png")) { |
|
| 218 | - $path = \OC_App::getAppWebPath($appName) . "/img/$basename.png"; |
|
| 219 | - } elseif (!empty($appName) and file_exists(\OC::$SERVERROOT . "/$appName/img/$file")) { |
|
| 220 | - $path = \OC::$WEBROOT . "/$appName/img/$file"; |
|
| 221 | - } elseif (!empty($appName) and (!file_exists(\OC::$SERVERROOT . "/$appName/img/$basename.svg") |
|
| 222 | - && file_exists(\OC::$SERVERROOT . "/$appName/img/$basename.png"))) { |
|
| 223 | - $path = \OC::$WEBROOT . "/$appName/img/$basename.png"; |
|
| 224 | - } elseif (file_exists(\OC::$SERVERROOT . "/core/img/$file")) { |
|
| 225 | - $path = \OC::$WEBROOT . "/core/img/$file"; |
|
| 226 | - } elseif (!file_exists(\OC::$SERVERROOT . "/core/img/$basename.svg") |
|
| 227 | - && file_exists(\OC::$SERVERROOT . "/core/img/$basename.png")) { |
|
| 228 | - $path = \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png"; |
|
| 229 | - } |
|
| 197 | + if (file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$appName/img/$file")) { |
|
| 198 | + $path = \OC::$WEBROOT . "/themes/$theme/apps/$appName/img/$file"; |
|
| 199 | + } elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$appName/img/$basename.svg") |
|
| 200 | + && file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$appName/img/$basename.png")) { |
|
| 201 | + $path = \OC::$WEBROOT . "/themes/$theme/apps/$appName/img/$basename.png"; |
|
| 202 | + } elseif (!empty($appName) and file_exists(\OC::$SERVERROOT . "/themes/$theme/$appName/img/$file")) { |
|
| 203 | + $path = \OC::$WEBROOT . "/themes/$theme/$appName/img/$file"; |
|
| 204 | + } elseif (!empty($appName) and (!file_exists(\OC::$SERVERROOT . "/themes/$theme/$appName/img/$basename.svg") |
|
| 205 | + && file_exists(\OC::$SERVERROOT . "/themes/$theme/$appName/img/$basename.png"))) { |
|
| 206 | + $path = \OC::$WEBROOT . "/themes/$theme/$appName/img/$basename.png"; |
|
| 207 | + } elseif (file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$file")) { |
|
| 208 | + $path = \OC::$WEBROOT . "/themes/$theme/core/img/$file"; |
|
| 209 | + } elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.svg") |
|
| 210 | + && file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.png")) { |
|
| 211 | + $path = \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png"; |
|
| 212 | + } elseif ($themingEnabled && $themingImagePath) { |
|
| 213 | + $path = $themingImagePath; |
|
| 214 | + } elseif ($appPath && file_exists($appPath . "/img/$file")) { |
|
| 215 | + $path = \OC_App::getAppWebPath($appName) . "/img/$file"; |
|
| 216 | + } elseif ($appPath && !file_exists($appPath . "/img/$basename.svg") |
|
| 217 | + && file_exists($appPath . "/img/$basename.png")) { |
|
| 218 | + $path = \OC_App::getAppWebPath($appName) . "/img/$basename.png"; |
|
| 219 | + } elseif (!empty($appName) and file_exists(\OC::$SERVERROOT . "/$appName/img/$file")) { |
|
| 220 | + $path = \OC::$WEBROOT . "/$appName/img/$file"; |
|
| 221 | + } elseif (!empty($appName) and (!file_exists(\OC::$SERVERROOT . "/$appName/img/$basename.svg") |
|
| 222 | + && file_exists(\OC::$SERVERROOT . "/$appName/img/$basename.png"))) { |
|
| 223 | + $path = \OC::$WEBROOT . "/$appName/img/$basename.png"; |
|
| 224 | + } elseif (file_exists(\OC::$SERVERROOT . "/core/img/$file")) { |
|
| 225 | + $path = \OC::$WEBROOT . "/core/img/$file"; |
|
| 226 | + } elseif (!file_exists(\OC::$SERVERROOT . "/core/img/$basename.svg") |
|
| 227 | + && file_exists(\OC::$SERVERROOT . "/core/img/$basename.png")) { |
|
| 228 | + $path = \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png"; |
|
| 229 | + } |
|
| 230 | 230 | |
| 231 | - if ($path !== '') { |
|
| 232 | - $cache->set($cacheKey, $path); |
|
| 233 | - return $path; |
|
| 234 | - } |
|
| 231 | + if ($path !== '') { |
|
| 232 | + $cache->set($cacheKey, $path); |
|
| 233 | + return $path; |
|
| 234 | + } |
|
| 235 | 235 | |
| 236 | - throw new RuntimeException('image not found: image:' . $file . ' webroot:' . \OC::$WEBROOT . ' serverroot:' . \OC::$SERVERROOT); |
|
| 237 | - } |
|
| 236 | + throw new RuntimeException('image not found: image:' . $file . ' webroot:' . \OC::$WEBROOT . ' serverroot:' . \OC::$SERVERROOT); |
|
| 237 | + } |
|
| 238 | 238 | |
| 239 | 239 | |
| 240 | - /** |
|
| 241 | - * Makes an URL absolute |
|
| 242 | - * @param string $url the url in the ownCloud host |
|
| 243 | - * @return string the absolute version of the url |
|
| 244 | - */ |
|
| 245 | - public function getAbsoluteURL(string $url): string { |
|
| 246 | - $separator = strpos($url, '/') === 0 ? '' : '/'; |
|
| 240 | + /** |
|
| 241 | + * Makes an URL absolute |
|
| 242 | + * @param string $url the url in the ownCloud host |
|
| 243 | + * @return string the absolute version of the url |
|
| 244 | + */ |
|
| 245 | + public function getAbsoluteURL(string $url): string { |
|
| 246 | + $separator = strpos($url, '/') === 0 ? '' : '/'; |
|
| 247 | 247 | |
| 248 | - if (\OC::$CLI && !\defined('PHPUNIT_RUN')) { |
|
| 249 | - return rtrim($this->config->getSystemValue('overwrite.cli.url'), '/') . '/' . ltrim($url, '/'); |
|
| 250 | - } |
|
| 251 | - // The ownCloud web root can already be prepended. |
|
| 252 | - if (\OC::$WEBROOT !== '' && strpos($url, \OC::$WEBROOT) === 0) { |
|
| 253 | - $url = substr($url, \strlen(\OC::$WEBROOT)); |
|
| 254 | - } |
|
| 248 | + if (\OC::$CLI && !\defined('PHPUNIT_RUN')) { |
|
| 249 | + return rtrim($this->config->getSystemValue('overwrite.cli.url'), '/') . '/' . ltrim($url, '/'); |
|
| 250 | + } |
|
| 251 | + // The ownCloud web root can already be prepended. |
|
| 252 | + if (\OC::$WEBROOT !== '' && strpos($url, \OC::$WEBROOT) === 0) { |
|
| 253 | + $url = substr($url, \strlen(\OC::$WEBROOT)); |
|
| 254 | + } |
|
| 255 | 255 | |
| 256 | - return $this->getBaseUrl() . $separator . $url; |
|
| 257 | - } |
|
| 256 | + return $this->getBaseUrl() . $separator . $url; |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - /** |
|
| 260 | - * @param string $key |
|
| 261 | - * @return string url to the online documentation |
|
| 262 | - */ |
|
| 263 | - public function linkToDocs(string $key): string { |
|
| 264 | - $theme = \OC::$server->getThemingDefaults(); |
|
| 265 | - return $theme->buildDocLinkToKey($key); |
|
| 266 | - } |
|
| 259 | + /** |
|
| 260 | + * @param string $key |
|
| 261 | + * @return string url to the online documentation |
|
| 262 | + */ |
|
| 263 | + public function linkToDocs(string $key): string { |
|
| 264 | + $theme = \OC::$server->getThemingDefaults(); |
|
| 265 | + return $theme->buildDocLinkToKey($key); |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | - /** |
|
| 269 | - * @return string base url of the current request |
|
| 270 | - */ |
|
| 271 | - public function getBaseUrl(): string { |
|
| 272 | - return $this->request->getServerProtocol() . '://' . $this->request->getServerHost() . \OC::$WEBROOT; |
|
| 273 | - } |
|
| 268 | + /** |
|
| 269 | + * @return string base url of the current request |
|
| 270 | + */ |
|
| 271 | + public function getBaseUrl(): string { |
|
| 272 | + return $this->request->getServerProtocol() . '://' . $this->request->getServerHost() . \OC::$WEBROOT; |
|
| 273 | + } |
|
| 274 | 274 | } |
@@ -45,403 +45,403 @@ |
||
| 45 | 45 | use Symfony\Component\Routing\RouteCollection; |
| 46 | 46 | |
| 47 | 47 | class Router implements IRouter { |
| 48 | - /** @var RouteCollection[] */ |
|
| 49 | - protected $collections = []; |
|
| 50 | - /** @var null|RouteCollection */ |
|
| 51 | - protected $collection = null; |
|
| 52 | - /** @var null|string */ |
|
| 53 | - protected $collectionName = null; |
|
| 54 | - /** @var null|RouteCollection */ |
|
| 55 | - protected $root = null; |
|
| 56 | - /** @var null|UrlGenerator */ |
|
| 57 | - protected $generator = null; |
|
| 58 | - /** @var string[] */ |
|
| 59 | - protected $routingFiles; |
|
| 60 | - /** @var bool */ |
|
| 61 | - protected $loaded = false; |
|
| 62 | - /** @var array */ |
|
| 63 | - protected $loadedApps = []; |
|
| 64 | - /** @var ILogger */ |
|
| 65 | - protected $logger; |
|
| 66 | - /** @var RequestContext */ |
|
| 67 | - protected $context; |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * @param ILogger $logger |
|
| 71 | - */ |
|
| 72 | - public function __construct(ILogger $logger) { |
|
| 73 | - $this->logger = $logger; |
|
| 74 | - $baseUrl = \OC::$WEBROOT; |
|
| 75 | - if (!(\OC::$server->getConfig()->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) { |
|
| 76 | - $baseUrl .= '/index.php'; |
|
| 77 | - } |
|
| 78 | - if (!\OC::$CLI && isset($_SERVER['REQUEST_METHOD'])) { |
|
| 79 | - $method = $_SERVER['REQUEST_METHOD']; |
|
| 80 | - } else { |
|
| 81 | - $method = 'GET'; |
|
| 82 | - } |
|
| 83 | - $request = \OC::$server->getRequest(); |
|
| 84 | - $host = $request->getServerHost(); |
|
| 85 | - $schema = $request->getServerProtocol(); |
|
| 86 | - $this->context = new RequestContext($baseUrl, $method, $host, $schema); |
|
| 87 | - // TODO cache |
|
| 88 | - $this->root = $this->getCollection('root'); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * Get the files to load the routes from |
|
| 93 | - * |
|
| 94 | - * @return string[] |
|
| 95 | - */ |
|
| 96 | - public function getRoutingFiles() { |
|
| 97 | - if (!isset($this->routingFiles)) { |
|
| 98 | - $this->routingFiles = []; |
|
| 99 | - foreach (\OC_APP::getEnabledApps() as $app) { |
|
| 100 | - $appPath = \OC_App::getAppPath($app); |
|
| 101 | - if ($appPath !== false) { |
|
| 102 | - $file = $appPath . '/appinfo/routes.php'; |
|
| 103 | - if (file_exists($file)) { |
|
| 104 | - $this->routingFiles[$app] = $file; |
|
| 105 | - } |
|
| 106 | - } |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - return $this->routingFiles; |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * Loads the routes |
|
| 114 | - * |
|
| 115 | - * @param null|string $app |
|
| 116 | - */ |
|
| 117 | - public function loadRoutes($app = null) { |
|
| 118 | - if (is_string($app)) { |
|
| 119 | - $app = \OC_App::cleanAppId($app); |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - $requestedApp = $app; |
|
| 123 | - if ($this->loaded) { |
|
| 124 | - return; |
|
| 125 | - } |
|
| 126 | - if (is_null($app)) { |
|
| 127 | - $this->loaded = true; |
|
| 128 | - $routingFiles = $this->getRoutingFiles(); |
|
| 129 | - } else { |
|
| 130 | - if (isset($this->loadedApps[$app])) { |
|
| 131 | - return; |
|
| 132 | - } |
|
| 133 | - $file = \OC_App::getAppPath($app) . '/appinfo/routes.php'; |
|
| 134 | - if ($file !== false && file_exists($file)) { |
|
| 135 | - $routingFiles = [$app => $file]; |
|
| 136 | - } else { |
|
| 137 | - $routingFiles = []; |
|
| 138 | - } |
|
| 139 | - } |
|
| 140 | - \OC::$server->getEventLogger()->start('loadroutes' . $requestedApp, 'Loading Routes'); |
|
| 141 | - foreach ($routingFiles as $app => $file) { |
|
| 142 | - if (!isset($this->loadedApps[$app])) { |
|
| 143 | - if (!\OC_App::isAppLoaded($app)) { |
|
| 144 | - // app MUST be loaded before app routes |
|
| 145 | - // try again next time loadRoutes() is called |
|
| 146 | - $this->loaded = false; |
|
| 147 | - continue; |
|
| 148 | - } |
|
| 149 | - $this->loadedApps[$app] = true; |
|
| 150 | - $this->useCollection($app); |
|
| 151 | - $this->requireRouteFile($file, $app); |
|
| 152 | - $collection = $this->getCollection($app); |
|
| 153 | - $this->root->addCollection($collection); |
|
| 154 | - |
|
| 155 | - // Also add the OCS collection |
|
| 156 | - $collection = $this->getCollection($app.'.ocs'); |
|
| 157 | - $collection->addPrefix('/ocsapp'); |
|
| 158 | - $this->root->addCollection($collection); |
|
| 159 | - } |
|
| 160 | - } |
|
| 161 | - if (!isset($this->loadedApps['core'])) { |
|
| 162 | - $this->loadedApps['core'] = true; |
|
| 163 | - $this->useCollection('root'); |
|
| 164 | - require_once __DIR__ . '/../../../core/routes.php'; |
|
| 165 | - |
|
| 166 | - // Also add the OCS collection |
|
| 167 | - $collection = $this->getCollection('root.ocs'); |
|
| 168 | - $collection->addPrefix('/ocsapp'); |
|
| 169 | - $this->root->addCollection($collection); |
|
| 170 | - } |
|
| 171 | - if ($this->loaded) { |
|
| 172 | - $collection = $this->getCollection('ocs'); |
|
| 173 | - $collection->addPrefix('/ocs'); |
|
| 174 | - $this->root->addCollection($collection); |
|
| 175 | - } |
|
| 176 | - \OC::$server->getEventLogger()->end('loadroutes' . $requestedApp); |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - /** |
|
| 180 | - * @return string |
|
| 181 | - * @deprecated |
|
| 182 | - */ |
|
| 183 | - public function getCacheKey() { |
|
| 184 | - return ''; |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - /** |
|
| 188 | - * @param string $name |
|
| 189 | - * @return \Symfony\Component\Routing\RouteCollection |
|
| 190 | - */ |
|
| 191 | - protected function getCollection($name) { |
|
| 192 | - if (!isset($this->collections[$name])) { |
|
| 193 | - $this->collections[$name] = new RouteCollection(); |
|
| 194 | - } |
|
| 195 | - return $this->collections[$name]; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - /** |
|
| 199 | - * Sets the collection to use for adding routes |
|
| 200 | - * |
|
| 201 | - * @param string $name Name of the collection to use. |
|
| 202 | - * @return void |
|
| 203 | - */ |
|
| 204 | - public function useCollection($name) { |
|
| 205 | - $this->collection = $this->getCollection($name); |
|
| 206 | - $this->collectionName = $name; |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - /** |
|
| 210 | - * returns the current collection name in use for adding routes |
|
| 211 | - * |
|
| 212 | - * @return string the collection name |
|
| 213 | - */ |
|
| 214 | - public function getCurrentCollection() { |
|
| 215 | - return $this->collectionName; |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - |
|
| 219 | - /** |
|
| 220 | - * Create a \OC\Route\Route. |
|
| 221 | - * |
|
| 222 | - * @param string $name Name of the route to create. |
|
| 223 | - * @param string $pattern The pattern to match |
|
| 224 | - * @param array $defaults An array of default parameter values |
|
| 225 | - * @param array $requirements An array of requirements for parameters (regexes) |
|
| 226 | - * @return \OC\Route\Route |
|
| 227 | - */ |
|
| 228 | - public function create($name, |
|
| 229 | - $pattern, |
|
| 230 | - array $defaults = [], |
|
| 231 | - array $requirements = []) { |
|
| 232 | - $route = new Route($pattern, $defaults, $requirements); |
|
| 233 | - $this->collection->add($name, $route); |
|
| 234 | - return $route; |
|
| 235 | - } |
|
| 236 | - |
|
| 237 | - /** |
|
| 238 | - * Find the route matching $url |
|
| 239 | - * |
|
| 240 | - * @param string $url The url to find |
|
| 241 | - * @throws \Exception |
|
| 242 | - * @return array |
|
| 243 | - */ |
|
| 244 | - public function findMatchingRoute(string $url): array { |
|
| 245 | - if (substr($url, 0, 6) === '/apps/') { |
|
| 246 | - // empty string / 'apps' / $app / rest of the route |
|
| 247 | - list(, , $app,) = explode('/', $url, 4); |
|
| 248 | - |
|
| 249 | - $app = \OC_App::cleanAppId($app); |
|
| 250 | - \OC::$REQUESTEDAPP = $app; |
|
| 251 | - $this->loadRoutes($app); |
|
| 252 | - } elseif (substr($url, 0, 13) === '/ocsapp/apps/') { |
|
| 253 | - // empty string / 'ocsapp' / 'apps' / $app / rest of the route |
|
| 254 | - list(, , , $app,) = explode('/', $url, 5); |
|
| 255 | - |
|
| 256 | - $app = \OC_App::cleanAppId($app); |
|
| 257 | - \OC::$REQUESTEDAPP = $app; |
|
| 258 | - $this->loadRoutes($app); |
|
| 259 | - } elseif (substr($url, 0, 10) === '/settings/') { |
|
| 260 | - $this->loadRoutes('settings'); |
|
| 261 | - } elseif (substr($url, 0, 6) === '/core/') { |
|
| 262 | - \OC::$REQUESTEDAPP = $url; |
|
| 263 | - if (!\OC::$server->getConfig()->getSystemValueBool('maintenance') && !Util::needUpgrade()) { |
|
| 264 | - \OC_App::loadApps(); |
|
| 265 | - } |
|
| 266 | - $this->loadRoutes('core'); |
|
| 267 | - } else { |
|
| 268 | - $this->loadRoutes(); |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - $matcher = new UrlMatcher($this->root, $this->context); |
|
| 272 | - try { |
|
| 273 | - $parameters = $matcher->match($url); |
|
| 274 | - } catch (ResourceNotFoundException $e) { |
|
| 275 | - if (substr($url, -1) !== '/') { |
|
| 276 | - // We allow links to apps/files? for backwards compatibility reasons |
|
| 277 | - // However, since Symfony does not allow empty route names, the route |
|
| 278 | - // we need to match is '/', so we need to append the '/' here. |
|
| 279 | - try { |
|
| 280 | - $parameters = $matcher->match($url . '/'); |
|
| 281 | - } catch (ResourceNotFoundException $newException) { |
|
| 282 | - // If we still didn't match a route, we throw the original exception |
|
| 283 | - throw $e; |
|
| 284 | - } |
|
| 285 | - } else { |
|
| 286 | - throw $e; |
|
| 287 | - } |
|
| 288 | - } |
|
| 289 | - |
|
| 290 | - return $parameters; |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - /** |
|
| 294 | - * Find and execute the route matching $url |
|
| 295 | - * |
|
| 296 | - * @param string $url The url to find |
|
| 297 | - * @throws \Exception |
|
| 298 | - * @return void |
|
| 299 | - */ |
|
| 300 | - public function match($url) { |
|
| 301 | - $parameters = $this->findMatchingRoute($url); |
|
| 302 | - |
|
| 303 | - \OC::$server->getEventLogger()->start('run_route', 'Run route'); |
|
| 304 | - if (isset($parameters['caller'])) { |
|
| 305 | - $caller = $parameters['caller']; |
|
| 306 | - unset($parameters['caller']); |
|
| 307 | - $application = $this->getApplicationClass($caller[0]); |
|
| 308 | - \OC\AppFramework\App::main($caller[1], $caller[2], $application->getContainer(), $parameters); |
|
| 309 | - } elseif (isset($parameters['action'])) { |
|
| 310 | - $action = $parameters['action']; |
|
| 311 | - if (!is_callable($action)) { |
|
| 312 | - throw new \Exception('not a callable action'); |
|
| 313 | - } |
|
| 314 | - unset($parameters['action']); |
|
| 315 | - call_user_func($action, $parameters); |
|
| 316 | - } elseif (isset($parameters['file'])) { |
|
| 317 | - include $parameters['file']; |
|
| 318 | - } else { |
|
| 319 | - throw new \Exception('no action available'); |
|
| 320 | - } |
|
| 321 | - \OC::$server->getEventLogger()->end('run_route'); |
|
| 322 | - } |
|
| 323 | - |
|
| 324 | - /** |
|
| 325 | - * Get the url generator |
|
| 326 | - * |
|
| 327 | - * @return \Symfony\Component\Routing\Generator\UrlGenerator |
|
| 328 | - * |
|
| 329 | - */ |
|
| 330 | - public function getGenerator() { |
|
| 331 | - if (null !== $this->generator) { |
|
| 332 | - return $this->generator; |
|
| 333 | - } |
|
| 334 | - |
|
| 335 | - return $this->generator = new UrlGenerator($this->root, $this->context); |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - /** |
|
| 339 | - * Generate url based on $name and $parameters |
|
| 340 | - * |
|
| 341 | - * @param string $name Name of the route to use. |
|
| 342 | - * @param array $parameters Parameters for the route |
|
| 343 | - * @param bool $absolute |
|
| 344 | - * @return string |
|
| 345 | - */ |
|
| 346 | - public function generate($name, |
|
| 347 | - $parameters = [], |
|
| 348 | - $absolute = false) { |
|
| 349 | - $referenceType = UrlGenerator::ABSOLUTE_URL; |
|
| 350 | - if ($absolute === false) { |
|
| 351 | - $referenceType = UrlGenerator::ABSOLUTE_PATH; |
|
| 352 | - } |
|
| 353 | - $name = $this->fixLegacyRootName($name); |
|
| 354 | - if (strpos($name, '.') !== false) { |
|
| 355 | - list($appName, $other) = explode('.', $name, 3); |
|
| 356 | - // OCS routes are prefixed with "ocs." |
|
| 357 | - if ($appName === 'ocs') { |
|
| 358 | - $appName = $other; |
|
| 359 | - } |
|
| 360 | - $this->loadRoutes($appName); |
|
| 361 | - try { |
|
| 362 | - return $this->getGenerator()->generate($name, $parameters, $referenceType); |
|
| 363 | - } catch (RouteNotFoundException $e) { |
|
| 364 | - } |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - // Fallback load all routes |
|
| 368 | - $this->loadRoutes(); |
|
| 369 | - try { |
|
| 370 | - return $this->getGenerator()->generate($name, $parameters, $referenceType); |
|
| 371 | - } catch (RouteNotFoundException $e) { |
|
| 372 | - $this->logger->logException($e, ['level' => ILogger::INFO]); |
|
| 373 | - return ''; |
|
| 374 | - } |
|
| 375 | - } |
|
| 376 | - |
|
| 377 | - protected function fixLegacyRootName(string $routeName): string { |
|
| 378 | - if ($routeName === 'files.viewcontroller.showFile') { |
|
| 379 | - return 'files.View.showFile'; |
|
| 380 | - } |
|
| 381 | - if ($routeName === 'files_sharing.sharecontroller.showShare') { |
|
| 382 | - return 'files_sharing.Share.showShare'; |
|
| 383 | - } |
|
| 384 | - if ($routeName === 'files_sharing.sharecontroller.showAuthenticate') { |
|
| 385 | - return 'files_sharing.Share.showAuthenticate'; |
|
| 386 | - } |
|
| 387 | - if ($routeName === 'files_sharing.sharecontroller.authenticate') { |
|
| 388 | - return 'files_sharing.Share.authenticate'; |
|
| 389 | - } |
|
| 390 | - if ($routeName === 'files_sharing.sharecontroller.downloadShare') { |
|
| 391 | - return 'files_sharing.Share.downloadShare'; |
|
| 392 | - } |
|
| 393 | - if ($routeName === 'files_sharing.publicpreview.directLink') { |
|
| 394 | - return 'files_sharing.PublicPreview.directLink'; |
|
| 395 | - } |
|
| 396 | - if ($routeName === 'cloud_federation_api.requesthandlercontroller.addShare') { |
|
| 397 | - return 'cloud_federation_api.RequestHandler.addShare'; |
|
| 398 | - } |
|
| 399 | - if ($routeName === 'cloud_federation_api.requesthandlercontroller.receiveNotification') { |
|
| 400 | - return 'cloud_federation_api.RequestHandler.receiveNotification'; |
|
| 401 | - } |
|
| 402 | - return $routeName; |
|
| 403 | - } |
|
| 404 | - |
|
| 405 | - /** |
|
| 406 | - * To isolate the variable scope used inside the $file it is required in it's own method |
|
| 407 | - * |
|
| 408 | - * @param string $file the route file location to include |
|
| 409 | - * @param string $appName |
|
| 410 | - */ |
|
| 411 | - private function requireRouteFile($file, $appName) { |
|
| 412 | - $this->setupRoutes(include_once $file, $appName); |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - |
|
| 416 | - /** |
|
| 417 | - * If a routes.php file returns an array, try to set up the application and |
|
| 418 | - * register the routes for the app. The application class will be chosen by |
|
| 419 | - * camelcasing the appname, e.g.: my_app will be turned into |
|
| 420 | - * \OCA\MyApp\AppInfo\Application. If that class does not exist, a default |
|
| 421 | - * App will be intialized. This makes it optional to ship an |
|
| 422 | - * appinfo/application.php by using the built in query resolver |
|
| 423 | - * |
|
| 424 | - * @param array $routes the application routes |
|
| 425 | - * @param string $appName the name of the app. |
|
| 426 | - */ |
|
| 427 | - private function setupRoutes($routes, $appName) { |
|
| 428 | - if (is_array($routes)) { |
|
| 429 | - $application = $this->getApplicationClass($appName); |
|
| 430 | - $application->registerRoutes($this, $routes); |
|
| 431 | - } |
|
| 432 | - } |
|
| 433 | - |
|
| 434 | - private function getApplicationClass(string $appName) { |
|
| 435 | - $appNameSpace = App::buildAppNamespace($appName); |
|
| 436 | - |
|
| 437 | - $applicationClassName = $appNameSpace . '\\AppInfo\\Application'; |
|
| 438 | - |
|
| 439 | - if (class_exists($applicationClassName)) { |
|
| 440 | - $application = \OC::$server->query($applicationClassName); |
|
| 441 | - } else { |
|
| 442 | - $application = new App($appName); |
|
| 443 | - } |
|
| 444 | - |
|
| 445 | - return $application; |
|
| 446 | - } |
|
| 48 | + /** @var RouteCollection[] */ |
|
| 49 | + protected $collections = []; |
|
| 50 | + /** @var null|RouteCollection */ |
|
| 51 | + protected $collection = null; |
|
| 52 | + /** @var null|string */ |
|
| 53 | + protected $collectionName = null; |
|
| 54 | + /** @var null|RouteCollection */ |
|
| 55 | + protected $root = null; |
|
| 56 | + /** @var null|UrlGenerator */ |
|
| 57 | + protected $generator = null; |
|
| 58 | + /** @var string[] */ |
|
| 59 | + protected $routingFiles; |
|
| 60 | + /** @var bool */ |
|
| 61 | + protected $loaded = false; |
|
| 62 | + /** @var array */ |
|
| 63 | + protected $loadedApps = []; |
|
| 64 | + /** @var ILogger */ |
|
| 65 | + protected $logger; |
|
| 66 | + /** @var RequestContext */ |
|
| 67 | + protected $context; |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * @param ILogger $logger |
|
| 71 | + */ |
|
| 72 | + public function __construct(ILogger $logger) { |
|
| 73 | + $this->logger = $logger; |
|
| 74 | + $baseUrl = \OC::$WEBROOT; |
|
| 75 | + if (!(\OC::$server->getConfig()->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) { |
|
| 76 | + $baseUrl .= '/index.php'; |
|
| 77 | + } |
|
| 78 | + if (!\OC::$CLI && isset($_SERVER['REQUEST_METHOD'])) { |
|
| 79 | + $method = $_SERVER['REQUEST_METHOD']; |
|
| 80 | + } else { |
|
| 81 | + $method = 'GET'; |
|
| 82 | + } |
|
| 83 | + $request = \OC::$server->getRequest(); |
|
| 84 | + $host = $request->getServerHost(); |
|
| 85 | + $schema = $request->getServerProtocol(); |
|
| 86 | + $this->context = new RequestContext($baseUrl, $method, $host, $schema); |
|
| 87 | + // TODO cache |
|
| 88 | + $this->root = $this->getCollection('root'); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * Get the files to load the routes from |
|
| 93 | + * |
|
| 94 | + * @return string[] |
|
| 95 | + */ |
|
| 96 | + public function getRoutingFiles() { |
|
| 97 | + if (!isset($this->routingFiles)) { |
|
| 98 | + $this->routingFiles = []; |
|
| 99 | + foreach (\OC_APP::getEnabledApps() as $app) { |
|
| 100 | + $appPath = \OC_App::getAppPath($app); |
|
| 101 | + if ($appPath !== false) { |
|
| 102 | + $file = $appPath . '/appinfo/routes.php'; |
|
| 103 | + if (file_exists($file)) { |
|
| 104 | + $this->routingFiles[$app] = $file; |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + return $this->routingFiles; |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * Loads the routes |
|
| 114 | + * |
|
| 115 | + * @param null|string $app |
|
| 116 | + */ |
|
| 117 | + public function loadRoutes($app = null) { |
|
| 118 | + if (is_string($app)) { |
|
| 119 | + $app = \OC_App::cleanAppId($app); |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + $requestedApp = $app; |
|
| 123 | + if ($this->loaded) { |
|
| 124 | + return; |
|
| 125 | + } |
|
| 126 | + if (is_null($app)) { |
|
| 127 | + $this->loaded = true; |
|
| 128 | + $routingFiles = $this->getRoutingFiles(); |
|
| 129 | + } else { |
|
| 130 | + if (isset($this->loadedApps[$app])) { |
|
| 131 | + return; |
|
| 132 | + } |
|
| 133 | + $file = \OC_App::getAppPath($app) . '/appinfo/routes.php'; |
|
| 134 | + if ($file !== false && file_exists($file)) { |
|
| 135 | + $routingFiles = [$app => $file]; |
|
| 136 | + } else { |
|
| 137 | + $routingFiles = []; |
|
| 138 | + } |
|
| 139 | + } |
|
| 140 | + \OC::$server->getEventLogger()->start('loadroutes' . $requestedApp, 'Loading Routes'); |
|
| 141 | + foreach ($routingFiles as $app => $file) { |
|
| 142 | + if (!isset($this->loadedApps[$app])) { |
|
| 143 | + if (!\OC_App::isAppLoaded($app)) { |
|
| 144 | + // app MUST be loaded before app routes |
|
| 145 | + // try again next time loadRoutes() is called |
|
| 146 | + $this->loaded = false; |
|
| 147 | + continue; |
|
| 148 | + } |
|
| 149 | + $this->loadedApps[$app] = true; |
|
| 150 | + $this->useCollection($app); |
|
| 151 | + $this->requireRouteFile($file, $app); |
|
| 152 | + $collection = $this->getCollection($app); |
|
| 153 | + $this->root->addCollection($collection); |
|
| 154 | + |
|
| 155 | + // Also add the OCS collection |
|
| 156 | + $collection = $this->getCollection($app.'.ocs'); |
|
| 157 | + $collection->addPrefix('/ocsapp'); |
|
| 158 | + $this->root->addCollection($collection); |
|
| 159 | + } |
|
| 160 | + } |
|
| 161 | + if (!isset($this->loadedApps['core'])) { |
|
| 162 | + $this->loadedApps['core'] = true; |
|
| 163 | + $this->useCollection('root'); |
|
| 164 | + require_once __DIR__ . '/../../../core/routes.php'; |
|
| 165 | + |
|
| 166 | + // Also add the OCS collection |
|
| 167 | + $collection = $this->getCollection('root.ocs'); |
|
| 168 | + $collection->addPrefix('/ocsapp'); |
|
| 169 | + $this->root->addCollection($collection); |
|
| 170 | + } |
|
| 171 | + if ($this->loaded) { |
|
| 172 | + $collection = $this->getCollection('ocs'); |
|
| 173 | + $collection->addPrefix('/ocs'); |
|
| 174 | + $this->root->addCollection($collection); |
|
| 175 | + } |
|
| 176 | + \OC::$server->getEventLogger()->end('loadroutes' . $requestedApp); |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + /** |
|
| 180 | + * @return string |
|
| 181 | + * @deprecated |
|
| 182 | + */ |
|
| 183 | + public function getCacheKey() { |
|
| 184 | + return ''; |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + /** |
|
| 188 | + * @param string $name |
|
| 189 | + * @return \Symfony\Component\Routing\RouteCollection |
|
| 190 | + */ |
|
| 191 | + protected function getCollection($name) { |
|
| 192 | + if (!isset($this->collections[$name])) { |
|
| 193 | + $this->collections[$name] = new RouteCollection(); |
|
| 194 | + } |
|
| 195 | + return $this->collections[$name]; |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + /** |
|
| 199 | + * Sets the collection to use for adding routes |
|
| 200 | + * |
|
| 201 | + * @param string $name Name of the collection to use. |
|
| 202 | + * @return void |
|
| 203 | + */ |
|
| 204 | + public function useCollection($name) { |
|
| 205 | + $this->collection = $this->getCollection($name); |
|
| 206 | + $this->collectionName = $name; |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + /** |
|
| 210 | + * returns the current collection name in use for adding routes |
|
| 211 | + * |
|
| 212 | + * @return string the collection name |
|
| 213 | + */ |
|
| 214 | + public function getCurrentCollection() { |
|
| 215 | + return $this->collectionName; |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + |
|
| 219 | + /** |
|
| 220 | + * Create a \OC\Route\Route. |
|
| 221 | + * |
|
| 222 | + * @param string $name Name of the route to create. |
|
| 223 | + * @param string $pattern The pattern to match |
|
| 224 | + * @param array $defaults An array of default parameter values |
|
| 225 | + * @param array $requirements An array of requirements for parameters (regexes) |
|
| 226 | + * @return \OC\Route\Route |
|
| 227 | + */ |
|
| 228 | + public function create($name, |
|
| 229 | + $pattern, |
|
| 230 | + array $defaults = [], |
|
| 231 | + array $requirements = []) { |
|
| 232 | + $route = new Route($pattern, $defaults, $requirements); |
|
| 233 | + $this->collection->add($name, $route); |
|
| 234 | + return $route; |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + /** |
|
| 238 | + * Find the route matching $url |
|
| 239 | + * |
|
| 240 | + * @param string $url The url to find |
|
| 241 | + * @throws \Exception |
|
| 242 | + * @return array |
|
| 243 | + */ |
|
| 244 | + public function findMatchingRoute(string $url): array { |
|
| 245 | + if (substr($url, 0, 6) === '/apps/') { |
|
| 246 | + // empty string / 'apps' / $app / rest of the route |
|
| 247 | + list(, , $app,) = explode('/', $url, 4); |
|
| 248 | + |
|
| 249 | + $app = \OC_App::cleanAppId($app); |
|
| 250 | + \OC::$REQUESTEDAPP = $app; |
|
| 251 | + $this->loadRoutes($app); |
|
| 252 | + } elseif (substr($url, 0, 13) === '/ocsapp/apps/') { |
|
| 253 | + // empty string / 'ocsapp' / 'apps' / $app / rest of the route |
|
| 254 | + list(, , , $app,) = explode('/', $url, 5); |
|
| 255 | + |
|
| 256 | + $app = \OC_App::cleanAppId($app); |
|
| 257 | + \OC::$REQUESTEDAPP = $app; |
|
| 258 | + $this->loadRoutes($app); |
|
| 259 | + } elseif (substr($url, 0, 10) === '/settings/') { |
|
| 260 | + $this->loadRoutes('settings'); |
|
| 261 | + } elseif (substr($url, 0, 6) === '/core/') { |
|
| 262 | + \OC::$REQUESTEDAPP = $url; |
|
| 263 | + if (!\OC::$server->getConfig()->getSystemValueBool('maintenance') && !Util::needUpgrade()) { |
|
| 264 | + \OC_App::loadApps(); |
|
| 265 | + } |
|
| 266 | + $this->loadRoutes('core'); |
|
| 267 | + } else { |
|
| 268 | + $this->loadRoutes(); |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + $matcher = new UrlMatcher($this->root, $this->context); |
|
| 272 | + try { |
|
| 273 | + $parameters = $matcher->match($url); |
|
| 274 | + } catch (ResourceNotFoundException $e) { |
|
| 275 | + if (substr($url, -1) !== '/') { |
|
| 276 | + // We allow links to apps/files? for backwards compatibility reasons |
|
| 277 | + // However, since Symfony does not allow empty route names, the route |
|
| 278 | + // we need to match is '/', so we need to append the '/' here. |
|
| 279 | + try { |
|
| 280 | + $parameters = $matcher->match($url . '/'); |
|
| 281 | + } catch (ResourceNotFoundException $newException) { |
|
| 282 | + // If we still didn't match a route, we throw the original exception |
|
| 283 | + throw $e; |
|
| 284 | + } |
|
| 285 | + } else { |
|
| 286 | + throw $e; |
|
| 287 | + } |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + return $parameters; |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + /** |
|
| 294 | + * Find and execute the route matching $url |
|
| 295 | + * |
|
| 296 | + * @param string $url The url to find |
|
| 297 | + * @throws \Exception |
|
| 298 | + * @return void |
|
| 299 | + */ |
|
| 300 | + public function match($url) { |
|
| 301 | + $parameters = $this->findMatchingRoute($url); |
|
| 302 | + |
|
| 303 | + \OC::$server->getEventLogger()->start('run_route', 'Run route'); |
|
| 304 | + if (isset($parameters['caller'])) { |
|
| 305 | + $caller = $parameters['caller']; |
|
| 306 | + unset($parameters['caller']); |
|
| 307 | + $application = $this->getApplicationClass($caller[0]); |
|
| 308 | + \OC\AppFramework\App::main($caller[1], $caller[2], $application->getContainer(), $parameters); |
|
| 309 | + } elseif (isset($parameters['action'])) { |
|
| 310 | + $action = $parameters['action']; |
|
| 311 | + if (!is_callable($action)) { |
|
| 312 | + throw new \Exception('not a callable action'); |
|
| 313 | + } |
|
| 314 | + unset($parameters['action']); |
|
| 315 | + call_user_func($action, $parameters); |
|
| 316 | + } elseif (isset($parameters['file'])) { |
|
| 317 | + include $parameters['file']; |
|
| 318 | + } else { |
|
| 319 | + throw new \Exception('no action available'); |
|
| 320 | + } |
|
| 321 | + \OC::$server->getEventLogger()->end('run_route'); |
|
| 322 | + } |
|
| 323 | + |
|
| 324 | + /** |
|
| 325 | + * Get the url generator |
|
| 326 | + * |
|
| 327 | + * @return \Symfony\Component\Routing\Generator\UrlGenerator |
|
| 328 | + * |
|
| 329 | + */ |
|
| 330 | + public function getGenerator() { |
|
| 331 | + if (null !== $this->generator) { |
|
| 332 | + return $this->generator; |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + return $this->generator = new UrlGenerator($this->root, $this->context); |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + /** |
|
| 339 | + * Generate url based on $name and $parameters |
|
| 340 | + * |
|
| 341 | + * @param string $name Name of the route to use. |
|
| 342 | + * @param array $parameters Parameters for the route |
|
| 343 | + * @param bool $absolute |
|
| 344 | + * @return string |
|
| 345 | + */ |
|
| 346 | + public function generate($name, |
|
| 347 | + $parameters = [], |
|
| 348 | + $absolute = false) { |
|
| 349 | + $referenceType = UrlGenerator::ABSOLUTE_URL; |
|
| 350 | + if ($absolute === false) { |
|
| 351 | + $referenceType = UrlGenerator::ABSOLUTE_PATH; |
|
| 352 | + } |
|
| 353 | + $name = $this->fixLegacyRootName($name); |
|
| 354 | + if (strpos($name, '.') !== false) { |
|
| 355 | + list($appName, $other) = explode('.', $name, 3); |
|
| 356 | + // OCS routes are prefixed with "ocs." |
|
| 357 | + if ($appName === 'ocs') { |
|
| 358 | + $appName = $other; |
|
| 359 | + } |
|
| 360 | + $this->loadRoutes($appName); |
|
| 361 | + try { |
|
| 362 | + return $this->getGenerator()->generate($name, $parameters, $referenceType); |
|
| 363 | + } catch (RouteNotFoundException $e) { |
|
| 364 | + } |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + // Fallback load all routes |
|
| 368 | + $this->loadRoutes(); |
|
| 369 | + try { |
|
| 370 | + return $this->getGenerator()->generate($name, $parameters, $referenceType); |
|
| 371 | + } catch (RouteNotFoundException $e) { |
|
| 372 | + $this->logger->logException($e, ['level' => ILogger::INFO]); |
|
| 373 | + return ''; |
|
| 374 | + } |
|
| 375 | + } |
|
| 376 | + |
|
| 377 | + protected function fixLegacyRootName(string $routeName): string { |
|
| 378 | + if ($routeName === 'files.viewcontroller.showFile') { |
|
| 379 | + return 'files.View.showFile'; |
|
| 380 | + } |
|
| 381 | + if ($routeName === 'files_sharing.sharecontroller.showShare') { |
|
| 382 | + return 'files_sharing.Share.showShare'; |
|
| 383 | + } |
|
| 384 | + if ($routeName === 'files_sharing.sharecontroller.showAuthenticate') { |
|
| 385 | + return 'files_sharing.Share.showAuthenticate'; |
|
| 386 | + } |
|
| 387 | + if ($routeName === 'files_sharing.sharecontroller.authenticate') { |
|
| 388 | + return 'files_sharing.Share.authenticate'; |
|
| 389 | + } |
|
| 390 | + if ($routeName === 'files_sharing.sharecontroller.downloadShare') { |
|
| 391 | + return 'files_sharing.Share.downloadShare'; |
|
| 392 | + } |
|
| 393 | + if ($routeName === 'files_sharing.publicpreview.directLink') { |
|
| 394 | + return 'files_sharing.PublicPreview.directLink'; |
|
| 395 | + } |
|
| 396 | + if ($routeName === 'cloud_federation_api.requesthandlercontroller.addShare') { |
|
| 397 | + return 'cloud_federation_api.RequestHandler.addShare'; |
|
| 398 | + } |
|
| 399 | + if ($routeName === 'cloud_federation_api.requesthandlercontroller.receiveNotification') { |
|
| 400 | + return 'cloud_federation_api.RequestHandler.receiveNotification'; |
|
| 401 | + } |
|
| 402 | + return $routeName; |
|
| 403 | + } |
|
| 404 | + |
|
| 405 | + /** |
|
| 406 | + * To isolate the variable scope used inside the $file it is required in it's own method |
|
| 407 | + * |
|
| 408 | + * @param string $file the route file location to include |
|
| 409 | + * @param string $appName |
|
| 410 | + */ |
|
| 411 | + private function requireRouteFile($file, $appName) { |
|
| 412 | + $this->setupRoutes(include_once $file, $appName); |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + |
|
| 416 | + /** |
|
| 417 | + * If a routes.php file returns an array, try to set up the application and |
|
| 418 | + * register the routes for the app. The application class will be chosen by |
|
| 419 | + * camelcasing the appname, e.g.: my_app will be turned into |
|
| 420 | + * \OCA\MyApp\AppInfo\Application. If that class does not exist, a default |
|
| 421 | + * App will be intialized. This makes it optional to ship an |
|
| 422 | + * appinfo/application.php by using the built in query resolver |
|
| 423 | + * |
|
| 424 | + * @param array $routes the application routes |
|
| 425 | + * @param string $appName the name of the app. |
|
| 426 | + */ |
|
| 427 | + private function setupRoutes($routes, $appName) { |
|
| 428 | + if (is_array($routes)) { |
|
| 429 | + $application = $this->getApplicationClass($appName); |
|
| 430 | + $application->registerRoutes($this, $routes); |
|
| 431 | + } |
|
| 432 | + } |
|
| 433 | + |
|
| 434 | + private function getApplicationClass(string $appName) { |
|
| 435 | + $appNameSpace = App::buildAppNamespace($appName); |
|
| 436 | + |
|
| 437 | + $applicationClassName = $appNameSpace . '\\AppInfo\\Application'; |
|
| 438 | + |
|
| 439 | + if (class_exists($applicationClassName)) { |
|
| 440 | + $application = \OC::$server->query($applicationClassName); |
|
| 441 | + } else { |
|
| 442 | + $application = new App($appName); |
|
| 443 | + } |
|
| 444 | + |
|
| 445 | + return $application; |
|
| 446 | + } |
|
| 447 | 447 | } |