Repository navigation
Internals Setting Settings
Framework Internals · Subsystem overview · Developer guide
Source: awt_src/classes/setting/Settings.php · Snapshot 8411f4287706.
Database-backed settings are initialized as named SettingModel constants and retrieved through Config.
use database\DatabaseManager;
use setting\model\SettingModel;class SettingsDeclarations below preserve visibility, type, default and modifiers exactly. A typed property without an initializer remains uninitialized until its constructor or another method assigns it. Mutable fields belong to this instance unless marked static; readonly fields can be initialized once. Constructor-promoted properties are also listed below.
| Member | Declaration | Purpose or source contract |
|---|---|---|
| $database | private DatabaseManager $database; |
Used by __construct(), fetchSettings(), createSetting(). |
| $settings | private array $settings; |
Used by __construct(), fetchSettings(), initSettings(), getSettings(), getSetting(). |
| Method | Signature |
|---|---|
| __construct | public function __construct() |
| fetchSettings | public function fetchSettings(): self |
| initSettings | public function initSettings(): self |
| getSettings | public function getSettings(): array |
| getSetting | public function getSetting(string $name): ?SettingModel |
| createSetting | public function createSetting(int $package_id, string $name, string $value, int $perm, string $value_type = "text", string $category = "Miscellaneous"): int |
public function __construct()State writes: $this->database, $this->settings.
Implementation, validation guards and interaction order
public function __construct()
{
$this->database = new DatabaseManager();
$this->settings = [];
}public function fetchSettings(): selfState writes: $this->settings[$setting["id"]].
Return expressions (including local callbacks): $this.
Implementation, validation guards and interaction order
public function fetchSettings(): self
{
$result = $this->database->
table("awt_setting")->
select(["awt_setting.id", "awt_package.name AS package_name", "awt_setting.package_id", "awt_setting.name", "awt_setting.value", "awt_setting.value_type", "awt_setting.category", "awt_setting.required_permission_level"])->
join("awt_package", "awt_package.id = awt_setting.package_id")->
where(["1" => 1])->
get();
foreach ($result as $setting) {
$this->settings[$setting["id"]] = new SettingModel($setting["id"], $setting["package_name"], $setting);
}
return $this;
}public function initSettings(): selfReturn expressions (including local callbacks): $this.
Implementation, validation guards and interaction order
public function initSettings(): self
{
foreach ($this->settings as $setting) {
$setting->createObjectConstant();
}
return $this;
}public function getSettings(): arrayReturn expressions (including local callbacks): $this->settings.
Implementation, validation guards and interaction order
public function getSettings(): array
{
return $this->settings;
}public function getSetting(string $name): ?SettingModel| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$name |
string $name |
Named key/label selected by this API; its exact scope is shown by the implementation trace. |
Return expressions (including local callbacks): $setting; null.
Implementation, validation guards and interaction order
public function getSetting(string $name): ?SettingModel
{
foreach ($this->settings as $setting) {
if ($setting->getName() === $name) {
return $setting;
}
}
return null;
}public function createSetting(int $package_id, string $name, string $value, int $perm, string $value_type = "text", string $category = "Miscellaneous"): int| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$package_id |
int $package_id |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
$name |
string $name |
Named key/label selected by this API; its exact scope is shown by the implementation trace. |
$value |
string $value |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
$perm |
int $perm |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
$value_type |
string $value_type = "text" |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
$category |
string $category = "Miscellaneous" |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
Return expressions (including local callbacks): 0; $this->database->table("awt_setting")->insert([ "package_id" => $package_id, "name" => $name, "value" => $value, "value_type" => $value_type, "category" => $category, "required_permission_level" => $perm ])->executeInsert().
Implementation, validation guards and interaction order
public function createSetting(int $package_id, string $name, string $value, int $perm, string $value_type = "text", string $category = "Miscellaneous"): int
{
$res = $this->database->table("awt_setting")->select(["id"])->where(["package_id" => $package_id, "name" => $name])->get();
if($res !== null && count($res) > 0)
return 0;
return $this->database->table("awt_setting")->insert([
"package_id" => $package_id,
"name" => $name,
"value" => $value,
"value_type" => $value_type,
"category" => $category,
"required_permission_level" => $perm
])->executeInsert();
}AWT Framework Wiki · Home · Installation Guide · Developer Guide · Framework Internals
Philosophy · Architecture · Known discrepancies · Verification
Installation Guide
Developer Guide
- Learning sequence
- First package
- Package structure
- Lifecycle
- Runtimes
- Events and objects
- Routing and controllers
- Views and resources
- Database and models
- Storage and caching
- Configuration and CLI
- Responses and errors
- Extension points
Framework Internals
- Architecture
- Bootstrap
- Packages
- Runtime
- Events and context
- Objects
- HTTP routing and controllers
- Rendering
- Blade integration
- Database
- Models
- Storage and caching
- Settings
- CLI
- Identity and sessions
- Responses
- Errors
- Complete source inventory
Documentation notes