summaryrefslogtreecommitdiffstats
path: root/lib/Settings/AdminSettings.php
blob: 1f3d98c0895ab598f139c938c5414b7c3a4a8035 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php

namespace OCA\News\Settings;

use OCA\News\AppInfo\Application;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\Settings\ISettings;

class AdminSettings implements ISettings
{

    /**
     * @var IConfig
     */
    private $config;

    public function __construct(IConfig $config)
    {
        $this->config = $config;
    }

    public function getForm()
    {
        $data = [];

        foreach (array_keys(Application::DEFAULT_SETTINGS) as $setting) {
            $data[$setting] = $this->config->getAppValue(
                Application::NAME,
                $setting,
                Application::DEFAULT_SETTINGS[$setting]
            );
        }

        return new TemplateResponse(Application::NAME, 'admin', $data);
    }

    public function getSection()
    {
        return 'news';
    }

    public function getPriority()
    {
        return 40;
    }
}