Repository navigation
Internals 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.
use JsonException;
use model\exceptions\ModelCreationException;
use model\exceptions\ModelCRUDException;
use model\Model;
use object\ObjectCollection;
use package\dependency\Dependency;class Package 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 |
|---|---|---|
| $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 | 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 |
public function __construct(?int $id = null)| 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");
}
}public function getStoreId(): ?stringReturn expressions (including local callbacks): $this->store_id.
Implementation, validation guards and interaction order
public function getStoreId(): ?string { return $this->store_id; }public function setStoreId(?string $storeId): void| 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; }public function getPackagePath(): stringReturn 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); }public function getInfo(): arrayReturn 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',
},
];
}public function getName(): stringReturn expressions (including local callbacks): $this->name.
Implementation, validation guards and interaction order
// Getters
public function getName(): string
{
return $this->name;
}public function getAuthor(): ?stringReturn expressions (including local callbacks): $this->author.
Implementation, validation guards and interaction order
public function getAuthor(): ?string
{
return $this->author;
}public function getDescription(): ?stringReturn expressions (including local callbacks): $this->description.
Implementation, validation guards and interaction order
public function getDescription(): ?string
{
return $this->description;
}public function getIcon(): ?stringReturn expressions (including local callbacks): $this->icon.
Implementation, validation guards and interaction order
public function getIcon(): ?string
{
return $this->icon;
}public function getPreviewImage(): ?stringReturn expressions (including local callbacks): $this->preview_image.
Implementation, validation guards and interaction order
public function getPreviewImage(): ?string
{
return $this->preview_image;
}public function getVersion(): stringReturn expressions (including local callbacks): $this->version.
Implementation, validation guards and interaction order
public function getVersion(): string
{
return $this->version;
}public function getMinimumAwtVersion(): stringReturn expressions (including local callbacks): $this->minimum_awt_version.
Implementation, validation guards and interaction order
public function getMinimumAwtVersion(): string
{
return $this->minimum_awt_version;
}public function getMaximumAwtVersion(): ?stringReturn expressions (including local callbacks): $this->maximum_awt_version.
Implementation, validation guards and interaction order
public function getMaximumAwtVersion(): ?string
{
return $this->maximum_awt_version;
}public function getType(): intReturn expressions (including local callbacks): $this->type.
Implementation, validation guards and interaction order
public function getType(): int
{
return $this->type;
}public function getSystem(): boolReturn expressions (including local callbacks): $this->system_package.
Implementation, validation guards and interaction order
public function getSystem(): bool
{
return $this->system_package;
}public function getLicense(): ?stringReturn expressions (including local callbacks): $this->license.
Implementation, validation guards and interaction order
public function getLicense(): ?string
{
return $this->license;
}public function getLicenseUrl(): ?stringReturn expressions (including local callbacks): $this->license_url.
Implementation, validation guards and interaction order
public function getLicenseUrl(): ?string
{
return $this->license_url;
}public function getDependencies(): ?arrayState 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;
}public function getDependenciesCollection(): ?ObjectCollectionReturn expressions (including local callbacks): $this->dependenciesCollection.
Implementation, validation guards and interaction order
public function getDependenciesCollection(): ?ObjectCollection
{
return $this->dependenciesCollection;
}public function setName(string $name): void| 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;
}public function setAuthor(string $author): void| 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;
}public function setDescription(?string $description): void| 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;
}public function setIcon(?string $icon): void| 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;
}public function setPreviewImage(?string $preview_image): void| 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;
}public function setVersion(string $version): void| 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;
}public function setMinimumAwtVersion(string $minimum_awt_version): void| 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;
}public function setMaximumAwtVersion(?string $maximum_awt_version): void| 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;
}public function setType(int $type): void| 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;
}public function setSystem(bool $system_package): void| 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;
}public function setLicense(?string $license): void| 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;
}public function setLicenseUrl(?string $licenseUrl): void| 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;
}public function setDependencies(?array $dependencies): void| 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;
}public function createDependencyCollection(): voidState 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));
}
}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);
}
}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; }
}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; }
}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