mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 15:34:12 +01:00
N°5090 Setup : improve missing dependencies message (#280)
The setup now relies on the new method MissingDependencyException::getHtmlDesc to get the message to display MissingDependencyException is also now a CoreException child. Note that previous behavior (MissingDependencyException instantiator setting message) is kept, as some consumer still do $e->getMessage() (like unattended install)
This commit is contained in:
@@ -19,9 +19,46 @@
|
||||
*
|
||||
*/
|
||||
|
||||
class MissingDependencyException extends Exception
|
||||
class MissingDependencyException extends CoreException
|
||||
{
|
||||
/**
|
||||
* @see \ModuleDiscovery::OrderModulesByDependencies property init
|
||||
* @var array module id as key
|
||||
* another array as value, containing : 'module' with module info, 'dependencies' with missing dependencies
|
||||
*/
|
||||
public $aModulesInfo;
|
||||
|
||||
/**
|
||||
* @return string HTML to print to the user the modules impacted
|
||||
* @since 2.7.7 3.0.2 3.1.0 PR #280
|
||||
*/
|
||||
public function getHtmlDesc($sHighlightHtmlBegin = null, $sHighlightHtmlEnd = null)
|
||||
{
|
||||
$sErrorMessage = <<<HTML
|
||||
<p>The following modules have unmet dependencies:</p>
|
||||
<ul>
|
||||
HTML;
|
||||
foreach ($this->aModulesInfo as $sModuleId => $aModuleErrors) {
|
||||
$sModuleLabel = $aModuleErrors['module']['label'];
|
||||
$aModuleMissingDependencies = $aModuleErrors['dependencies'];
|
||||
$sErrorMessage .= <<<HTML
|
||||
<li><strong>{$sModuleLabel}</strong> ({$sModuleId}):
|
||||
<ul>
|
||||
HTML;
|
||||
|
||||
foreach ($aModuleMissingDependencies as $sMissingModule) {
|
||||
$sErrorMessage .= "<li>{$sMissingModule}</li>";
|
||||
}
|
||||
$sErrorMessage .= <<<HTML
|
||||
</ul>
|
||||
</li>
|
||||
HTML;
|
||||
|
||||
}
|
||||
$sErrorMessage .= '</ul>';
|
||||
|
||||
return $sErrorMessage;
|
||||
}
|
||||
}
|
||||
|
||||
class ModuleDiscovery
|
||||
|
||||
@@ -1351,7 +1351,7 @@ class WizStepModulesChoice extends WizardStep
|
||||
}
|
||||
catch(MissingDependencyException $e)
|
||||
{
|
||||
$oPage->warning($e->getMessage());
|
||||
$oPage->warning($e->getHtmlDesc());
|
||||
}
|
||||
|
||||
$this->bUpgrade = ($this->oWizard->GetParameter('install_mode') != 'install');
|
||||
@@ -2092,7 +2092,7 @@ class WizStepSummary extends WizardStep
|
||||
catch(MissingDependencyException $e)
|
||||
{
|
||||
$this->bDependencyCheck = false;
|
||||
$this->sDependencyIssue = $e->getMessage();
|
||||
$this->sDependencyIssue = $e->getHtmlDesc();
|
||||
}
|
||||
}
|
||||
return $this->bDependencyCheck;
|
||||
|
||||
Reference in New Issue
Block a user