Completed
Push — master ( 0471ec...901b23 )
by René
10:22 queued 06:22
created

SystemController::getVendor()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <[email protected]>
4
 *
5
 * @author René Gieling <[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
24
namespace OCA\Polls\Controller;
25
26
use OCP\AppFramework\Controller;
27
use OCP\AppFramework\Http;
28
use OCP\AppFramework\Http\DataResponse;
29
30
use OCP\IConfig;
31
use OCP\IRequest;
32
33
class SystemController extends Controller {
34
35
	private $systemConfig;
36
37
	/**
38
	 * PageController constructor.
39
	 * @param String $appName
40
	 * @param IConfig $systemConfig
41
	 * @param IRequest $request
42
	 */
43
	public function __construct(
44
		$appName,
45
		IConfig $systemConfig,
46
		IRequest $request
47
	) {
48
		parent::__construct($appName, $request);
49
		$this->systemConfig = $systemConfig;
50
	}
51
52
	/**
53
	 * Get the endor  name of the installation ('ownCloud' or 'Nextcloud')
54
	 * @NoAdminRequired
55
	 * @NoCSRFRequired
56
	 * @return String
57
	 */
58
	private function getVendor() {
59
		require \OC::$SERVERROOT . '/version.php';
60
61
		/** @var string $vendor */
62
		return (string) $vendor;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $vendor seems to be never defined.
Loading history...
63
	}
64
65
	/**
66
	 * Get some system informations
67
	 * @NoAdminRequired
68
	 * @NoCSRFRequired
69
	 * @return DataResponse
70
	 */
71
	public function getSystem() {
72
		$userId = \OC::$server->getUserSession()->getUser()->getUID();
73
		$data['system'] = [
0 ignored issues
show
Comprehensibility Best Practice introduced by
$data was never initialized. Although not strictly required by PHP, it is generally a good practice to add $data = array(); before regardless.
Loading history...
74
			'versionArray' => \OCP\Util::getVersion(),
75
			'version' => implode('.', \OCP\Util::getVersion()),
76
			'vendor' => $this->getVendor(),
77
			'language' => $this->systemConfig->getUserValue($userId, 'core', 'lang')
78
		];
79
80
		return new DataResponse($data, Http::STATUS_OK);
81
	}
82
}
83