1
0

OCJSController.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. *
  12. * @license GNU AGPL version 3 or any later version
  13. *
  14. * This program is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Affero General Public License as
  16. * published by the Free Software Foundation, either version 3 of the
  17. * License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU Affero General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Affero General Public License
  25. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  26. *
  27. */
  28. namespace OC\Core\Controller;
  29. use bantu\IniGetWrapper\IniGetWrapper;
  30. use OC\CapabilitiesManager;
  31. use OC\Template\JSConfigHelper;
  32. use OCP\App\IAppManager;
  33. use OCP\AppFramework\Controller;
  34. use OCP\AppFramework\Http;
  35. use OCP\AppFramework\Http\DataDisplayResponse;
  36. use OCP\Defaults;
  37. use OCP\IConfig;
  38. use OCP\IGroupManager;
  39. use OCP\IInitialStateService;
  40. use OCP\IRequest;
  41. use OCP\ISession;
  42. use OCP\IURLGenerator;
  43. use OCP\IUserSession;
  44. use OCP\L10N\IFactory;
  45. class OCJSController extends Controller {
  46. private JSConfigHelper $helper;
  47. public function __construct(
  48. string $appName,
  49. IRequest $request,
  50. IFactory $l10nFactory,
  51. Defaults $defaults,
  52. IAppManager $appManager,
  53. ISession $session,
  54. IUserSession $userSession,
  55. IConfig $config,
  56. IGroupManager $groupManager,
  57. IniGetWrapper $iniWrapper,
  58. IURLGenerator $urlGenerator,
  59. CapabilitiesManager $capabilitiesManager,
  60. IInitialStateService $initialStateService,
  61. ) {
  62. parent::__construct($appName, $request);
  63. $this->helper = new JSConfigHelper(
  64. $l10nFactory->get('lib'),
  65. $defaults,
  66. $appManager,
  67. $session,
  68. $userSession->getUser(),
  69. $config,
  70. $groupManager,
  71. $iniWrapper,
  72. $urlGenerator,
  73. $capabilitiesManager,
  74. $initialStateService
  75. );
  76. }
  77. /**
  78. * @NoCSRFRequired
  79. * @NoTwoFactorRequired
  80. * @PublicPage
  81. */
  82. public function getConfig(): DataDisplayResponse {
  83. $data = $this->helper->getConfig();
  84. return new DataDisplayResponse($data, Http::STATUS_OK, ['Content-type' => 'text/javascript']);
  85. }
  86. }