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

View File

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

View File

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

View File

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

View File

@ -357,9 +357,9 @@ class WebWizard extends Wizard implements SetupWizard
*/ */
public function getRequirements() public function getRequirements()
{ {
$requirements = new Requirements(); $set = new RequirementSet();
$requirements->add(new PhpVersionRequirement(array( $set->add(new PhpVersionRequirement(array(
'condition' => array('>=', '5.3.2'), 'condition' => array('>=', '5.3.2'),
'description' => mt( 'description' => mt(
'setup', '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), 'condition' => array('date.timezone', true),
'title' => mt('setup', 'Default Timezone'), 'title' => mt('setup', 'Default Timezone'),
'description' => sprintf( 'description' => sprintf(
@ -377,7 +377,7 @@ class WebWizard extends Wizard implements SetupWizard
), ),
))); )));
$requirements->add(new OSRequirement(array( $set->add(new OSRequirement(array(
'optional' => true, 'optional' => true,
'condition' => 'linux', 'condition' => 'linux',
'description' => mt( 'description' => mt(
@ -387,7 +387,7 @@ class WebWizard extends Wizard implements SetupWizard
) )
))); )));
$requirements->add(new PhpModuleRequirement(array( $set->add(new PhpModuleRequirement(array(
'condition' => 'OpenSSL', 'condition' => 'OpenSSL',
'description' => mt( 'description' => mt(
'setup', 'setup',
@ -395,7 +395,7 @@ class WebWizard extends Wizard implements SetupWizard
) )
))); )));
$requirements->add(new PhpModuleRequirement(array( $set->add(new PhpModuleRequirement(array(
'optional' => true, 'optional' => true,
'condition' => 'JSON', 'condition' => 'JSON',
'description' => mt( 'description' => mt(
@ -404,7 +404,7 @@ class WebWizard extends Wizard implements SetupWizard
) )
))); )));
$requirements->add(new PhpModuleRequirement(array( $set->add(new PhpModuleRequirement(array(
'optional' => true, 'optional' => true,
'condition' => 'LDAP', 'condition' => 'LDAP',
'description' => mt( 'description' => mt(
@ -413,7 +413,7 @@ class WebWizard extends Wizard implements SetupWizard
) )
))); )));
$requirements->add(new PhpModuleRequirement(array( $set->add(new PhpModuleRequirement(array(
'optional' => true, 'optional' => true,
'condition' => 'INTL', 'condition' => 'INTL',
'description' => mt( '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 // 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, 'optional' => true,
'condition' => 'DOM', 'condition' => 'DOM',
'description' => mt( 'description' => mt(
@ -433,7 +433,7 @@ class WebWizard extends Wizard implements SetupWizard
) )
))); )));
$requirements->add(new PhpModuleRequirement(array( $set->add(new PhpModuleRequirement(array(
'optional' => true, 'optional' => true,
'condition' => 'GD', 'condition' => 'GD',
'description' => mt( 'description' => mt(
@ -442,7 +442,7 @@ class WebWizard extends Wizard implements SetupWizard
) )
))); )));
$requirements->add(new PhpModuleRequirement(array( $set->add(new PhpModuleRequirement(array(
'optional' => true, 'optional' => true,
'condition' => 'Imagick', 'condition' => 'Imagick',
'description' => mt( 'description' => mt(
@ -451,8 +451,8 @@ class WebWizard extends Wizard implements SetupWizard
) )
))); )));
$mysqlRequirements = new Requirements(); $mysqlSet = new RequirementSet();
$mysqlRequirements->add(new PhpModuleRequirement(array( $mysqlSet->add(new PhpModuleRequirement(array(
'optional' => true, 'optional' => true,
'condition' => 'mysql', 'condition' => 'mysql',
'alias' => 'PDO-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.' '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, 'optional' => true,
'condition' => 'Zend_Db_Adapter_Pdo_Mysql', 'condition' => 'Zend_Db_Adapter_Pdo_Mysql',
'alias' => mt('setup', 'Zend database adapter for 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.' 'The Zend database adapter for MySQL is required to access a MySQL database.'
) )
))); )));
$requirements->merge($mysqlRequirements); $set->merge($mysqlSet);
$pgsqlRequirements = new Requirements(); $pgsqlSet = new RequirementSet();
$pgsqlRequirements->add(new PhpModuleRequirement(array( $pgsqlSet->add(new PhpModuleRequirement(array(
'optional' => true, 'optional' => true,
'condition' => 'pgsql', 'condition' => 'pgsql',
'alias' => 'PDO-PostgreSQL', '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.' '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, 'optional' => true,
'condition' => 'Zend_Db_Adapter_Pdo_Pgsql', 'condition' => 'Zend_Db_Adapter_Pdo_Pgsql',
'alias' => mt('setup', 'Zend database adapter for PostgreSQL'), '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.' '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(), 'condition' => Icinga::app()->getConfigDir(),
'description' => mt( 'description' => mt(
'setup', 'setup',
@ -503,9 +503,9 @@ class WebWizard extends Wizard implements SetupWizard
))); )));
foreach ($this->getWizards() as $wizard) { foreach ($this->getWizards() as $wizard) {
$requirements->merge($wizard->getRequirements()); $set->merge($wizard->getRequirements());
} }
return $requirements; return $set;
} }
} }