Skip to content

Internals Package Facade PackageFacade

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

package\facade\PackageFacade

Framework Internals · Subsystem overview · Developer guide

Source: awt_src/classes/package/facade/PackageFacade.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 package\model\InstalledPackage;
use package\model\repository\interfaces\IPackageRepository;
use package\model\repository\PackageRepository;
use package\model\service\interface\IPackageService;
use package\model\service\PackageService;

PackageFacade

Declaration and architectural role

class PackageFacade

Source description (behavioral corrections are recorded in Known discrepancies):

PackageFacade

Handles installed package database operations.

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
$repository private IPackageRepository $repository; Used by __construct(), getRepository().
$service private IPackageService $service; Used by __construct(), getService(), getPackage(), getPackageById(), getInstalled(), enablePackage(), disablePackage(), getActive(), getDisabled().
Constructor-promoted public function __construct(?IPackageRepository $repository = null) Initialized from the constructor argument; default expression is evaluated when the argument is omitted.

Method index

Method Signature
__construct public function __construct(?IPackageRepository $repository = null)
getService public function getService(): IPackageService
getRepository public function getRepository(): IPackageRepository
getPackage public function getPackage(string $name): ?InstalledPackage
getPackageById public function getPackageById(int $id): InstalledPackage
getInstalled public function getInstalled(): array
enablePackage public function enablePackage(int $id): void
disablePackage public function disablePackage(int $id): void
removePackage public function removePackage(int $id, bool $purge = false): void
getActive public function getActive(): array
getDisabled public function getDisabled(): array

__construct

Source line 22

public function __construct(?IPackageRepository $repository = null)

Parameters

Parameter Type, modifiers and default Purpose
$repository ?IPackageRepository $repository = null Operation input; the exact use, validation and propagation are shown in the implementation trace.

State writes: $this->repository, $this->service.

Implementation, validation guards and interaction order
public function __construct(?IPackageRepository $repository = null)
    {
        $this->repository = $repository ?? new PackageRepository();
        $this->service = new PackageService($this->repository);
    }

getService

Source line 28

public function getService(): IPackageService

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

Implementation, validation guards and interaction order
public function getService(): IPackageService
    {
        return $this->service;
    }

getRepository

Source line 33

public function getRepository(): IPackageRepository

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

Implementation, validation guards and interaction order
public function getRepository(): IPackageRepository
    {
        return $this->repository;
    }

getPackage

Source line 38

public function getPackage(string $name): ?InstalledPackage

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.

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

Implementation, validation guards and interaction order
public function getPackage(string $name): ?InstalledPackage
    {
        return $this->service->getPackage($name);
    }

getPackageById

Source line 43

public function getPackageById(int $id): InstalledPackage

Parameters

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

Return expressions (including local callbacks): $this->service->getPackageById($id) ?? throw new \OutOfBoundsException("Package with ID {$id} not found.").

Explicit exceptions: \OutOfBoundsException. 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 getPackageById(int $id): InstalledPackage
    {
        return $this->service->getPackageById($id) ?? throw new \OutOfBoundsException("Package with ID {$id} not found.");
    }

getInstalled

Source line 48

public function getInstalled(): array

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

Implementation, validation guards and interaction order
public function getInstalled(): array { return $this->service->getInstalled(); }

enablePackage

Source line 49

public function enablePackage(int $id): void

Parameters

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

Computes or delegates the operation shown below; no explicit receiver property assignment or throw occurs in this method.

Implementation, validation guards and interaction order
public function enablePackage(int $id): void { $this->service->enablePackage($id); }

disablePackage

Source line 50

public function disablePackage(int $id): void

Parameters

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

Computes or delegates the operation shown below; no explicit receiver property assignment or throw occurs in this method.

Implementation, validation guards and interaction order
public function disablePackage(int $id): void { $this->service->disablePackage($id); }

removePackage

Source line 53

public function removePackage(int $id, bool $purge = false): void

Parameters

Parameter Type, modifiers and default Purpose
$id int $id Record or runtime identifier selected by this operation.
$purge bool $purge = false Operation input; the exact use, validation and propagation are shown in the implementation trace.

Remove code and resource records; purge also removes owned storage and tables.

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
/** Remove code and resource records; purge also removes owned storage and tables. */
    public function removePackage(int $id, bool $purge = false): void
    {
        $steps = $purge ? null : [
            new \uninstaller\cleanup\PackageFilesCleanup(PACKAGES),
            new \uninstaller\cleanup\ResourceCleanup(PACKAGES),
        ];
        $uninstaller = new \uninstaller\PackageUninstaller($steps, $this);
        if (!$uninstaller->uninstall($id)) {
            throw new \RuntimeException(implode("\n", $uninstaller->getErrors()));
        }
    }

getActive

Source line 65

public function getActive(): array

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

Implementation, validation guards and interaction order
public function getActive(): array
    {
        return $this->service->getActive();
    }

getDisabled

Source line 70

public function getDisabled(): array

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

Implementation, validation guards and interaction order
public function getDisabled(): array
    {
        return $this->service->getDisabled();
    }

Related types

Clone this wiki locally