PageController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 34
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A index() 0 9 2
1
<?php
2
/**
3
 * Nextcloud - Tasks
4
 *
5
 * @author Raimund Schlüßler
6
 * @copyright 2019 Raimund Schlüßler <[email protected]>
7
 *
8
 * This library is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
 * License as published by the Free Software Foundation; either
11
 * version 3 of the License, or any later version.
12
 *
13
 * This library is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
 *
18
 * You should have received a copy of the GNU Affero General Public
19
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
20
 *
21
 */
22
23
namespace OCA\Tasks\Controller;
24
25
use \OCA\Tasks\Service\SettingsService;
26
use \OCP\AppFramework\Controller;
27
use \OCP\AppFramework\Http\TemplateResponse;
28
use \OCP\IInitialStateService;
29
use \OCP\IRequest;
30
31
/**
32
 * Controller class for main page.
33
 */
34
class PageController extends Controller {
35
36
	/**
37
	 * @var IInitialStateService
38
	 */
39
	private $initialStateService;
40
41
	/**
42
	 * @param string $appName
43
	 * @param IRequest $request an instance of the request
44
	 */
45
	public function __construct(string $appName, IRequest $request, SettingsService $settingsService, IInitialStateService $initialStateService) {
46
		parent::__construct($appName, $request);
47
		$this->settingsService = $settingsService;
48
		$this->initialStateService = $initialStateService;
49
	}
50
51
52
	/**
53
	 * @NoAdminRequired
54
	 * @NoCSRFRequired
55
	 *
56
	 * @return TemplateResponse
57
	 */
58
	public function index():TemplateResponse {
59
		$settings = $this->settingsService->get();
60
61
		foreach ($settings as $setting => $value) {
62
			$this->initialStateService->provideInitialState($this->appName, $setting, $value);
63
		}
64
65
		return new TemplateResponse('tasks', 'main');
66
	}
67
}
68