Repository navigation
Internals Package Model Repository PackageRepository
Framework Internals · Subsystem overview · Developer guide
Source: awt_src/classes/package/model/repository/PackageRepository.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 database\DatabaseManager;
use database\trait\DoNotCache;
use package\model\repository\interfaces\IPackageRepository;class PackageRepository extends DatabaseManager implements IPackageRepositoryDeclarations 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 |
|---|---|---|
| use DoNotCache | use DoNotCache; |
Trait composition. |
| $append | private array $append = [ "model_source" => "awt_package", "id_column" => "id", ]; |
Used by getActive(), getDisabled(), getAll(), getPackage(), getPackageById(). |
| Method | Signature |
|---|---|
| getActive | public function getActive(): array |
| getDisabled | public function getDisabled(): array |
| getAll | public function getAll(): array |
| getPackage | public function getPackage(string $name): ?array |
| getPackageById | public function getPackageById(int $id): ?array |
| setStatus | public function setStatus(int $id, bool $status): bool |
| updatePackage | public function updatePackage(int $id, array $data): bool |
| newPackage | public function newPackage(array $data): ?int |
| manifestData | private function manifestData(array $data): array |
public function getActive(): arrayReturn expressions (including local callbacks): array_map(fn($item) => array_merge($item, $this->append), $results).
Implementation, validation guards and interaction order
public function getActive(): array
{
$results = $this->table('awt_package')->select()->where(["status" => 1])->orderBy("system_package", "DESC")->get();
return array_map(fn($item) => array_merge($item, $this->append), $results);
}public function getDisabled(): arrayReturn expressions (including local callbacks): array_map(fn($item) => array_merge($item, $this->append), $results).
Implementation, validation guards and interaction order
public function getDisabled(): array
{
$results = $this->table('awt_package')->select()->where(["status" => 0])->get();
return array_map(fn($item) => array_merge($item, $this->append), $results);
}public function getAll(): arrayReturn expressions (including local callbacks): array_map(fn($item) => array_merge($item, $this->append), $results).
Implementation, validation guards and interaction order
public function getAll(): array
{
$results = $this->table('awt_package')->select()->where([1 => 1])->get();
return array_map(fn($item) => array_merge($item, $this->append), $results);
}public function getPackage(string $name): ?array| 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): $result ? array_merge($result, $this->append) : null.
Implementation, validation guards and interaction order
public function getPackage(string $name): ?array
{
$result = $this->table('awt_package')->select()->where(["name" => $name])->get()[0] ?? null;
return $result ? array_merge($result, $this->append) : null;
}public function getPackageById(int $id): ?array| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$id |
int $id |
Record or runtime identifier selected by this operation. |
Return expressions (including local callbacks): $result ? array_merge($result, $this->append) : null.
Implementation, validation guards and interaction order
public function getPackageById(int $id): ?array
{
$result = $this->table('awt_package')->select()->where(['id' => $id])->get()[0] ?? null;
return $result ? array_merge($result, $this->append) : null;
}public function setStatus(int $id, bool $status): bool| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$id |
int $id |
Record or runtime identifier selected by this operation. |
$status |
bool $status |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
Return expressions (including local callbacks): $this->table('awt_package')->where(['id' => $id])->update(['status' => (int) $status]).
Implementation, validation guards and interaction order
public function setStatus(int $id, bool $status): bool
{
return $this->table('awt_package')->where(['id' => $id])->update(['status' => (int) $status]);
}public function updatePackage(int $id, array $data): bool| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$id |
int $id |
Record or runtime identifier selected by this operation. |
$data |
array $data |
Input data array or payload; see allowed fields and validation guards below. |
Return expressions (including local callbacks): false; true; $this->table('awt_package')->where(['id' => $id])->update($data).
Implementation, validation guards and interaction order
public function updatePackage(int $id, array $data): bool
{
$data = $this->manifestData($data);
if (!empty($data['system_package'])) $data['status'] = 1;
$existing = $this->getPackageById($id);
if ($existing === null) return false;
$changed = false;
foreach ($data as $key => $value) {
if (!array_key_exists($key, $existing)
|| ($value === null ? $existing[$key] !== null : $existing[$key] === null || (string) $existing[$key] !== (string) $value)) {
$changed = true;
break;
}
}
// MySQL reports zero affected rows when identical metadata is written.
if (!$changed) return true;
return $this->table('awt_package')->where(['id' => $id])->update($data);
}public function newPackage(array $data): ?int| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$data |
array $data |
Input data array or payload; see allowed fields and validation guards below. |
Return expressions (including local callbacks): $this->table('awt_package')->insert($data)->executeInsert().
Implementation, validation guards and interaction order
public function newPackage(array $data): ?int
{
$data = $this->manifestData($data);
$data['status'] = !empty($data['system_package']) ? 1 : 0;
$data['installation_date'] = date('Y-m-d H:i:s');
return $this->table('awt_package')->insert($data)->executeInsert();
}private function manifestData(array $data): array| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$data |
array $data |
Input data array or payload; see allowed fields and validation guards below. |
Return expressions (including local callbacks): $data.
Implementation, validation guards and interaction order
private function manifestData(array $data): array
{
$data = array_intersect_key($data, array_flip([
'name', 'author', 'description', 'icon', 'preview_image', 'version',
'minimum_awt_version', 'maximum_awt_version', 'type', 'system_package',
'license', 'license_url', 'dependencies', 'store_id',
]));
$data['dependencies'] = json_encode($data['dependencies'] ?? [], JSON_THROW_ON_ERROR);
return $data;
}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