Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function execute()
 {
     if (!$this->repositoryPaths) {
         // Check all paths if none are passed
         $this->repositoryPaths = $this->conflicts->getRepositoryPaths();
     }
     // Mark all as resolved
     foreach ($this->repositoryPaths as $repositoryPath) {
         if ($this->conflicts->has($repositoryPath)) {
             $conflict = $this->conflicts->get($repositoryPath);
             $this->conflicts->remove($repositoryPath);
             $this->removedConflicts[$repositoryPath] = $conflict->getMappings();
             $conflict->resolve();
         }
     }
     $packageConflicts = $this->conflictDetector->detectConflicts($this->repositoryPaths);
     $this->deduplicatePackageConflicts($packageConflicts);
     foreach ($packageConflicts as $packageConflict) {
         $repositoryPath = $packageConflict->getConflictingToken();
         $conflict = new PathConflict($repositoryPath);
         foreach ($packageConflict->getPackageNames() as $packageName) {
             $conflict->addMapping($this->mappingsByResource->get($repositoryPath, $packageName));
         }
         $this->conflicts->add($conflict);
         $this->addedConflicts[] = $repositoryPath;
     }
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function rollback()
 {
     if (!$this->mapping->isLoaded()) {
         return;
     }
     $packageName = $this->containingPackage->getName();
     $this->mappings->remove($this->mapping->getRepositoryPath(), $packageName);
     foreach ($this->mapping->listRepositoryPaths() as $repositoryPath) {
         $this->mappingsByResource->remove($repositoryPath, $packageName);
         $this->conflictDetector->release($repositoryPath, $packageName);
     }
     // Unload after iterating, otherwise the paths are gone
     $this->mapping->unload();
 }
Exemplo n.º 3
0
 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;
 }
Exemplo n.º 4
0
 /**
  * @param string $packageName
  *
  * @return PathMapping[]
  */
 private function getEnabledMappingsByPackageName($packageName)
 {
     $mappingsToAdd = array();
     foreach ($this->mappings->listByPackageName($packageName) as $repositoryPath => $mapping) {
         if ($mapping->isEnabled()) {
             // Remove duplicates
             $mappingsToAdd[$mapping->getRepositoryPath()] = $mapping;
         }
     }
     return $mappingsToAdd;
 }
Exemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function rollback()
 {
     if ($this->mapping->isLoaded() || !$this->containingModule) {
         return;
     }
     $this->mapping->load($this->containingModule, $this->modules);
     $moduleName = $this->containingModule->getName();
     foreach ($this->mapping->listRepositoryPaths() as $repositoryPath) {
         $this->mappings->add($this->mapping);
         $this->conflictDetector->claim($repositoryPath, $moduleName);
     }
     // Restore conflicts
     foreach ($this->conflicts as $repositoryPath => $conflict) {
         $conflict->addMappings($this->conflictingMappings[$repositoryPath]);
     }
 }
Exemplo n.º 6
0
 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;
 }
 private function loadPathMappings()
 {
     $this->overrideGraph = OverrideGraph::forPackages($this->packages);
     $this->conflictDetector = new PackageConflictDetector($this->overrideGraph);
     $this->mappings = new PathMappingCollection();
     $this->mappingsByResource = new PathMappingCollection();
     $this->conflicts = new ConflictCollection();
     // Load mappings
     foreach ($this->packages as $package) {
         foreach ($package->getPackageFile()->getPathMappings() as $mapping) {
             $this->loadPathMapping($mapping, $package)->execute();
         }
     }
     // Scan all paths for conflicts
     $this->updateConflicts($this->mappingsByResource->getRepositoryPaths())->execute();
 }
Exemplo n.º 8
0
 private function loadPathMappings()
 {
     $this->overrideGraph = DependencyGraph::forModules($this->modules);
     $this->conflictDetector = new ModuleConflictDetector($this->overrideGraph);
     $this->mappings = new PathMappingCollection();
     $this->mappingsByResource = new PathMappingCollection();
     $this->conflicts = new ConflictCollection();
     // Load mappings
     foreach ($this->modules as $module) {
         if (null === $module->getModuleFile()) {
             continue;
         }
         foreach ($module->getModuleFile()->getPathMappings() as $mapping) {
             $this->loadPathMapping($mapping, $module)->execute();
         }
     }
     // Scan all paths for conflicts
     $this->updateConflicts($this->mappingsByResource->getRepositoryPaths())->execute();
 }