context = $context; $this->checkConfig(); $this->config = $this->context->getConfig()[$context->getName()]; } protected function checkConfig(): void { $config = $this->context->getConfig(); $defaults = $this->context->getMetadata()["config"]; $name = $this->context->getName(); if (!isset($config[$name])) { $config[$name] = $defaults; return; } foreach ($defaults as $key => $value) { if (!isset($config[$name][$key])) { $config[$name][$key] = $value; } } } protected function saveConfig() { $wrapper = $this->context->getConfig(); $wrapper[$this->context->getName()] = $this->config; $wrapper->save(); } }