1
0

OCJSController.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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(string $appName,
  48. IRequest $request,
  49. IFactory $l10nFactory,
  50. Defaults $defaults,
  51. IAppManager $appManager,
  52. ISession $session,
  53. IUserSession $userSession,
  54. IConfig $config,
  55. IGroupManager $groupManager,
  56. IniGetWrapper $iniWrapper,
  57. IURLGenerator $urlGenerator,
  58. CapabilitiesManager $capabilitiesManager,
  59. IInitialStateService $initialStateService) {
  60. parent::__construct($appName, $request);
  61. $this->helper = new JSConfigHelper(
  62. $l10nFactory->get('lib'),
  63. $defaults,
  64. $appManager,
  65. $session,
  66. $userSession->getUser(),
  67. $config,
  68. $groupManager,
  69. $iniWrapper,
  70. $urlGenerator,
  71. $capabilitiesManager,
  72. $initialStateService
  73. );
  74. }
  75. /**
  76. * @NoCSRFRequired
  77. * @NoTwoFactorRequired
  78. * @PublicPage
  79. */
  80. public function getConfig(): DataDisplayResponse {
  81. $data = $this->helper->getConfig();
  82. return new DataDisplayResponse($data, Http::STATUS_OK, ['Content-type' => 'text/javascript']);
  83. }
  84. }