Traits
HasSettings
v1.0.0Adds getSetting, setSetting, deleteSetting, and getAllSettings helpers backed by SettingsServiceInterface.
Use Trait
use Meteorack\Sdk\RuntimeWp\Traits\HasSettings;How To Use It
- You usually get this automatically through AbstractModule, so import the trait manually only when you build your own base module class.
- Use the helpers for everyday module configuration work and drop to SettingsServiceInterface only when you need raw defaults or service-level composition.
Works Well With
Helpers
public function getSetting(string $key, mixed $default = null): mixedReads a module setting with an optional fallback.
public function setSetting(string $key, mixed $value): voidPersists a module setting value.
public function deleteSetting(string $key): voidDeletes a stored setting for the current module.
public function getAllSettings(): arrayReturns all stored settings for the module.
Example
bootstrap.php
class ReportsModule extends AbstractModule
{
public function onSdkReady(SdkContext $ctx): void
{
parent::onSdkReady($ctx);
$this->setSetting('theme', 'dark');
$theme = $this->getSetting('theme', 'light');
$ctx->logger()->info('reports.theme_loaded', ['theme' => $theme]);
}
}