public addConflict ( Puli\Manager\Api\Repository\PathConflict $conflict ) | ||
$conflict | Puli\Manager\Api\Repository\PathConflict | The conflict to be added. |
public function addConflict(PathConflict $conflict)
{
if (null === $this->state) {
throw new NotLoadedException('The mapping is not loaded.');
}
if (!Path::isBasePath($this->repositoryPath, $conflict->getRepositoryPath())) {
throw new InvalidArgumentException(sprintf('The conflicting path %s is not within the path %s of the ' . 'mapping.', $conflict->getRepositoryPath(), $this->repositoryPath));
}
$repositoryPath = $conflict->getRepositoryPath();
$previousConflict = isset($this->conflicts[$repositoryPath]) ? $this->conflicts[$repositoryPath] : null;
if ($previousConflict === $conflict) {
return;
}
if ($previousConflict) {
$previousConflict->removeMapping($this);
}
$this->conflicts[$repositoryPath] = $conflict;
$conflict->addMapping($this);
$this->refreshState();
}
/** * Adds a path mapping involved in the conflict. * * @param PathMapping $mapping The path mapping to add. * * @throws NotLoadedException If the passed mapping is not loaded. */ public function addMapping(PathMapping $mapping) { if (!$mapping->isLoaded()) { throw new NotLoadedException('The passed mapping must be loaded.'); } $packageName = $mapping->getContainingPackage()->getName(); $previousMapping = isset($this->mappings[$packageName]) ? $this->mappings[$packageName] : null; if ($previousMapping === $mapping) { return; } if ($previousMapping) { $previousMapping->removeConflict($this); } $this->mappings[$packageName] = $mapping; $mapping->addConflict($this); }