Repository navigation
Internals Setting Model SettingModel
Framework Internals · Subsystem overview · Developer guide
Source: awt_src/classes/setting/model/SettingModel.php · Snapshot 8411f4287706.
Database-backed settings are initialized as named SettingModel constants and retrieved through Config.
use model\Model;class SettingModel extends ModelDeclarations 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 |
|---|---|---|
| $id | public int $id; |
Used by __construct(), setValue(). |
| $package_id | public int $package_id; |
Used by __construct(). |
| $package_name | public string $package_name; |
Used by __construct(), createObjectConstant(). |
| $name | public string $name; |
Used by __construct(), createObjectConstant(), getName(). |
| $value | public mixed $value; |
Used by __construct(), setValue(), getValue(). |
| $value_type | public string $value_type; |
Used by __construct(). |
| $category | public string $category; |
Used by __construct(). |
| $constName | public ?string $constName = null; |
Used by createObjectConstant(). |
| $required_permission_level | public int $required_permission_level = 1; |
Used by __construct(). |
| Constructor-promoted | public function __construct(int $id |
Initialized from the constructor argument; default expression is evaluated when the argument is omitted. |
| Method | Signature |
|---|---|
| __construct | public function __construct(int $id, string $package_name, array $data) |
| convertType | private function convertType(): void |
| setValue | public function setValue(mixed $value): self |
| createObjectConstant | public function createObjectConstant(): self |
| getValue | public function getValue(): mixed |
| getName | public function getName(): string |
| getObject | public function getObject(): self |
public function __construct(int $id, string $package_name, array $data)| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$id |
int $id |
Record or runtime identifier selected by this operation. |
$package_name |
string $package_name |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
$data |
array $data |
Input data array or payload; see allowed fields and validation guards below. |
State writes: $this->model_source, $this->model_id, $this->id_column, $this->id, $this->name, $this->value, $this->category, $this->package_id, $this->value_type, $this->required_permission_level, $this->package_name.
Implementation, validation guards and interaction order
public function __construct(int $id, string $package_name, array $data)
{
parent::__construct();
$this->model_source = "awt_setting";
$this->model_id = $id;
$this->id_column = "id";
$this->id = $id;
$this->name = $data["name"];
$this->value = $data["value"];
$this->category = $data["category"];
$this->package_id = $data["package_id"];
$this->value_type = $data["value_type"];
$this->required_permission_level = $data["required_permission_level"];
$this->package_name = $package_name;
$this->paramBlackList("constName");
$this->paramBlackList("type");
$this->paramBlackList("package_name");
}private function convertType(): voidState writes: $this->type.
Implementation, validation guards and interaction order
private function convertType(): void
{
$this->type = match ($this->type) {
"text" => "string",
"number" => "int",
default => "string",
};
}public function setValue(mixed $value): self| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$value |
mixed $value |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
State writes: $this->value.
Return expressions (including local callbacks): $this.
Implementation, validation guards and interaction order
public function setValue(mixed $value): self
{
$this->value = $value;
$this->table("awt_setting")->where(["id" => $this->id])->update(["value" => $value]);
return $this;
}public function createObjectConstant(): selfState writes: $this->constName.
Return expressions (including local callbacks): $this.
External effects include define.
Implementation, validation guards and interaction order
public function createObjectConstant(): self
{
$this->constName = strtoupper(str_replace(" ", "_", strtoupper($this->package_name)) . "_" . str_replace(" ", "_", strtoupper($this->name)));
if (!defined($this->constName)) {
define("SETT_" . $this->constName, $this->getObject());
}
return $this;
}public function getValue(): mixedReturn expressions (including local callbacks): $this->value.
Implementation, validation guards and interaction order
public function getValue(): mixed
{
return $this->value;
}public function getName(): stringReturn expressions (including local callbacks): $this->name.
Implementation, validation guards and interaction order
public function getName(): string
{
return $this->name;
}public function getObject(): selfReturn expressions (including local callbacks): $this.
Implementation, validation guards and interaction order
public function getObject(): self
{
return $this;
}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