Skip to content

Internals Setting Model SettingModel

Stefan Crkvenjakov edited this page Oct 7, 2026 · 1 revision

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.

Imports and dependencies

use model\Model;

SettingModel

Declaration and architectural role

class SettingModel extends Model

Constants, enum cases, traits and properties

Declarations 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 index

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

__construct

Source line 19

public function __construct(int $id, string $package_name, array $data)

Parameters

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");
    }

convertType

Source line 50

private function convertType(): void

State writes: $this->type.

Implementation, validation guards and interaction order
private function convertType(): void
    {
        $this->type = match ($this->type) {
            "text" => "string",
            "number" => "int",
            default => "string",
        };
    }

setValue

Source line 59

public function setValue(mixed $value): self

Parameters

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;
    }

createObjectConstant

Source line 68

public function createObjectConstant(): self

State 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;
    }

getValue

Source line 79

public function getValue(): mixed

Return expressions (including local callbacks): $this->value.

Implementation, validation guards and interaction order
public function getValue(): mixed
    {
        return $this->value;
    }

getName

Source line 84

public function getName(): string

Return expressions (including local callbacks): $this->name.

Implementation, validation guards and interaction order
public function getName(): string
    {
        return $this->name;
    }

getObject

Source line 89

public function getObject(): self

Return expressions (including local callbacks): $this.

Implementation, validation guards and interaction order
public function getObject(): self
    {
        return $this;
    }

Related types

Clone this wiki locally