/**
  * {@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;
     }
 }
 public function testCheckAllTokensIfNoTokensPassed()
 {
     $this->detector->claim('A', 'package1');
     $this->detector->claim('A', 'package2');
     $conflicts = $this->detector->detectConflicts();
     $this->assertCount(1, $conflicts);
     $this->assertInstanceOf('Puli\\Manager\\Conflict\\PackageConflict', $conflicts[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();
 }
 /**
  * {@inheritdoc}
  */
 public function rollback()
 {
     if ($this->mapping->isLoaded() || !$this->containingPackage) {
         return;
     }
     $this->mapping->load($this->containingPackage, $this->packages);
     $packageName = $this->containingPackage->getName();
     foreach ($this->mapping->listRepositoryPaths() as $repositoryPath) {
         $this->mappings->add($this->mapping);
         $this->conflictDetector->claim($repositoryPath, $packageName);
     }
     // Restore conflicts
     foreach ($this->conflicts as $repositoryPath => $conflict) {
         $conflict->addMappings($this->conflictingMappings[$repositoryPath]);
     }
 }