Completed
Pull Request — master (#1917)
by Lukas
40:33 queued 30:26
created

OCJSController::getConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * @copyright Copyright (c) 2016, Roeland Jago Douma <[email protected]>
4
 *
5
 * @author Roeland Jago Douma <[email protected]>
6
 *
7
 * @license GNU AGPL version 3 or any later version
8
 *
9
 * This program is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU Affero General Public License as
11
 * published by the Free Software Foundation, either version 3 of the
12
 * License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU Affero General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU Affero General Public License
20
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 *
22
 */
23
namespace OC\Core\Controller;
24
25
use bantu\IniGetWrapper\IniGetWrapper;
26
use OC\Template\JSConfigHelper;
27
use OCP\App\IAppManager;
28
use OCP\AppFramework\Controller;
29
use OCP\AppFramework\Http;
30
use OCP\AppFramework\Http\DataDisplayResponse;
31
use OCP\IConfig;
32
use OCP\IGroupManager;
33
use OCP\IL10N;
34
use OCP\IRequest;
35
use OCP\IURLGenerator;
36
use OCP\IUserSession;
37
38
class OCJSController extends Controller {
39
40
	/** @var JSConfigHelper */
41
	private $helper;
42
43
	/**
44
	 * OCJSController constructor.
45
	 *
46
	 * @param string $appName
47
	 * @param IRequest $request
48
	 * @param IL10N $l
49
	 * @param \OC_Defaults $defaults
50
	 * @param IAppManager $appManager
51
	 * @param IUserSession $session
52
	 * @param IConfig $config
53
	 * @param IGroupManager $groupManager
54
	 * @param IniGetWrapper $iniWrapper
55
	 * @param IURLGenerator $urlGenerator
56
	 */
57
	public function __construct($appName,
58
								IRequest $request,
59
								IL10N $l,
60
								\OC_Defaults $defaults,
61
								IAppManager $appManager,
62
								IUserSession $session,
63
								IConfig $config,
64
								IGroupManager $groupManager,
65
								IniGetWrapper $iniWrapper,
66
								IURLGenerator $urlGenerator) {
67
		parent::__construct($appName, $request);
68
69
		$this->helper = new JSConfigHelper(
70
			$l,
71
			$defaults,
72
			$appManager,
73
			$session->getUser(),
74
			$config,
75
			$groupManager,
76
			$iniWrapper,
77
			$urlGenerator
78
		);
79
	}
80
81
	/**
82
	 * @NoCSRFRequired
83
	 * @PublicPage
84
	 *
85
	 * @return DataDisplayResponse
86
	 */
87
	public function getConfig() {
88
		$data = $this->helper->getConfig();
89
90
		return new DataDisplayResponse($data, Http::STATUS_OK, ['Content-type' => 'text/javascript']);
91
	}
92
}
93