OCJSController.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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) <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. /** @var JSConfigHelper */
  47. private $helper;
  48. /**
  49. * OCJSController constructor.
  50. *
  51. * @param string $appName
  52. * @param IRequest $request
  53. * @param IFactory $l10nFactory
  54. * @param Defaults $defaults
  55. * @param IAppManager $appManager
  56. * @param ISession $session
  57. * @param IUserSession $userSession
  58. * @param IConfig $config
  59. * @param IGroupManager $groupManager
  60. * @param IniGetWrapper $iniWrapper
  61. * @param IURLGenerator $urlGenerator
  62. * @param CapabilitiesManager $capabilitiesManager
  63. * @param IInitialStateService $initialStateService
  64. */
  65. public function __construct($appName,
  66. IRequest $request,
  67. IFactory $l10nFactory,
  68. Defaults $defaults,
  69. IAppManager $appManager,
  70. ISession $session,
  71. IUserSession $userSession,
  72. IConfig $config,
  73. IGroupManager $groupManager,
  74. IniGetWrapper $iniWrapper,
  75. IURLGenerator $urlGenerator,
  76. CapabilitiesManager $capabilitiesManager,
  77. IInitialStateService $initialStateService) {
  78. parent::__construct($appName, $request);
  79. $this->helper = new JSConfigHelper(
  80. $l10nFactory->get('lib'),
  81. $defaults,
  82. $appManager,
  83. $session,
  84. $userSession->getUser(),
  85. $config,
  86. $groupManager,
  87. $iniWrapper,
  88. $urlGenerator,
  89. $capabilitiesManager,
  90. $initialStateService
  91. );
  92. }
  93. /**
  94. * @NoCSRFRequired
  95. * @PublicPage
  96. *
  97. * @return DataDisplayResponse
  98. */
  99. public function getConfig() {
  100. $data = $this->helper->getConfig();
  101. return new DataDisplayResponse($data, Http::STATUS_OK, ['Content-type' => 'text/javascript']);
  102. }
  103. }