1
0

OCJSController.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, Roeland Jago Douma <roeland@famdouma.nl>
  4. *
  5. * @author Bjoern Schiessle <bjoern@schiessle.org>
  6. * @author Joas Schilling <coding@schilljs.com>
  7. * @author John Molakvoæ <skjnldsv@protonmail.com>
  8. * @author Lukas Reschke <lukas@statuscode.ch>
  9. * @author Morris Jobke <hey@morrisjobke.de>
  10. * @author Roeland Jago Douma <roeland@famdouma.nl>
  11. * @author Kate Döen <kate.doeen@nextcloud.com>
  12. *
  13. * @license GNU AGPL version 3 or any later version
  14. *
  15. * This program is free software: you can redistribute it and/or modify
  16. * it under the terms of the GNU Affero General Public License as
  17. * published by the Free Software Foundation, either version 3 of the
  18. * License, or (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU Affero General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU Affero General Public License
  26. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  27. *
  28. */
  29. namespace OC\Core\Controller;
  30. use bantu\IniGetWrapper\IniGetWrapper;
  31. use OC\Authentication\Token\IProvider;
  32. use OC\CapabilitiesManager;
  33. use OC\Template\JSConfigHelper;
  34. use OCP\App\IAppManager;
  35. use OCP\AppFramework\Controller;
  36. use OCP\AppFramework\Http;
  37. use OCP\AppFramework\Http\Attribute\OpenAPI;
  38. use OCP\AppFramework\Http\DataDisplayResponse;
  39. use OCP\Defaults;
  40. use OCP\IConfig;
  41. use OCP\IGroupManager;
  42. use OCP\IInitialStateService;
  43. use OCP\IRequest;
  44. use OCP\ISession;
  45. use OCP\IURLGenerator;
  46. use OCP\IUserSession;
  47. use OCP\L10N\IFactory;
  48. #[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)]
  49. class OCJSController extends Controller {
  50. private JSConfigHelper $helper;
  51. public function __construct(
  52. string $appName,
  53. IRequest $request,
  54. IFactory $l10nFactory,
  55. Defaults $defaults,
  56. IAppManager $appManager,
  57. ISession $session,
  58. IUserSession $userSession,
  59. IConfig $config,
  60. IGroupManager $groupManager,
  61. IniGetWrapper $iniWrapper,
  62. IURLGenerator $urlGenerator,
  63. CapabilitiesManager $capabilitiesManager,
  64. IInitialStateService $initialStateService,
  65. IProvider $tokenProvider,
  66. ) {
  67. parent::__construct($appName, $request);
  68. $this->helper = new JSConfigHelper(
  69. $l10nFactory->get('lib'),
  70. $defaults,
  71. $appManager,
  72. $session,
  73. $userSession->getUser(),
  74. $config,
  75. $groupManager,
  76. $iniWrapper,
  77. $urlGenerator,
  78. $capabilitiesManager,
  79. $initialStateService,
  80. $tokenProvider
  81. );
  82. }
  83. /**
  84. * @NoCSRFRequired
  85. * @NoTwoFactorRequired
  86. * @PublicPage
  87. */
  88. public function getConfig(): DataDisplayResponse {
  89. $data = $this->helper->getConfig();
  90. return new DataDisplayResponse($data, Http::STATUS_OK, ['Content-type' => 'text/javascript']);
  91. }
  92. }