/** * {@inheritdoc} */ public function rollback() { if ($this->previousMapping) { $this->rootPackageFile->addPathMapping($this->previousMapping); } else { $this->rootPackageFile->removePathMapping($this->mapping->getRepositoryPath()); } }
/** * {@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 execute() { if (!$this->mapping->isLoaded()) { return; } $this->containingModule = $this->mapping->getContainingModule(); // Remember the conflicts that will be adjusted during unload() foreach ($this->mapping->getConflicts() as $conflict) { $this->conflicts[$conflict->getRepositoryPath()] = $conflict; $this->conflictingMappings[$conflict->getRepositoryPath()] = $conflict->getMappings(); } $moduleName = $this->containingModule->getName(); $this->mappings->remove($this->mapping->getRepositoryPath(), $moduleName); foreach ($this->mapping->listRepositoryPaths() as $repositoryPath) { $this->mappingsByResource->remove($repositoryPath, $moduleName); $this->conflictDetector->release($repositoryPath, $moduleName); } // Unload after iterating, otherwise the paths are gone $this->mapping->unload(); }
/** * {@inheritdoc} */ public function addRootPathMapping(PathMapping $mapping, $flags = 0) { Assert::integer($flags, 'The argument $flags must be a boolean.'); $this->assertMappingsLoaded(); if (!($flags & self::OVERRIDE) && $this->rootPackageFile->hasPathMapping($mapping->getRepositoryPath())) { throw DuplicatePathMappingException::forRepositoryPath($mapping->getRepositoryPath(), $this->rootPackage->getName()); } $tx = new Transaction(); try { $syncOp = $this->syncRepositoryPath($mapping->getRepositoryPath()); $syncOp->takeSnapshot(); $tx->execute($this->loadPathMapping($mapping, $this->rootPackage)); if (!($flags & self::IGNORE_FILE_NOT_FOUND)) { $this->assertNoLoadErrors($mapping); } $tx->execute($this->updateConflicts($mapping->listRepositoryPaths())); $tx->execute($this->overrideConflictingPackages($mapping)); $tx->execute($this->updateConflicts()); $tx->execute($this->addPathMappingToPackageFile($mapping)); $tx->execute($syncOp); $this->saveRootPackageFile(); $tx->commit(); } catch (Exception $e) { $tx->rollback(); throw $e; } }
/** * Adds a path mapping. * * @param PathMapping $mapping The path mapping. */ public function addPathMapping(PathMapping $mapping) { $this->pathMappings[$mapping->getRepositoryPath()] = $mapping; ksort($this->pathMappings); }
private function mappingsEqual(PathMapping $mapping1, PathMapping $mapping2) { return $mapping1->getRepositoryPath() === $mapping2->getRepositoryPath() && $mapping1->getPathReferences() === $mapping2->getPathReferences(); }
private function mappingsEqual(PathMapping $mapping1, PathMapping $mapping2) { if ($mapping1->getRepositoryPath() !== $mapping2->getRepositoryPath()) { return false; } if ($mapping1->getPathReferences() !== $mapping2->getPathReferences()) { return false; } return true; }