Enhance requirements in InstallCommand

This commit is contained in:
Nicolas Lœuillet 2016-02-23 16:41:38 +01:00
parent 754cb2abc0
commit fc6020b2c8

View file

@ -26,6 +26,14 @@ class InstallCommand extends ContainerAwareCommand
*/ */
protected $defaultOutput; protected $defaultOutput;
/**
* @var array
*/
protected $requirements = [
'pcre',
'DOM',
];
protected function configure() protected function configure()
{ {
$this $this
@ -65,27 +73,18 @@ class InstallCommand extends ContainerAwareCommand
$fulfilled = true; $fulfilled = true;
$label = '<comment>PCRE</comment>'; foreach ($this->requirements as $requirement) {
if (extension_loaded('pcre')) { $label = '<comment>'.strtoupper($requirement).'</comment>';
$status = '<info>OK!</info>'; if (extension_loaded($requirement)) {
$help = ''; $status = '<info>OK!</info>';
} else { $help = '';
$fulfilled = false; } else {
$status = '<error>ERROR!</error>'; $fulfilled = false;
$help = 'You should enabled PCRE extension'; $status = '<error>ERROR!</error>';
$help = 'You should enabled '.$requirement.' extension';
}
$rows[] = array($label, $status, $help);
} }
$rows[] = array($label, $status, $help);
$label = '<comment>DOM</comment>';
if (extension_loaded('DOM')) {
$status = '<info>OK!</info>';
$help = '';
} else {
$fulfilled = false;
$status = '<error>ERROR!</error>';
$help = 'You should enabled DOM extension';
}
$rows[] = array($label, $status, $help);
$table = new Table($this->defaultOutput); $table = new Table($this->defaultOutput);
$table $table