Repository navigation
Internals Uninstaller PackageUninstaller
Framework Internals · Subsystem overview · Developer guide
Source: awt_src/classes/uninstaller/PackageUninstaller.php · Snapshot 8411f4287706.
Uninstallation deletes the package record before attempting each cleanup collaborator. Failures are collected; cleanup continues and can leave partial state.
use database\creator\table\TableRegistry;
use database\creator\table\TableSchemaProvider;
use database\DatabaseManager;
use database\provider\DatabaseProvider;
use package\facade\PackageFacade;
use uninstaller\cleanup\PackageFilesCleanup;
use uninstaller\cleanup\ResourceCleanup;
use uninstaller\cleanup\StorageCleanup;
use uninstaller\cleanup\TableCleanup;
use uninstaller\interfaces\IPackageCleanup;
use uninstaller\interfaces\IPackageUninstaller;
use vfs\storage\services\LocalFileSystemService;
use vfs\storage\StorageRepository;class PackageUninstaller implements IPackageUninstallerSource description (behavioral corrections are recorded in Known discrepancies):
Self-wiring facade. Package and dependency records are left to the caller. Every cleanup is attempted; false means getErrors() contains failures.
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 |
|---|---|---|
| $errors | private array $errors = []; |
Used by uninstall(), getErrors(). |
| $steps | private array $steps; |
Used by __construct(), uninstall(). |
| $packageFacade | private PackageFacade $packageFacade; |
Used by __construct(), uninstall(). |
| Method | Signature |
|---|---|
| __construct | public function __construct( ?array $steps = null, ?PackageFacade $packageFacade = null, string $packageRoot = PACKAGES, ) |
| uninstall | public function uninstall(int $id): bool |
| getErrors | public function getErrors(): array |
public function __construct(
?array $steps = null,
?PackageFacade $packageFacade = null,
string $packageRoot = PACKAGES,
)| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$steps |
?array $steps = null |
Override or extend cleanup collaborators. |
$packageFacade |
?PackageFacade $packageFacade = null |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
$packageRoot |
string $packageRoot = PACKAGES |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
@param IPackageCleanup[]|null $steps Override or extend cleanup collaborators.
State writes: $this->packageFacade, $this->steps.
Explicit exceptions: \InvalidArgumentException. The guards in the implementation below show when each is raised; exceptions from collaborators also propagate unless caught.
Implementation, validation guards and interaction order
/**
* @param IPackageCleanup[]|null $steps Override or extend cleanup collaborators.
*/
public function __construct(
?array $steps = null,
?PackageFacade $packageFacade = null,
string $packageRoot = PACKAGES,
) {
$this->packageFacade = $packageFacade ?? new PackageFacade();
$this->steps = $steps ?? [
new StorageCleanup(new StorageRepository(), new LocalFileSystemService()),
new PackageFilesCleanup($packageRoot),
new ResourceCleanup($packageRoot),
new TableCleanup(new TableRegistry(new DatabaseManager()), new TableSchemaProvider(new DatabaseProvider())),
];
foreach ($this->steps as $step) {
if (!$step instanceof IPackageCleanup) {
throw new \InvalidArgumentException('Cleanup steps must implement IPackageCleanup.');
}
}
}public function uninstall(int $id): bool| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$id |
int $id |
Record or runtime identifier selected by this operation. |
State writes: $this->errors, $this->errors[].
Return expressions (including local callbacks): false; $this->errors === [].
Explicit exceptions: \InvalidArgumentException, \RuntimeException. The guards in the implementation below show when each is raised; exceptions from collaborators also propagate unless caught.
Failure handling catches \Throwable.
Implementation, validation guards and interaction order
public function uninstall(int $id): bool
{
$this->errors = [];
try {
if ($id <= 0) {
throw new \InvalidArgumentException('Package ID must be positive.');
}
$package = $this->packageFacade->getPackageById($id);
$name = $package->getName();
if ($name === '' || $name === '.' || $name === '..' || strpbrk($name, "/\\\0") !== false) {
throw new \InvalidArgumentException('Invalid package directory name.');
}
if (!$package->deleteModel()) throw new \RuntimeException('Failed to delete package record.');
} catch (\Throwable $error) {
$this->errors[] = 'Package lookup: ' . $error->getMessage();
return false;
}
foreach ($this->steps as $step) {
try {
foreach ($step->clean($id, $name) as $error) {
$this->errors[] = get_class($step) . ': ' . $error;
}
} catch (\Throwable $error) {
$this->errors[] = get_class($step) . ': ' . $error->getMessage();
}
}
return $this->errors === [];
}public function getErrors(): arrayReturn expressions (including local callbacks): $this->errors.
Implementation, validation guards and interaction order
public function getErrors(): array
{
return $this->errors;
}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