| @@ 212-237 (lines=26) @@ | ||
| 209 | * @param string $sectionClassName |
|
| 210 | * @param string $type either 'admin' or 'personal' |
|
| 211 | */ |
|
| 212 | private function setupSectionEntry($sectionClassName, $type) { |
|
| 213 | if (!class_exists($sectionClassName)) { |
|
| 214 | $this->log->debug('Could not find ' . ucfirst($type) . ' section class ' . $sectionClassName); |
|
| 215 | return; |
|
| 216 | } |
|
| 217 | try { |
|
| 218 | $section = $this->query($sectionClassName); |
|
| 219 | } catch (QueryException $e) { |
|
| 220 | // cancel |
|
| 221 | return; |
|
| 222 | } |
|
| 223 | ||
| 224 | if (!$section instanceof ISection) { |
|
| 225 | $this->log->error( |
|
| 226 | ucfirst($type) .' section instance must implement \OCP\ISection. Invalid class: {class}', |
|
| 227 | ['class' => $sectionClassName] |
|
| 228 | ); |
|
| 229 | return; |
|
| 230 | } |
|
| 231 | $table = $this->getSectionTableForType($type); |
|
| 232 | if(!$this->hasSection(get_class($section), $table)) { |
|
| 233 | $this->addSection($section, $table); |
|
| 234 | } else { |
|
| 235 | $this->updateSection($section, $table); |
|
| 236 | } |
|
| 237 | } |
|
| 238 | ||
| 239 | private function addSection(ISection $section, $table) { |
|
| 240 | $this->mapper->add($table, [ |
|
| @@ 296-323 (lines=28) @@ | ||
| 293 | return $this->mapper->has($table, $className); |
|
| 294 | } |
|
| 295 | ||
| 296 | private function setupSettingsEntry($settingsClassName, $type) { |
|
| 297 | if (!class_exists($settingsClassName)) { |
|
| 298 | $this->log->debug('Could not find ' . $type . ' section class ' . $settingsClassName); |
|
| 299 | return; |
|
| 300 | } |
|
| 301 | ||
| 302 | try { |
|
| 303 | /** @var ISettings $settings */ |
|
| 304 | $settings = $this->query($settingsClassName); |
|
| 305 | } catch (QueryException $e) { |
|
| 306 | // cancel |
|
| 307 | return; |
|
| 308 | } |
|
| 309 | ||
| 310 | if (!$settings instanceof ISettings) { |
|
| 311 | $this->log->error( |
|
| 312 | ucfirst($type) . ' section instance must implement \OCP\Settings\ISettings. Invalid class: {class}', |
|
| 313 | ['class' => $settingsClassName] |
|
| 314 | ); |
|
| 315 | return; |
|
| 316 | } |
|
| 317 | $table = $this->getSettingsTableForType($type); |
|
| 318 | if (!$this->hasSettings(get_class($settings), $table)) { |
|
| 319 | $this->addSettings($settings, $table); |
|
| 320 | } else { |
|
| 321 | $this->updateSettings($settings, $table); |
|
| 322 | } |
|
| 323 | } |
|
| 324 | ||
| 325 | private function getSectionTableForType($type) { |
|
| 326 | if($type === 'admin') { |
|