Rename Requirements to RequirementSet

refs #8508
This commit is contained in:
Johannes Meyer 2015-03-09 09:05:56 +01:00
parent 4badbc660b
commit e80786d63d
5 changed files with 57 additions and 57 deletions

View File

@ -8,7 +8,7 @@ use Icinga\Web\Wizard;
use Icinga\Web\Request;
use Icinga\Module\Setup\Setup;
use Icinga\Module\Setup\SetupWizard;
use Icinga\Module\Setup\Requirements;
use Icinga\Module\Setup\RequirementSet;
use Icinga\Module\Setup\Forms\SummaryPage;
use Icinga\Module\Monitoring\Forms\Setup\WelcomePage;
use Icinga\Module\Monitoring\Forms\Setup\BackendPage;
@ -136,9 +136,9 @@ class MonitoringWizard extends Wizard implements SetupWizard
*/
public function getRequirements()
{
$requirements = new Requirements();
$set = new RequirementSet();
$requirements->add(new PhpModuleRequirement(array(
$set->add(new PhpModuleRequirement(array(
'optional' => true,
'condition' => 'Sockets',
'description' => mt(
@ -148,9 +148,9 @@ class MonitoringWizard extends Wizard implements SetupWizard
)
)));
$idoRequirements = new Requirements(Requirements::MODE_OR);
$mysqlRequirements = new Requirements();
$mysqlRequirements->add(new PhpModuleRequirement(array(
$idoSet = new RequirementSet(RequirementSet::MODE_OR);
$mysqlSet = new RequirementSet();
$mysqlSet->add(new PhpModuleRequirement(array(
'condition' => 'mysql',
'alias' => 'PDO-MySQL',
'description' => mt(
@ -158,7 +158,7 @@ class MonitoringWizard extends Wizard implements SetupWizard
'To access the IDO stored in a MySQL database the PDO-MySQL module for PHP is required.'
)
)));
$mysqlRequirements->add(new ClassRequirement(array(
$mysqlSet->add(new ClassRequirement(array(
'condition' => 'Zend_Db_Adapter_Pdo_Mysql',
'alias' => mt('monitoring', 'Zend database adapter for MySQL'),
'description' => mt(
@ -166,9 +166,9 @@ class MonitoringWizard extends Wizard implements SetupWizard
'The Zend database adapter for MySQL is required to access a MySQL database.'
)
)));
$idoRequirements->merge($mysqlRequirements);
$pgsqlRequirements = new Requirements();
$pgsqlRequirements->add(new PhpModuleRequirement(array(
$idoSet->merge($mysqlSet);
$pgsqlSet = new RequirementSet();
$pgsqlSet->add(new PhpModuleRequirement(array(
'condition' => 'pgsql',
'alias' => 'PDO-PostgreSQL',
'description' => mt(
@ -176,7 +176,7 @@ class MonitoringWizard extends Wizard implements SetupWizard
'To access the IDO stored in a PostgreSQL database the PDO-PostgreSQL module for PHP is required.'
)
)));
$pgsqlRequirements->add(new ClassRequirement(array(
$pgsqlSet->add(new ClassRequirement(array(
'condition' => 'Zend_Db_Adapter_Pdo_Pgsql',
'alias' => mt('monitoring', 'Zend database adapter for PostgreSQL'),
'description' => mt(
@ -184,9 +184,9 @@ class MonitoringWizard extends Wizard implements SetupWizard
'The Zend database adapter for PostgreSQL is required to access a PostgreSQL database.'
)
)));
$idoRequirements->merge($pgsqlRequirements);
$requirements->merge($idoRequirements);
$idoSet->merge($pgsqlSet);
$set->merge($idoSet);
return $requirements;
return $set;
}
}

View File

@ -4,7 +4,7 @@
namespace Icinga\Module\Setup\Forms;
use Icinga\Web\Form;
use Icinga\Module\Setup\Requirements;
use Icinga\Module\Setup\RequirementSet;
/**
* Wizard page to list setup requirements
@ -14,9 +14,9 @@ class RequirementsPage extends Form
/**
* The requirements to list
*
* @var Requirements
* @var RequirementSet
*/
protected $requirements;
protected $set;
/**
* Initialize this page
@ -30,24 +30,24 @@ class RequirementsPage extends Form
/**
* Set the requirements to list
*
* @param Requirements $requirements
* @param RequirementSet $set
*
* @return self
*/
public function setRequirements(Requirements $requirements)
public function setRequirements(RequirementSet $set)
{
$this->requirements = $requirements;
$this->set = $set;
return $this;
}
/**
* Return the requirements to list
*
* @return Requirements
* @return RequirementSet
*/
public function getRequirements()
{
return $this->requirements;
return $this->set;
}
/**
@ -63,6 +63,6 @@ class RequirementsPage extends Form
return false;
}
return $this->requirements->fulfilled();
return $this->set->fulfilled();
}
}

View File

@ -9,7 +9,7 @@ use RecursiveIterator;
/**
* Container to store and handle requirements
*/
class Requirements implements RecursiveIterator
class RequirementSet implements RecursiveIterator
{
/**
* Mode AND (all requirements must met)
@ -59,7 +59,7 @@ class Requirements implements RecursiveIterator
*
* @param int $mode
*
* @return Requirements
* @return RequirementSet
*
* @throws LogicException In case the given mode is invalid
*/
@ -88,7 +88,7 @@ class Requirements implements RecursiveIterator
*
* @param Requirement $requirement The requirement to add
*
* @return Requirements
* @return RequirementSet
*/
public function add(Requirement $requirement)
{
@ -144,14 +144,14 @@ class Requirements implements RecursiveIterator
/**
* Register the given requirements
*
* @param Requirements $requirements The requirements to register
* @param RequirementSet $set The requirements to register
*
* @return Requirements
* @return RequirementSet
*/
public function merge(Requirements $requirements)
public function merge(RequirementSet $set)
{
if ($this->getMode() === static::MODE_OR && $requirements->getMode() === static::MODE_OR) {
foreach ($requirements->getAll() as $requirement) {
if ($this->getMode() === static::MODE_OR && $set->getMode() === static::MODE_OR) {
foreach ($set->getAll() as $requirement) {
if ($requirement instanceof static) {
$this->merge($requirement);
} else {
@ -159,11 +159,11 @@ class Requirements implements RecursiveIterator
}
}
} else {
if ($requirements->getMode() === static::MODE_OR) {
if ($set->getMode() === static::MODE_OR) {
$this->containsMandatoryRequirements = true;
}
$this->requirements[] = $requirements;
$this->requirements[] = $set;
}
return $this;
@ -250,7 +250,7 @@ class Requirements implements RecursiveIterator
/**
* Return the current element in the iteration
*
* @return Requirement|Requirements
* @return Requirement|RequirementSet
*/
public function current()
{

View File

@ -18,7 +18,7 @@ interface SetupWizard
/**
* Return the requirements of this wizard
*
* @return Requirements
* @return RequirementSet
*/
public function getRequirements();
}

View File

@ -357,9 +357,9 @@ class WebWizard extends Wizard implements SetupWizard
*/
public function getRequirements()
{
$requirements = new Requirements();
$set = new RequirementSet();
$requirements->add(new PhpVersionRequirement(array(
$set->add(new PhpVersionRequirement(array(
'condition' => array('>=', '5.3.2'),
'description' => mt(
'setup',
@ -368,7 +368,7 @@ class WebWizard extends Wizard implements SetupWizard
)
)));
$requirements->add(new PhpConfigRequirement(array(
$set->add(new PhpConfigRequirement(array(
'condition' => array('date.timezone', true),
'title' => mt('setup', 'Default Timezone'),
'description' => sprintf(
@ -377,7 +377,7 @@ class WebWizard extends Wizard implements SetupWizard
),
)));
$requirements->add(new OSRequirement(array(
$set->add(new OSRequirement(array(
'optional' => true,
'condition' => 'linux',
'description' => mt(
@ -387,7 +387,7 @@ class WebWizard extends Wizard implements SetupWizard
)
)));
$requirements->add(new PhpModuleRequirement(array(
$set->add(new PhpModuleRequirement(array(
'condition' => 'OpenSSL',
'description' => mt(
'setup',
@ -395,7 +395,7 @@ class WebWizard extends Wizard implements SetupWizard
)
)));
$requirements->add(new PhpModuleRequirement(array(
$set->add(new PhpModuleRequirement(array(
'optional' => true,
'condition' => 'JSON',
'description' => mt(
@ -404,7 +404,7 @@ class WebWizard extends Wizard implements SetupWizard
)
)));
$requirements->add(new PhpModuleRequirement(array(
$set->add(new PhpModuleRequirement(array(
'optional' => true,
'condition' => 'LDAP',
'description' => mt(
@ -413,7 +413,7 @@ class WebWizard extends Wizard implements SetupWizard
)
)));
$requirements->add(new PhpModuleRequirement(array(
$set->add(new PhpModuleRequirement(array(
'optional' => true,
'condition' => 'INTL',
'description' => mt(
@ -424,7 +424,7 @@ class WebWizard extends Wizard implements SetupWizard
)));
// TODO(6172): Remove this requirement once we do not ship dompdf with Icinga Web 2 anymore
$requirements->add(new PhpModuleRequirement(array(
$set->add(new PhpModuleRequirement(array(
'optional' => true,
'condition' => 'DOM',
'description' => mt(
@ -433,7 +433,7 @@ class WebWizard extends Wizard implements SetupWizard
)
)));
$requirements->add(new PhpModuleRequirement(array(
$set->add(new PhpModuleRequirement(array(
'optional' => true,
'condition' => 'GD',
'description' => mt(
@ -442,7 +442,7 @@ class WebWizard extends Wizard implements SetupWizard
)
)));
$requirements->add(new PhpModuleRequirement(array(
$set->add(new PhpModuleRequirement(array(
'optional' => true,
'condition' => 'Imagick',
'description' => mt(
@ -451,8 +451,8 @@ class WebWizard extends Wizard implements SetupWizard
)
)));
$mysqlRequirements = new Requirements();
$mysqlRequirements->add(new PhpModuleRequirement(array(
$mysqlSet = new RequirementSet();
$mysqlSet->add(new PhpModuleRequirement(array(
'optional' => true,
'condition' => 'mysql',
'alias' => 'PDO-MySQL',
@ -461,7 +461,7 @@ class WebWizard extends Wizard implements SetupWizard
'To store users or preferences in a MySQL database the PDO-MySQL module for PHP is required.'
)
)));
$mysqlRequirements->add(new ClassRequirement(array(
$mysqlSet->add(new ClassRequirement(array(
'optional' => true,
'condition' => 'Zend_Db_Adapter_Pdo_Mysql',
'alias' => mt('setup', 'Zend database adapter for MySQL'),
@ -470,10 +470,10 @@ class WebWizard extends Wizard implements SetupWizard
'The Zend database adapter for MySQL is required to access a MySQL database.'
)
)));
$requirements->merge($mysqlRequirements);
$set->merge($mysqlSet);
$pgsqlRequirements = new Requirements();
$pgsqlRequirements->add(new PhpModuleRequirement(array(
$pgsqlSet = new RequirementSet();
$pgsqlSet->add(new PhpModuleRequirement(array(
'optional' => true,
'condition' => 'pgsql',
'alias' => 'PDO-PostgreSQL',
@ -482,7 +482,7 @@ class WebWizard extends Wizard implements SetupWizard
'To store users or preferences in a PostgreSQL database the PDO-PostgreSQL module for PHP is required.'
)
)));
$pgsqlRequirements->add(new ClassRequirement(array(
$pgsqlSet->add(new ClassRequirement(array(
'optional' => true,
'condition' => 'Zend_Db_Adapter_Pdo_Pgsql',
'alias' => mt('setup', 'Zend database adapter for PostgreSQL'),
@ -491,9 +491,9 @@ class WebWizard extends Wizard implements SetupWizard
'The Zend database adapter for PostgreSQL is required to access a PostgreSQL database.'
)
)));
$requirements->merge($pgsqlRequirements);
$set->merge($pgsqlSet);
$requirements->add(new ConfigDirectoryRequirement(array(
$set->add(new ConfigDirectoryRequirement(array(
'condition' => Icinga::app()->getConfigDir(),
'description' => mt(
'setup',
@ -503,9 +503,9 @@ class WebWizard extends Wizard implements SetupWizard
)));
foreach ($this->getWizards() as $wizard) {
$requirements->merge($wizard->getRequirements());
$set->merge($wizard->getRequirements());
}
return $requirements;
return $set;
}
}