Services
SettingsServiceInterface
v1.0.0Module-scoped settings CRUD backed by the meteorack_module_settings table.
Access
$ctx->settings()?->get('sync_interval', 300);How To Use It
- Use it for module-owned configuration that should survive page reloads and deployments.
- Prefer the HasSettings trait on AbstractModule for day-to-day reads and writes, and drop to the raw service when you need defaults or direct service access.
Works Well With
Methods
public function get(string $key, mixed $default = null): mixedReads a setting value with an optional fallback.
public function set(string $key, mixed $value): voidPersists a setting value for the current module.
public function delete(string $key): voidRemoves a setting from the current module namespace.
public function all(): arrayReturns all stored settings for the current module.
public function getDefaults(): arrayReturns the runtime default settings map for the module.
Example
bootstrap.php
public function onSdkReady(SdkContext $ctx): void
{
parent::onSdkReady($ctx);
$ctx->settings()?->set('sync_interval', 900);
$interval = $ctx->settings()?->get('sync_interval', 300);
$defaults = $ctx->settings()?->getDefaults() ?? [];
$ctx->logger()->info('reports.settings_loaded', [
'sync_interval' => $interval,
'defaults' => $defaults,
]);
}