Neos\Flow\Command\PackageCommandController::listCommand PHP Method

listCommand() public method

Lists all locally available packages. Displays the package key, version and package title and its state – active or inactive.
public listCommand ( boolean $loadingOrder = false ) : string
$loadingOrder boolean The returned packages are ordered by their loading order.
return string The list of packages
    public function listCommand($loadingOrder = false)
    {
        $activePackages = [];
        $inactivePackages = [];
        $frozenPackages = [];
        $longestPackageKey = 0;
        $freezeSupported = $this->bootstrap->getContext()->isDevelopment();
        foreach ($this->packageManager->getAvailablePackages() as $packageKey => $package) {
            if (strlen($packageKey) > $longestPackageKey) {
                $longestPackageKey = strlen($packageKey);
            }
            if ($this->packageManager->isPackageActive($packageKey)) {
                $activePackages[$packageKey] = $package;
            } else {
                $inactivePackages[$packageKey] = $package;
            }
            if ($this->packageManager->isPackageFrozen($packageKey)) {
                $frozenPackages[$packageKey] = $package;
            }
        }
        if ($loadingOrder === false) {
            ksort($activePackages);
            ksort($inactivePackages);
        }
        $this->outputLine('ACTIVE PACKAGES:');
        /** @var PackageInterface $package */
        foreach ($activePackages as $package) {
            $frozenState = $freezeSupported && isset($frozenPackages[$package->getPackageKey()]) ? '* ' : '  ';
            $this->outputLine(' ' . str_pad($package->getPackageKey(), $longestPackageKey + 3) . $frozenState . str_pad($package->getInstalledVersion(), 15));
        }
        if (count($inactivePackages) > 0) {
            $this->outputLine();
            $this->outputLine('INACTIVE PACKAGES:');
            foreach ($inactivePackages as $package) {
                $frozenState = isset($frozenPackages[$package->getPackageKey()]) ? '* ' : '  ';
                $this->outputLine(' ' . str_pad($package->getPackageKey(), $longestPackageKey + 3) . $frozenState . str_pad($package->getInstalledVersion(), 15));
            }
        }
        if (count($frozenPackages) > 0 && $freezeSupported) {
            $this->outputLine();
            $this->outputLine(' * frozen package');
        }
    }