systemConfigRepository->findAll(); } public function getConfigValue(SystemSettingKey $key, string $default = ''): string { return $this->systemConfigRepository->getValue($key, $default); } public function setConfigValue(SystemSettingKey $key, string $value): void { $this->systemConfigRepository->setValue($key, $value); } public function getConfigByKey(SystemSettingKey $key): SystemConfig { return $this->systemConfigRepository->findByKey($key); } public function createConfig(SystemSettingKey $key, string $value): SystemConfig { if ($this->systemConfigRepository->findByKey($key) instanceof SystemConfig) { throw new InvalidArgumentException("A configuration with the key '{$key->value}' already exists"); } $config = new SystemConfig(); $config->setKey($key); $config->setValue($value); $this->systemConfigRepository->save($config); return $config; } public function updateConfig(SystemConfig $config, string $value): SystemConfig { if ($value !== '') { $config->setValue($value); } $this->systemConfigRepository->save($config); return $config; } public function resetAllConfigs(): void { foreach (SystemSettingKey::cases() as $key) { $this->setDefaultValue($key); } } public function setDefaultValue(SystemSettingKey $key): void { $this->setConfigValue($key, SystemSettingKey::getDefaultValue($key)); } }