private function mergeDependencies(Version $oldVersion, Version $newVersion) { // Remove all versions that do not exist anymore and update the existing versions: foreach ($oldVersion->getDependencies() as $dependency) { $newDependency = null; foreach ($newVersion->getDependencies() as $tmpDep) { if ($tmpDep->getPackageVersion()->getId() == $dependency->getPackageVersion()->getId()) { $newDependency = $tmpDep; break; } } if (!$newDependency) { $oldVersion->removeDependency($dependency); } } // Add the new versions: foreach ($newVersion->getDependencies() as $dependency) { $oldDependency = null; foreach ($oldVersion->getDependencies() as $tmpDep) { if ($tmpDep->getPackageVersion()->getId() == $dependency->getPackageVersion()->getId()) { $oldDependency = $tmpDep; break; } } if (!$oldDependency) { $oldVersion->addDependency($dependency); } } }
public function getDependencies() { $result = parent::getDependencies(); if (!$this->syncedDependencies) { $this->syncedDependencies = true; $result = $this->pdo->findDependencies($this->getId()); $this->setDependencies($result); } return $result; }