private function getEnabledFilesystemPaths($repositoryPath) { // Get a copy so that we can remove the entries that we processed // already $inMappings = $this->mappings->toArray(); $outMappings = array(); $filesystemPaths = array(); $this->filterEnabledMappings($repositoryPath, $inMappings, $outMappings); foreach ($outMappings as $mappingPath => $mappingsByPackage) { foreach ($mappingsByPackage as $packageName => $mapping) { $filesystemPaths[$packageName][$mappingPath] = $mapping->getFilesystemPaths(); } } if (!$filesystemPaths) { return array(); } // Sort primary keys (package names) $sortedNames = $this->overrideGraph->getSortedPackageNames(array_keys($filesystemPaths)); $filesystemPaths = array_replace(array_flip($sortedNames), $filesystemPaths); // Sort secondary keys (repository paths) foreach ($filesystemPaths as $packageName => $pathsByPackage) { ksort($filesystemPaths[$packageName]); } return $filesystemPaths; }
/** * {@inheritdoc} */ public function execute() { // Quit if no mappings exist if (!($packageNames = $this->mappings->getPackageNames())) { return; } $sortedNames = $this->overrideGraph->getSortedPackageNames($packageNames); try { foreach ($sortedNames as $packageName) { foreach ($this->getEnabledMappingsByPackageName($packageName) as $repositoryPath => $mapping) { foreach ($mapping->getFilesystemPaths() as $filesystemPath) { $this->repo->add($repositoryPath, $this->createResource($filesystemPath)); $this->added = true; } } } } catch (Exception $e) { $this->repo->clear(); throw $e; } }
private function getEnabledFilesystemPaths($repositoryPath) { // Get a copy so that we can remove the entries that we processed // already $mappings = $this->mappingsByResource->toArray(); $this->collectEnabledFilesystemPaths($repositoryPath, $mappings, $filesystemPaths); if (!$filesystemPaths) { return array(); } // Sort primary keys (package names) $sortedNames = $this->overrideGraph->getSortedPackageNames(array_keys($filesystemPaths)); $filesystemPaths = array_replace(array_flip($sortedNames), $filesystemPaths); // Sort secondary keys (repository paths) foreach ($filesystemPaths as $packageName => $pathsByPackage) { ksort($filesystemPaths[$packageName]); } return $filesystemPaths; }
/** * @expectedException \RuntimeException */ public function testGetSortedPackagesExpectsValidPackages() { $this->graph->getSortedPackageNames(array('foo')); }