public function addRootInstallerDescriptor(InstallerDescriptor $descriptor)
{
$this->assertInstallersLoaded();
$name = $descriptor->getName();
$previouslySetInRoot = isset($this->rootInstallerDescriptors[$name]);
$previousInstaller = $previouslySetInRoot ? $this->rootInstallerDescriptors[$name] : null;
if (isset($this->installerDescriptors[$name]) && !$previouslySetInRoot) {
throw new RuntimeException(sprintf('An installer with the name "%s" exists already.', $name));
}
try {
$this->installerDescriptors[$name] = $descriptor;
$this->rootInstallerDescriptors[$name] = $descriptor;
$this->persistInstallersData();
} catch (Exception $e) {
if ($previouslySetInRoot) {
$this->installerDescriptors[$name] = $previousInstaller;
$this->rootInstallerDescriptors[$name] = $previousInstaller;
} else {
unset($this->installerDescriptors[$name]);
unset($this->rootInstallerDescriptors[$name]);
}
throw $e;
}
}