Skip to content

Internals Package Model Package

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

package\model\Package

Framework Internals · Subsystem overview · Developer guide

Source: awt_src/classes/package/model/Package.php · Snapshot 8411f4287706.

Package metadata is persisted in awt_package. Manifest readers validate input and package services build installed models; startup executes enabled nonzero-type packages.

Imports and dependencies

use JsonException;
use model\exceptions\ModelCreationException;
use model\exceptions\ModelCRUDException;
use model\Model;
use object\ObjectCollection;
use package\dependency\Dependency;

Package

Declaration and architectural role

class Package 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
$name public string $name = ""; Used by getPackagePath(), getInfo(), getName(), getDependencies(), setName().
$author public ?string $author = null; Used by getInfo(), getAuthor(), setAuthor().
$description public ?string $description = null; Used by getInfo(), getDescription(), setDescription().
$icon public ?string $icon = null; Used by getInfo(), getIcon(), setIcon().
$preview_image public ?string $preview_image = null; Used by getInfo(), getPreviewImage(), setPreviewImage().
$version public string $version = "0.0.0"; Used by getInfo(), getVersion(), getDependencies(), setVersion().
$minimum_awt_version public string $minimum_awt_version = "0.0.0"; Used by getInfo(), getMinimumAwtVersion(), setMinimumAwtVersion().
$maximum_awt_version public ?string $maximum_awt_version = null; Used by getInfo(), getMaximumAwtVersion(), setMaximumAwtVersion().
$type public int $type = -1; Used by getInfo(), getType(), setType().
$system_package public bool $system_package = false; Used by getInfo(), getSystem(), setSystem().
$license public ?string $license = null; Used by getInfo(), getLicense(), setLicense().
$license_url public ?string $license_url = null; Used by getInfo(), getLicenseUrl(), setLicenseUrl().
$dependencies public array|string|null $dependencies = []; Used by getDependencies(), setDependencies(), encodeDependencies(), saveModel(), save().
$dependenciesCollection public ?ObjectCollection $dependenciesCollection; Used by __construct(), getDependenciesCollection(), createDependencyCollection().
Constructor-promoted public function __construct(?int $id = null) Initialized from the constructor argument; default expression is evaluated when the argument is omitted.

Method index

Method Signature
__construct public function __construct(?int $id = null)
getStoreId public function getStoreId(): ?string
setStoreId public function setStoreId(?string $storeId): void
getPackagePath public function getPackagePath(): string
getInfo public function getInfo(): array
getName public function getName(): string
getAuthor public function getAuthor(): ?string
getDescription public function getDescription(): ?string
getIcon public function getIcon(): ?string
getPreviewImage public function getPreviewImage(): ?string
getVersion public function getVersion(): string
getMinimumAwtVersion public function getMinimumAwtVersion(): string
getMaximumAwtVersion public function getMaximumAwtVersion(): ?string
getType public function getType(): int
getSystem public function getSystem(): bool
getLicense public function getLicense(): ?string
getLicenseUrl public function getLicenseUrl(): ?string
getDependencies public function getDependencies(): ?array
getDependenciesCollection public function getDependenciesCollection(): ?ObjectCollection
setName public function setName(string $name): void
setAuthor public function setAuthor(string $author): void
setDescription public function setDescription(?string $description): void
setIcon public function setIcon(?string $icon): void
setPreviewImage public function setPreviewImage(?string $preview_image): void
setVersion public function setVersion(string $version): void
setMinimumAwtVersion public function setMinimumAwtVersion(string $minimum_awt_version): void
setMaximumAwtVersion public function setMaximumAwtVersion(?string $maximum_awt_version): void
setType public function setType(int $type): void
setSystem public function setSystem(bool $system_package): void
setLicense public function setLicense(?string $license): void
setLicenseUrl public function setLicenseUrl(?string $licenseUrl): void
setDependencies public function setDependencies(?array $dependencies): void
createDependencyCollection public function createDependencyCollection(): void
encodeDependencies private function encodeDependencies(): void
saveModel public function saveModel(): int|null
save public function save(): bool

__construct

Source line 41

public function __construct(?int $id = null)

Parameters

Parameter Type, modifiers and default Purpose
$id ?int $id = null Record or runtime identifier selected by this operation.

@throws ModelCreationException

State writes: $this->dependenciesCollection.

Implementation, validation guards and interaction order
/**
     * @throws ModelCreationException
     */
    public function __construct(?int $id = null)
    {
        $this->dependenciesCollection = new ObjectCollection();
        $this->dependenciesCollection->setStrictType(Dependency::class)->setKey("name");
        $this->paramBlackList("dependenciesCollection");

        parent::__construct();

        if ($id !== null) {
            $this->selectByID($id, "awt_package");
        }

    }

getStoreId

Source line 55

public function getStoreId(): ?string

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

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

setStoreId

Source line 56

public function setStoreId(?string $storeId): void

Parameters

Parameter Type, modifiers and default Purpose
$storeId ?string $storeId Operation input; the exact use, validation and propagation are shown in the implementation trace.

State writes: $this->store_id.

Implementation, validation guards and interaction order
public function setStoreId(?string $storeId): void { $this->store_id = $storeId; }

getPackagePath

Source line 57

public function getPackagePath(): string

Return expressions (including local callbacks): PACKAGES . str_replace(' ', '', $this->name).

Implementation, validation guards and interaction order
public function getPackagePath(): string { return PACKAGES . str_replace(' ', '', $this->name); }

getInfo

Source line 58

public function getInfo(): array

Return expressions (including local callbacks): [ 'name' => $this->name, 'description' => $this->description, 'icon' => $this->icon, 'previewImage' => $this->preview_image, 'version' => $this->version, 'minimumAwtVersion' => $this->minimum_awt_version, 'maximumAwtVersion' => $this->maximum_awt_version, 'license' => $this->license, 'licenseUrl' => $this->license_url, 'author' => $this->author, 'system' => $this->system_package, 'type' => $this->system_package ? 'System' : match ($this->type) { 0 => 'System', 1 => 'Plugin', 2 => 'Theme', default => 'Unknown', }, ].

Implementation, validation guards and interaction order
public function getInfo(): array
    {
        return [
            'name' => $this->name, 'description' => $this->description,
            'icon' => $this->icon, 'previewImage' => $this->preview_image,
            'version' => $this->version, 'minimumAwtVersion' => $this->minimum_awt_version,
            'maximumAwtVersion' => $this->maximum_awt_version,
            'license' => $this->license, 'licenseUrl' => $this->license_url,
            'author' => $this->author, 'system' => $this->system_package,
            'type' => $this->system_package ? 'System' : match ($this->type) {
                0 => 'System', 1 => 'Plugin', 2 => 'Theme', default => 'Unknown',
            },
        ];
    }

getName

Source line 74

public function getName(): string

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

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

getAuthor

Source line 79

public function getAuthor(): ?string

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

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

getDescription

Source line 84

public function getDescription(): ?string

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

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

getIcon

Source line 89

public function getIcon(): ?string

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

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

getPreviewImage

Source line 94

public function getPreviewImage(): ?string

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

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

getVersion

Source line 99

public function getVersion(): string

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

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

getMinimumAwtVersion

Source line 104

public function getMinimumAwtVersion(): string

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

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

getMaximumAwtVersion

Source line 109

public function getMaximumAwtVersion(): ?string

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

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

getType

Source line 114

public function getType(): int

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

Implementation, validation guards and interaction order
public function getType(): int
    {
        return $this->type;
    }

getSystem

Source line 119

public function getSystem(): bool

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

Implementation, validation guards and interaction order
public function getSystem(): bool
    {
        return $this->system_package;
    }

getLicense

Source line 124

public function getLicense(): ?string

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

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

getLicenseUrl

Source line 129

public function getLicenseUrl(): ?string

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

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

getDependencies

Source line 134

public function getDependencies(): ?array

State writes: $this->dependencies.

Return expressions (including local callbacks): $this->dependencies = $normalized.

Implementation, validation guards and interaction order
public function getDependencies(): ?array
    {
        $this->dependencies ??= [];
        if (is_string($this->dependencies)) {
            $this->dependencies = json_decode($this->dependencies, true, 512, JSON_THROW_ON_ERROR);
        }
        $normalized = [];
        foreach ($this->dependencies as $data) {
            $dep = Dependency::fromArray($data);
            $normalized[] = ['name' => $dep->name, 'version' => $dep->version, 'url' => $dep->url];
        }
        return $this->dependencies = $normalized;
    }

getDependenciesCollection

Source line 148

public function getDependenciesCollection(): ?ObjectCollection

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

Implementation, validation guards and interaction order
public function getDependenciesCollection(): ?ObjectCollection
    {
        return $this->dependenciesCollection;
    }

setName

Source line 154

public function setName(string $name): void

Parameters

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.

State writes: $this->name.

Implementation, validation guards and interaction order
// Setters
    public function setName(string $name): void
    {
        $this->name = $name;
    }

setAuthor

Source line 159

public function setAuthor(string $author): void

Parameters

Parameter Type, modifiers and default Purpose
$author string $author Operation input; the exact use, validation and propagation are shown in the implementation trace.

State writes: $this->author.

Implementation, validation guards and interaction order
public function setAuthor(string $author): void
    {
        $this->author = $author;
    }

setDescription

Source line 164

public function setDescription(?string $description): void

Parameters

Parameter Type, modifiers and default Purpose
$description ?string $description Operation input; the exact use, validation and propagation are shown in the implementation trace.

State writes: $this->description.

Implementation, validation guards and interaction order
public function setDescription(?string $description): void
    {
        $this->description = $description;
    }

setIcon

Source line 169

public function setIcon(?string $icon): void

Parameters

Parameter Type, modifiers and default Purpose
$icon ?string $icon Operation input; the exact use, validation and propagation are shown in the implementation trace.

State writes: $this->icon.

Implementation, validation guards and interaction order
public function setIcon(?string $icon): void
    {
        $this->icon = $icon;
    }

setPreviewImage

Source line 174

public function setPreviewImage(?string $preview_image): void

Parameters

Parameter Type, modifiers and default Purpose
$preview_image ?string $preview_image Operation input; the exact use, validation and propagation are shown in the implementation trace.

State writes: $this->preview_image.

Implementation, validation guards and interaction order
public function setPreviewImage(?string $preview_image): void
    {
        $this->preview_image = $preview_image;
    }

setVersion

Source line 179

public function setVersion(string $version): void

Parameters

Parameter Type, modifiers and default Purpose
$version string $version Operation input; the exact use, validation and propagation are shown in the implementation trace.

State writes: $this->version.

Implementation, validation guards and interaction order
public function setVersion(string $version): void
    {
        $this->version = $version;
    }

setMinimumAwtVersion

Source line 184

public function setMinimumAwtVersion(string $minimum_awt_version): void

Parameters

Parameter Type, modifiers and default Purpose
$minimum_awt_version string $minimum_awt_version Operation input; the exact use, validation and propagation are shown in the implementation trace.

State writes: $this->minimum_awt_version.

Implementation, validation guards and interaction order
public function setMinimumAwtVersion(string $minimum_awt_version): void
    {
        $this->minimum_awt_version = $minimum_awt_version;
    }

setMaximumAwtVersion

Source line 189

public function setMaximumAwtVersion(?string $maximum_awt_version): void

Parameters

Parameter Type, modifiers and default Purpose
$maximum_awt_version ?string $maximum_awt_version Operation input; the exact use, validation and propagation are shown in the implementation trace.

State writes: $this->maximum_awt_version.

Implementation, validation guards and interaction order
public function setMaximumAwtVersion(?string $maximum_awt_version): void
    {
        $this->maximum_awt_version = $maximum_awt_version;
    }

setType

Source line 194

public function setType(int $type): void

Parameters

Parameter Type, modifiers and default Purpose
$type int $type Expected class/type or enum selection according to the signature.

State writes: $this->type.

Implementation, validation guards and interaction order
public function setType(int $type): void
    {
        $this->type = $type;
    }

setSystem

Source line 199

public function setSystem(bool $system_package): void

Parameters

Parameter Type, modifiers and default Purpose
$system_package bool $system_package Operation input; the exact use, validation and propagation are shown in the implementation trace.

State writes: $this->system_package.

Implementation, validation guards and interaction order
public function setSystem(bool $system_package): void
    {
        $this->system_package = $system_package;
    }

setLicense

Source line 204

public function setLicense(?string $license): void

Parameters

Parameter Type, modifiers and default Purpose
$license ?string $license Operation input; the exact use, validation and propagation are shown in the implementation trace.

State writes: $this->license.

Implementation, validation guards and interaction order
public function setLicense(?string $license): void
    {
        $this->license = $license;
    }

setLicenseUrl

Source line 209

public function setLicenseUrl(?string $licenseUrl): void

Parameters

Parameter Type, modifiers and default Purpose
$licenseUrl ?string $licenseUrl Operation input; the exact use, validation and propagation are shown in the implementation trace.

State writes: $this->license_url.

Implementation, validation guards and interaction order
public function setLicenseUrl(?string $licenseUrl): void
    {
        $this->license_url = $licenseUrl;
    }

setDependencies

Source line 214

public function setDependencies(?array $dependencies): void

Parameters

Parameter Type, modifiers and default Purpose
$dependencies ?array $dependencies Operation input; the exact use, validation and propagation are shown in the implementation trace.

State writes: $this->dependencies.

Implementation, validation guards and interaction order
public function setDependencies(?array $dependencies): void
    {
        if (!is_array($dependencies)) {
            $dependencies = [];
        }


        $this->dependencies = $dependencies;
    }

createDependencyCollection

Source line 225

public function createDependencyCollection(): void

State writes: $this->dependenciesCollection.

Implementation, validation guards and interaction order
public function createDependencyCollection(): void
    {
        $this->dependenciesCollection = new ObjectCollection();
        $this->dependenciesCollection->setStrictType(Dependency::class)->setKey("name");
        foreach ($this->getDependencies() as $dependency) {
            $this->dependenciesCollection->add(Dependency::fromArray($dependency));
        }
    }

encodeDependencies

Source line 237

private function encodeDependencies(): void

@throws JsonException

State writes: $this->dependencies.

Implementation, validation guards and interaction order
/**
     * @throws JsonException
     */
    private function encodeDependencies(): void
    {
        if (is_array($this->dependencies)) {
            $this->dependencies = json_encode($this->dependencies, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
        }
    }

saveModel

Source line 248

public function saveModel(): int|null

@throws ModelCRUDException @throws JsonException

State writes: $this->model_source, $this->dependencies.

Return expressions (including local callbacks): parent::saveModel().

Implementation, validation guards and interaction order
/**
     * @throws ModelCRUDException
     * @throws JsonException
     */
    public function saveModel(): int|null
    {
        $dependencies = $this->getDependencies();
        $this->encodeDependencies();
        $this->model_source = "awt_package";
        try { return parent::saveModel(); }
        finally { $this->dependencies = $dependencies; }
    }

save

Source line 261

public function save(): bool

@throws ModelCRUDException @throws JsonException

State writes: $this->dependencies.

Return expressions (including local callbacks): parent::save().

Implementation, validation guards and interaction order
/**
     * @throws ModelCRUDException
     * @throws JsonException
     */
    public function save(): bool
    {
        $dependencies = $this->getDependencies();
        $this->encodeDependencies();
        try { return parent::save(); }
        finally { $this->dependencies = $dependencies; }
    }

Related types

Clone this wiki locally