check extensions in install process

This commit is contained in:
Manuel Raynaud
2013-11-13 15:14:06 +01:00
parent 25192cf366
commit b965275425
2 changed files with 47 additions and 25 deletions

View File

@@ -63,6 +63,14 @@ class CheckPermission extends BaseInstall
'upload_max_filesize' => 2097152 'upload_max_filesize' => 2097152
); );
protected $extensions = array(
'curl',
'gd',
'intl',
'mcrypt',
'pdo_mysql',
);
protected $validationMessages = array(); protected $validationMessages = array();
/** @var bool If permissions are OK */ /** @var bool If permissions are OK */
@@ -103,6 +111,14 @@ class CheckPermission extends BaseInstall
); );
} }
foreach ($this->extensions as $extension) {
$this->validationMessages[$extension] = array(
'text' => '',
'hint' => $this->getI18nExtensionHint(),
'status' => true,
);
}
parent::__construct($verifyInstall); parent::__construct($verifyInstall);
} }
@@ -139,6 +155,15 @@ class CheckPermission extends BaseInstall
} }
} }
foreach ($this->extensions as $extension) {
$this->validationMessages[$extension]['text'] = $this->getI18nExtensionText($extension, true);
if (false === extension_loaded($extension)) {
$this->isValid = false;
$this->validationMessages[$extension]['status'] = false;
$this->validationMessages[$extension]['text'] = $this->getI18nExtensionText($extension, false);
}
}
@@ -176,7 +201,6 @@ class CheckPermission extends BaseInstall
} }
/** /**
* Get Translated text about the directory state * Get Translated text about the directory state
* *
@@ -198,8 +222,7 @@ class CheckPermission extends BaseInstall
$sentence, $sentence,
array( array(
'%directory%' => $directory '%directory%' => $directory
), )
'install-wizard'
); );
} else { } else {
$translatedText = sprintf('Your directory %s needs to be writable', $directory); $translatedText = sprintf('Your directory %s needs to be writable', $directory);
@@ -208,6 +231,19 @@ class CheckPermission extends BaseInstall
return $translatedText; return $translatedText;
} }
protected function getI18nExtensionText($extension, $isValid)
{
if ($isValid) {
$sentence = '%extension% is loaded';
} else {
$sentence = '%extension% is not loaded';
}
return $this->translator->trans($sentence, array(
'%extension' => $extension
));
}
/** /**
* Get Translated hint about the directory state * Get Translated hint about the directory state
* *
@@ -266,6 +302,11 @@ class CheckPermission extends BaseInstall
return $translatedText; return $translatedText;
} }
protected function getI18nExtensionHint()
{
return $this->translator->trans('This extension must be installed and loaded');
}
/** /**
* Get Translated hint about the config requirement issue * Get Translated hint about the config requirement issue
* *
@@ -275,9 +316,7 @@ class CheckPermission extends BaseInstall
{ {
$sentence = 'Modifying this value on your server php.ini file with admin rights could help'; $sentence = 'Modifying this value on your server php.ini file with admin rights could help';
$translatedText = $this->translator->trans( $translatedText = $this->translator->trans(
$sentence, $sentence
array(),
'install-wizard'
); );
return $translatedText; return $translatedText;
@@ -306,8 +345,7 @@ class CheckPermission extends BaseInstall
array( array(
'%expectedValue%' => $expectedValue, '%expectedValue%' => $expectedValue,
'%currentValue%' => $currentValue, '%currentValue%' => $currentValue,
), )
'install-wizard'
); );
} else { } else {
$translatedText = sprintf('Thelia needs at least PHP %s (%s currently)', $expectedValue, $currentValue); $translatedText = sprintf('Thelia needs at least PHP %s (%s currently)', $expectedValue, $currentValue);
@@ -326,8 +364,7 @@ class CheckPermission extends BaseInstall
$sentence = 'Upgrading your version of PHP with admin rights could help'; $sentence = 'Upgrading your version of PHP with admin rights could help';
$translatedText = $this->translator->trans( $translatedText = $this->translator->trans(
$sentence, $sentence,
array(), array()
'install-wizard'
); );
return $translatedText; return $translatedText;

View File

@@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<phpdoc>
<title><![CDATA[<b>Thelia</b> e-commerce Project]]></title>
<parser>
<target>documentation/api</target>
</parser>
<transformer>
<target>documentation/api</target>
</transformer>
<files>
<ignore>core/lib/Thelia/Tests/*</ignore>
<directory>core/lib/Thelia</directory>
</files>
</phpdoc>