App.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCA\Files;
  8. use OC\NavigationManager;
  9. use OCP\App\IAppManager;
  10. use OCP\IConfig;
  11. use OCP\IGroupManager;
  12. use OCP\INavigationManager;
  13. use OCP\IURLGenerator;
  14. use OCP\IUserSession;
  15. use OCP\L10N\IFactory;
  16. use OCP\Server;
  17. use Psr\Log\LoggerInterface;
  18. class App {
  19. private static ?INavigationManager $navigationManager = null;
  20. /**
  21. * Returns the app's navigation manager
  22. */
  23. public static function getNavigationManager(): INavigationManager {
  24. // TODO: move this into a service in the Application class
  25. if (self::$navigationManager === null) {
  26. self::$navigationManager = new NavigationManager(
  27. Server::get(IAppManager::class),
  28. Server::get(IUrlGenerator::class),
  29. Server::get(IFactory::class),
  30. Server::get(IUserSession::class),
  31. Server::get(IGroupManager::class),
  32. Server::get(IConfig::class),
  33. Server::get(LoggerInterface::class),
  34. );
  35. self::$navigationManager->clear(false);
  36. }
  37. return self::$navigationManager;
  38. }
  39. public static function extendJsConfig($settings): void {
  40. $appConfig = json_decode($settings['array']['oc_appconfig'], true);
  41. $maxChunkSize = (int)Server::get(IConfig::class)->getAppValue('files', 'max_chunk_size', (string)(10 * 1024 * 1024));
  42. $appConfig['files'] = [
  43. 'max_chunk_size' => $maxChunkSize
  44. ];
  45. $settings['array']['oc_appconfig'] = json_encode($appConfig);
  46. }
  47. }