1 | <?php |
||
24 | class AppConfig { |
||
25 | |||
26 | private $config; |
||
27 | private $navigationManager; |
||
28 | private $urlGenerator; |
||
29 | |||
30 | /** |
||
31 | * TODO: External deps that are needed: |
||
32 | * - add jobs |
||
33 | * - connect to hooks |
||
34 | */ |
||
35 | public function __construct(INavigationManager $navigationManager, |
||
36 | IURLGenerator $urlGenerator) { |
||
37 | $this->navigationManager = $navigationManager; |
||
38 | $this->urlGenerator = $urlGenerator; |
||
39 | $this->config = []; |
||
40 | } |
||
41 | |||
42 | |||
43 | /** |
||
44 | * Parse an xml config |
||
45 | */ |
||
46 | private function parseConfig($string) { |
||
51 | |||
52 | |||
53 | /** |
||
54 | * @param string|array $data path to the config file or an array with the |
||
55 | * config |
||
56 | */ |
||
57 | public function loadConfig($data) { |
||
58 | if(is_array($data)) { |
||
59 | $this->config = $data; |
||
60 | } else { |
||
61 | $this->config = $this->parseConfig($data); |
||
62 | } |
||
63 | } |
||
64 | |||
65 | |||
66 | /** |
||
67 | * @param string $key if given returns the value of the config at index $key |
||
68 | * @return array|mixed the config |
||
69 | */ |
||
70 | public function getConfig($key=null) { |
||
78 | |||
79 | |||
80 | /** |
||
81 | * Registers all config options |
||
82 | */ |
||
83 | public function registerAll() { |
||
84 | $this->registerNavigation(); |
||
85 | $this->registerHooks(); |
||
86 | // IJob API is fucked up, so silence the code checker |
||
87 | $class = '\OCP\BackgroundJob'; |
||
88 | $class::addRegularTask($this->config['cron']['job'], 'run'); |
||
89 | App::registerAdmin($this->config['id'], $this->config['admin']); |
||
90 | } |
||
91 | |||
92 | |||
93 | /** |
||
94 | * Parses the navigation and creates a navigation entry if needed |
||
95 | */ |
||
96 | public function registerNavigation() { |
||
118 | |||
119 | |||
120 | /** |
||
121 | * Registers all hooks in the config |
||
122 | */ |
||
123 | public function registerHooks() { |
||
135 | |||
136 | |||
137 | } |
||
138 |