Repository navigation
Internals Installer Package PackageAssetLinks
Framework Internals · Subsystem overview · Developer guide
Source: awt_src/classes/installer/package/PackageAssetLinks.php · Snapshot 8411f4287706.
Installation validates archives and manifests, moves files, persists metadata, copies data into storage, invokes an optional hook and emits an event. These operations do not form one atomic transaction.
use package\facade\PackageFacade;
use vfs\storage\enums\EOwnerType;
use vfs\storage\interfaces\IStorageRepository;
use vfs\storage\StorageEntry;
use vfs\storage\StorageRepository;final readonly class PackageAssetLinksDeclarations 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 |
|---|---|---|
| Constructor-promoted | private IStorageRepository $storage = new StorageRepository() |
Initialized from the constructor argument; default expression is evaluated when the argument is omitted. |
| Constructor-promoted | private PackageFacade $packages = new PackageFacade() |
Initialized from the constructor argument; default expression is evaluated when the argument is omitted. |
| Method | Signature |
|---|---|
| __construct | public function __construct( private IStorageRepository $storage = new StorageRepository(), private PackageFacade $packages = new PackageFacade(), ) |
| register | public function register(int $packageId, string $storageDirectory, array $manifest): void |
public function __construct(
private IStorageRepository $storage = new StorageRepository(),
private PackageFacade $packages = new PackageFacade(),
);| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$storage |
private IStorageRepository $storage = new StorageRepository() |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
$packages |
private PackageFacade $packages = new PackageFacade() |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
Concrete no-op/default hook: this method performs no work. Override it where the lifecycle or extension contract calls for behavior.
public function register(int $packageId, string $storageDirectory, array $manifest): void| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$packageId |
int $packageId |
Installed package ID used for metadata/schema/storage ownership. |
$storageDirectory |
string $storageDirectory |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
$manifest |
array $manifest |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
Explicit exceptions: \RuntimeException. The guards in the implementation below show when each is raised; exceptions from collaborators also propagate unless caught.
Implementation, validation guards and interaction order
public function register(int $packageId, string $storageDirectory, array $manifest): void
{
$entries = $this->storage->fetchByOwnerTypeAndOwner(EOwnerType::PACKAGE, $packageId);
$links = [];
foreach (['icon', 'preview_image'] as $field) {
$reference = $manifest[$field] ?? null;
if ($reference === null || $reference === '') continue;
$path = rtrim($storageDirectory, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $reference;
$matches = array_values(array_filter($entries, static fn(StorageEntry $entry): bool => $entry->getPath() === $path));
if ($matches === [] && basename($reference) === $reference) {
$matches = array_values(array_filter($entries, static fn(StorageEntry $entry): bool => $entry->getName() === $reference));
}
if (count($matches) > 1) {
throw new \RuntimeException("Ambiguous package {$field}: {$reference}. Use a path relative to the data directory.");
}
if ($matches !== []) $links[$field] = $matches[0]->getUrl();
}
if ($links === []) return;
$package = $this->packages->getPackageById($packageId);
$changed = false;
if (isset($links['icon']) && $package->getIcon() !== $links['icon']) {
$package->setIcon($links['icon']);
$changed = true;
}
if (isset($links['preview_image']) && $package->getPreviewImage() !== $links['preview_image']) {
$package->setPreviewImage($links['preview_image']);
$changed = true;
}
if ($changed && !$package->save()) {
throw new \RuntimeException('Failed to persist package asset links.');
}
}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