Admin::getPriority()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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