Skip to content

Commit

Permalink
feat: Added setting getter / setter
Browse files Browse the repository at this point in the history
  • Loading branch information
seebeen committed Oct 21, 2023
1 parent 12e2308 commit 58a9315
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/Module/BaseModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,31 @@ public function getCurrentLanguage(bool $inClientArea = true): string

return $languageName;
}

/**
* Get the plugin setting
*
* If no setting is provided, returns all settings
*
* @param string|null $setting Setting name.
*/
public function getSettings(?string $setting = null)
{
return $setting ? $this->settings[$setting] ?? null : $this->settings;
}

/**
* Set the plugin setting
*
* @param string $key Setting name.
* @param mixed $value Setting value.
*/
public function setSettings(string $key, $value)
{
return Capsule::table('tbladdonmodules')
->updateOrInsert(
['module' => $this->moduleName, 'setting' => $key],
['value' => $value]
);
}
}

0 comments on commit 58a9315

Please sign in to comment.