summaryrefslogtreecommitdiffstats
path: root/lib/private/Settings
diff options
context:
space:
mode:
authorsualko <klaus@jsxc.org>2018-08-25 16:48:37 +0200
committersualko <klaus@jsxc.org>2018-08-25 17:32:19 +0200
commit61370549f3f86565b73823ff3aba9ba28ec0a8be (patch)
treee4315cbe480cdb5af0b7a4facfbccdb756a17033 /lib/private/Settings
parent6099786c8dbd86c0848909108eb2a5572ad7a4bb (diff)
downloadnextcloud-server-61370549f3f86565b73823ff3aba9ba28ec0a8be.tar.gz
nextcloud-server-61370549f3f86565b73823ff3aba9ba28ec0a8be.zip
Allow same section class for multiple section types (fix #10764)
Signed-off-by: Klaus Herberth <klaus@jsxc.org>
Diffstat (limited to 'lib/private/Settings')
-rw-r--r--lib/private/Settings/Manager.php23
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/private/Settings/Manager.php b/lib/private/Settings/Manager.php
index 260e33d1929..f1baf35b7ab 100644
--- a/lib/private/Settings/Manager.php
+++ b/lib/private/Settings/Manager.php
@@ -133,7 +133,11 @@ class Manager implements IManager {
* @return void
*/
public function registerSection(string $type, string $section) {
- $this->sectionClasses[$section] = $type;
+ if (!isset($this->sectionClasses[$type])) {
+ $this->sectionClasses[$type] = [];
+ }
+
+ $this->sectionClasses[$type][] = $section;
}
/**
@@ -145,7 +149,11 @@ class Manager implements IManager {
$this->sections[$type] = [];
}
- foreach ($this->sectionClasses as $class => $sectionType) {
+ if (!isset($this->sectionClasses[$type])) {
+ return $this->sections[$type];
+ }
+
+ foreach ($this->sectionClasses[$type] as $index => $class) {
try {
/** @var ISection $section */
$section = \OC::$server->query($class);
@@ -159,9 +167,16 @@ class Manager implements IManager {
continue;
}
- $this->sections[$sectionType][$section->getID()] = $section;
+ $sectionID = $section->getID();
+
+ if (isset($this->sections[$type][$sectionID])) {
+ $this->log->logException(new \InvalidArgumentException('Section with the same ID already registered'), ['level' => ILogger::INFO]);
+ continue;
+ }
+
+ $this->sections[$type][$sectionID] = $section;
- unset($this->sectionClasses[$class]);
+ unset($this->sectionClasses[$type][$index]);
}
return $this->sections[$type];