ContribModuleVersionRequirement.php in Acquia Content Hub 8
File
acquia_contenthub_diagnostic/src/Plugin/ContentHubRequirement/ContribModuleVersionRequirement.php
View source
<?php
namespace Drupal\acquia_contenthub_diagnostic\Plugin\ContentHubRequirement;
use Drupal\acquia_contenthub_diagnostic\ContentHubRequirementBase;
class ContribModuleVersionRequirement extends ContentHubRequirementBase {
const MODULE_VERSIONS = [
'workbench_moderation' => '8.x-1.2',
'paragraphs' => '8.x-1.0',
'entity_reference_revisions' => '8.x-1.0',
];
public function verify() {
$issues_found = [];
foreach (static::MODULE_VERSIONS as $module => $recommended_version) {
if ($this->moduleHandler
->moduleExists($module)) {
$current_version = \Drupal::service('extension.list.module')
->getAllInstalledInfo()['acquia_contenthub']['version'];
if ($current_version !== $recommended_version) {
$name = $this->moduleHandler
->getName($module);
$issues_found[] = $this
->t('@name @current_version (Recommended @recommended_version)', [
'@name' => $name,
'@current_version' => $current_version,
'@recommended_version' => $recommended_version,
]);
}
}
}
if (empty($issues_found)) {
return REQUIREMENT_OK;
}
$this
->setValue($this
->t('Untested module versions active'));
$this
->setDescription($this
->t('The following untested module versions were found: @module_list', [
'@module_list' => implode(', ', $issues_found),
]));
return REQUIREMENT_WARNING;
}
}