Platform: Drop *Available function

Create a function extensionLoaded and change usages.

refs #5514
This commit is contained in:
Marius Hein 2014-08-28 11:54:45 +02:00
parent 436a4d2965
commit e345aa257a
3 changed files with 8 additions and 26 deletions

View File

@ -136,7 +136,7 @@ class LdapBackendForm extends BaseBackendForm
*/
public function isValidAuthenticationBackend()
{
if (! Platform::ldapAvailable()) {
if (! Platform::extensionLoaded('ldap')) {
/*
* It should be possible to run icingaweb without the php ldap extension, when
* no ldap backends are needed. When the user tries to create an ldap backend

View File

@ -406,14 +406,14 @@ class ResourceForm extends Form
* in case they aren't actually used. When the user tries to create a resource that depends on an
* uninstalled extension, an error should be displayed.
*/
if ($config->db === 'mysql' && ! Platform::mysqlAvailable()) {
if ($config->db === 'mysql' && ! Platform::extensionLoaded('mysql')) {
$this->addErrorMessage(
t('You need to install the php extension "mysql" and the ' .
'Zend_Pdo_Mysql classes to use MySQL database resources.')
);
return false;
}
if ($config->db === 'pgsql' && ! Platform::pgsqlAvailable()) {
if ($config->db === 'pgsql' && ! Platform::extensionLoaded('pgsql')) {
$this->addErrorMessage(
t('You need to install the php extension "pgsql" and the ' .
'Zend_Pdo_Pgsql classes to use PostgreSQL database resources.')

View File

@ -121,32 +121,14 @@ class Platform
}
/**
* Test of php ldap support
* Test for php extension
*
* @return bool
*/
public static function ldapAvailable()
{
return extension_loaded('ldap');
}
/**
* Test of php pgsql support
* @param string $extensionName E.g. mysql, ldap
*
* @return bool
* @return bool
*/
public static function pgsqlAvailable()
public static function extensionLoaded($extensionName)
{
return extension_loaded('pgsql');
}
/**
* Test of php mysql support
*
* @return bool
*/
public static function mysqlAvailable()
{
return extension_loaded('mysql');
return extension_loaded($extensionName);
}
}