Added ability to specify compatibility in hotfix
This commit is contained in:
@ -10,7 +10,10 @@ use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
||||
use Symfony\Component\Console\Question\ChoiceQuestion;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
|
||||
use NoccyLabs\Hotfix\Hotfix\Loader;
|
||||
use NoccyLabs\Hotfix\System\Facts;
|
||||
|
||||
|
||||
class ApplyCommand extends Command
|
||||
{
|
||||
@ -64,6 +67,28 @@ class ApplyCommand extends Command
|
||||
} else {
|
||||
$output->writeln("<fg=red;options=bold>Warning: Hotfix is not signed or signature not valid!</fg=red;options=bold>");
|
||||
}
|
||||
|
||||
$requires = $hotfix->getRequirements();
|
||||
if (count($requires)>0) {
|
||||
$engine = new ExpressionLanguage();
|
||||
$facts = Facts::getSystemFacts()->getFacts();
|
||||
while (true) {
|
||||
$expr = array_shift($requires);
|
||||
$ret = $engine->evaluate($expr, $facts);
|
||||
if ($ret) {
|
||||
//$output->writeln("<fg=green;options=bold>Hotfix is compatible with the current distribution</>");
|
||||
break;
|
||||
}
|
||||
if (count($requires)==0) {
|
||||
$output->writeln("<error>Error: This hotfix it not compatible with the current distribution</>");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//} else {
|
||||
//$output->writeln("<fg=green;options=bold>Hotfix indicates universal compatibility.</>");
|
||||
}
|
||||
|
||||
|
||||
$output->writeln("");
|
||||
$output->writeln(" Hotfix: <fg=yellow;options=bold>".$hotfix->getName()."</fg=yellow;options=bold>");
|
||||
$output->writeln(" Author: <comment>".$hotfix->getAuthor()."</comment>");
|
||||
|
Reference in New Issue
Block a user