Skip to content

Instantly share code, notes, and snippets.

@mneuhaus
Created May 8, 2014 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mneuhaus/929667396056afc16e8a to your computer and use it in GitHub Desktop.
Save mneuhaus/929667396056afc16e8a to your computer and use it in GitHub Desktop.
<?php
/**
* Sets the available packages
*
* @param array $allPackages An array of \TYPO3\Flow\Package\Package objects
* @param array $activePackages An array of \TYPO3\Flow\Package\Package objects
* @return void
*/
public function setPackages(array $allPackages, array $activePackages) {
foreach ($allPackages as $packageKey => $package) {
if (isset($activePackages[$packageKey])) {
if ($package->getAutoloadType() === Package::AUTOLOADER_TYPE_PSR0) {
$this->createNamespaceMapEntry($package->getNamespace(), $package->getClassesPath(), self::MAPPING_TYPE_PSR0);
} else if ($package->getAutoloadType() === Package::AUTOLOADER_TYPE_PSR4) {
$this->createNamespaceMapEntry($package->getNamespace(), $package->getClassesPath(), self::MAPPING_TYPE_PSR4);
}
if ($this->considerTestsNamespace) {
$this->createNamespaceMapEntry($package->getNamespace(), $package->getPackagePath(), self::MAPPING_TYPE_PSR4);
}
} else {
// Remove entries coming from composer for inactive packages.
$this->removeNamespaceMapEntry($package->getNamespace(), $package->getClassesPath());
if ($this->considerTestsNamespace) {
$this->removeNamespaceMapEntry($package->getNamespace(), $package->getPackagePath(), self::MAPPING_TYPE_PSR4);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment