setName("apply");
$this->setDescription("Apply a hotfix from a file or the Internet");
$this->addOption("insecure", "I", InputOption::VALUE_NONE, "Disable signature checks. Don't use unless you know what you are doing!");
$this->addArgument("hotfix", InputArgument::OPTIONAL, "The identifier, path or filename of the hotfix");
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->output = $output;
$fix = $input->getArgument("hotfix");
$insecure = $input->getOption("insecure");
$output->writeln("Reading hotfix {$fix}...");
$loader = new Loader();
try {
$hotfix = $loader->load($fix, $insecure);
} catch (\Exception $e) {
$output->writeln("Error: ".$e->getMessage()."");
return;
}
$output->writeln("");
if (($signer = $hotfix->getSignedBy())) {
$output->writeln("Hotfix has good signature by {$signer}");
} else {
$output->writeln("Warning: Hotfix is not signed or signature not valid!");
}
$output->writeln("");
$output->writeln(" Hotfix: ".$hotfix->getName()."");
$output->writeln(" Author: ".$hotfix->getAuthor()."");
$output->writeln(" Info:");
$info = explode("\n",wordwrap(trim($hotfix->getInfo()), 70));
foreach ($info as $line) {
$output->writeln(" | {$line}");
}
$output->writeln("");
$helper = $this->getHelper("question");
$question = new ConfirmationQuestion("Do you want to apply this hotfix? [y/N] ", false);
if (!$helper->ask($input, $output, $question)) {
return;
}
$output->writeln("\nApplying hotfix...\n");
try {
$hotfix->apply();
} catch (\Exception $e) {
$output->writeln("\nError: ".$e->getMessage()."");
}
$output->writeln("\nHotfix applied successfully");
}
}