OCJSController.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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\CapabilitiesManager;
  32. use OC\Template\JSConfigHelper;
  33. use OCP\App\IAppManager;
  34. use OCP\AppFramework\Controller;
  35. use OCP\AppFramework\Http;
  36. use OCP\AppFramework\Http\Attribute\IgnoreOpenAPI;
  37. use OCP\AppFramework\Http\DataDisplayResponse;
  38. use OCP\Defaults;
  39. use OCP\IConfig;
  40. use OCP\IGroupManager;
  41. use OCP\IInitialStateService;
  42. use OCP\IRequest;
  43. use OCP\ISession;
  44. use OCP\IURLGenerator;
  45. use OCP\IUserSession;
  46. use OCP\L10N\IFactory;
  47. #[IgnoreOpenAPI]
  48. class OCJSController extends Controller {
  49. private JSConfigHelper $helper;
  50. public function __construct(
  51. string $appName,
  52. IRequest $request,
  53. IFactory $l10nFactory,
  54. Defaults $defaults,
  55. IAppManager $appManager,
  56. ISession $session,
  57. IUserSession $userSession,
  58. IConfig $config,
  59. IGroupManager $groupManager,
  60. IniGetWrapper $iniWrapper,
  61. IURLGenerator $urlGenerator,
  62. CapabilitiesManager $capabilitiesManager,
  63. IInitialStateService $initialStateService,
  64. ) {
  65. parent::__construct($appName, $request);
  66. $this->helper = new JSConfigHelper(
  67. $l10nFactory->get('lib'),
  68. $defaults,
  69. $appManager,
  70. $session,
  71. $userSession->getUser(),
  72. $config,
  73. $groupManager,
  74. $iniWrapper,
  75. $urlGenerator,
  76. $capabilitiesManager,
  77. $initialStateService
  78. );
  79. }
  80. /**
  81. * @NoCSRFRequired
  82. * @NoTwoFactorRequired
  83. * @PublicPage
  84. */
  85. public function getConfig(): DataDisplayResponse {
  86. $data = $this->helper->getConfig();
  87. return new DataDisplayResponse($data, Http::STATUS_OK, ['Content-type' => 'text/javascript']);
  88. }
  89. }