Completed
Pull Request — master (#93)
by Janis
07:58
created

Admin   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 42
ccs 0
cts 17
cp 0
rs 10
c 1
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getForm() 0 8 1
A getSection() 0 3 1
A getPriority() 0 3 1
1
<?php
2
3
/**
4
 * Nextcloud - OCR
5
 *
6
 * This file is licensed under the Affero General Public License version 3 or
7
 * later. See the COPYING file.
8
 *
9
 * @author Janis Koehr <[email protected]>
10
 * @copyright Janis Koehr 2017
11
 */
12
namespace OCA\Ocr\Settings;
13
14
use OCP\Settings\ISettings;
15
use OCP\IConfig;
16
use OCP\AppFramework\Http\TemplateResponse;
17
use OCA\Ocr\Constants\OcrConstants;
18
19
class Admin implements ISettings {
20
	
21
	/** @var IConfig */
22
	private $config;
23
	/**
24
	 *
25
	 * @param IConfig $config        	
26
	 */
27
	public function __construct(IConfig $config) {
28
		$this->config = $config;
29
	}
30
	/**
31
	 *
32
	 * @return TemplateResponse
33
	 */
34
	public function getForm() {
35
		return new TemplateResponse( 'ocr', 'settings-admin', [ 
36
				OcrConstants::LANGUAGES_CONFIG_KEY => $this->config->getAppValue ( 'ocr', OcrConstants::LANGUAGES_CONFIG_KEY), 
37
				OcrConstants::REDIS_CONFIG_KEY_HOST => $this->config->getAppValue ( 'ocr', OcrConstants::REDIS_CONFIG_KEY_HOST),
38
				OcrConstants::REDIS_CONFIG_KEY_PORT => $this->config->getAppValue('ocr', OcrConstants::REDIS_CONFIG_KEY_PORT),
39
				OcrConstants::REDIS_CONFIG_KEY_DB => $this->config->getAppValue('ocr', OcrConstants::REDIS_CONFIG_KEY_DB)
40
		], 'blank' );
41
	}
42
	/**
43
	 *
44
	 * @return string the section ID, e.g. 'sharing'
45
	 */
46
	public function getSection() {
47
		return 'ocr';
48
	}
49
	/**
50
	 *
51
	 * @return int whether the form should be rather on the top or bottom of
52
	 *         the admin section. The forms are arranged in ascending order of the
53
	 *         priority values. It is required to return a value between 0 and 100.
54
	 *        
55
	 *         keep the server setting at the top, right after "server settings"
56
	 */
57
	public function getPriority() {
58
		return 0;
59
	}
60
}