diff --git a/app/Handlers/Registrators/Items/SettingExtension.php b/app/Handlers/Registrators/Items/SettingExtension.php new file mode 100644 index 00000000..64a65eff --- /dev/null +++ b/app/Handlers/Registrators/Items/SettingExtension.php @@ -0,0 +1,56 @@ +id = $id; + $this->name = $name; + $this->view = $view; + } + + /** + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @return string + */ + public function getView() + { + return $this->view; + } +} \ No newline at end of file diff --git a/app/Handlers/Registrators/SettingsExtensionRegistrator.php b/app/Handlers/Registrators/SettingsExtensionRegistrator.php new file mode 100644 index 00000000..882d1b75 --- /dev/null +++ b/app/Handlers/Registrators/SettingsExtensionRegistrator.php @@ -0,0 +1,68 @@ +settingsExtensions = []; + } + + /** + * Method for registering new settings extensions/parts + * + * @param $sectionId + * @param $sectionName + * @param $sectionView + * + * @throws EnumerationExistsException + */ + public function register($sectionId, $sectionName, $sectionView) + { + $this->checkIfRegistered($sectionId); + + // register new extension + $this->settingsExtensions[$sectionId] = new SettingExtension($sectionId, $sectionName, $sectionView); + } + + /** + * Registers new setting part - only as SettingExtension directly + * + * @param SettingExtension $extension + */ + public function registerObject(SettingExtension $extension) + { + $this->checkIfRegistered($extension->getId()); + + $this->settingsExtensions[$extension->getId()] = $extension; + } + + /** + * Getter for all registered extensions + * + * @return array + */ + public function get() + { + return $this->settingsExtensions; + } + + /** + * Checks if this section is not already defined + * + * @param $sectionId + * + * @throws EnumerationExistsException + */ + private function checkIfRegistered($sectionId) + { + if (isset($this->settingsExtensions[$sectionId])) { + throw new EnumerationExistsException('Already existing key ' . $sectionId); + } + } +}