protected function scanAvailablePackages($previousPackageStatesConfiguration)
{
$recoveredStateByPackage = $this->recoverStateFromConfiguration($previousPackageStatesConfiguration);
$newPackageStatesConfiguration = ['packages' => []];
$inactivePackages = [];
try {
$globalComposerManifest = ComposerUtility::getComposerManifest(FLOW_PATH_ROOT);
$inactivePackages = isset($globalComposerManifest['extra']['neos']['default-disabled-packages']) && is_array($globalComposerManifest['extra']['neos']['default-disabled-packages']) ? $globalComposerManifest['extra']['neos']['default-disabled-packages'] : [];
} catch (MissingPackageManifestException $exception) {
// TODO: We should probably throw an exception here and warn about the missing composer.json, but on production machines it might be missing...
}
foreach ($this->findComposerPackagesInPath($this->packagesBasePath) as $packagePath) {
$composerManifest = ComposerUtility::getComposerManifest($packagePath);
if (!isset($composerManifest['name'])) {
throw new InvalidConfigurationException(sprintf('A package composer.json was found at "%s" that contained no "name".', $packagePath), 1445933572);
}
$packageKey = $this->getPackageKeyFromManifest($composerManifest, $packagePath);
$this->composerNameToPackageKeyMap[strtolower($composerManifest['name'])] = $packageKey;
$state = in_array($composerManifest['name'], $inactivePackages, true) ? self::PACKAGE_STATE_INACTIVE : self::PACKAGE_STATE_ACTIVE;
if (isset($recoveredStateByPackage[$composerManifest['name']])) {
$state = $recoveredStateByPackage[$composerManifest['name']];
}
$packageInActivePackagesFolder = true;
if (strpos($packagePath, Files::concatenatePaths([$this->packagesBasePath, self::INACTIVE_PACKAGES_FOLDER])) === 0) {
$packageInActivePackagesFolder = false;
$state = self::PACKAGE_STATE_INACTIVE;
}
$packageConfiguration = $this->preparePackageStateConfiguration($packageKey, $packagePath, $composerManifest, $state);
$newPackageStatesConfiguration['packages'][$composerManifest['name']] = $packageConfiguration;
if ($state === self::PACKAGE_STATE_INACTIVE && $packageInActivePackagesFolder && is_dir($packagePath)) {
$newPackageStatesConfiguration['packages'][$composerManifest['name']]['packagePath'] = $this->buildInactivePackageRelativePath($packagePath);
$this->movePackageToDeactivatedPackages($packagePath);
}
}
return $newPackageStatesConfiguration;
}