public function SyncHealth::overview in CMS Content Sync 8
Same name and namespace in other branches
- 2.1.x modules/cms_content_sync_health/src/Controller/SyncHealth.php \Drupal\cms_content_sync_health\Controller\SyncHealth::overview()
- 2.0.x modules/cms_content_sync_health/src/Controller/SyncHealth.php \Drupal\cms_content_sync_health\Controller\SyncHealth::overview()
Render the overview page.
Return value
array
1 string reference to 'SyncHealth::overview'
- cms_content_sync_health.routing.yml in modules/
cms_content_sync_health/ cms_content_sync_health.routing.yml - modules/cms_content_sync_health/cms_content_sync_health.routing.yml
File
- modules/
cms_content_sync_health/ src/ Controller/ SyncHealth.php, line 255
Class
- SyncHealth
- Provides a listing of Flow.
Namespace
Drupal\cms_content_sync_health\ControllerCode
public function overview() {
$sync_cores = [];
foreach (SyncCoreFactory::getAllSyncCores() as $host => $core) {
$status = $core
->getReportingService()
->getStatus();
$reporting = $core
->getReportingService();
$status['error_log'] = $this
->filterSyncCoreLogMessages($reporting
->getLog(IReportingService::LOG_LEVEL_ERROR));
$status['warning_log'] = $this
->filterSyncCoreLogMessages($reporting
->getLog(IReportingService::LOG_LEVEL_WARNING));
$sync_cores[$host] = $status;
}
$module_info = \Drupal::service('extension.list.module')
->getExtensionInfo('cms_content_sync');
$moduleHandler = $this->moduleHandler;
if ($moduleHandler
->moduleExists('update')) {
$updates = new UpdateFetcher($this->configFactory, $this->httpClient);
$available = $updates
->fetchProjectData([
'name' => 'cms_content_sync',
'info' => $module_info,
'includes' => [],
'project_type' => 'module',
'project_status' => TRUE,
]);
preg_match_all('@<version>\\s*8.x-([0-9]+)\\.([0-9]+)\\s*</version>@i', $available, $versions, PREG_SET_ORDER);
$newest_major = 0;
$newest_minor = 0;
foreach ($versions as $version) {
if ($version[1] > $newest_major) {
$newest_major = $version[1];
$newest_minor = $version[2];
}
elseif ($version[1] == $newest_major && $version[2] > $newest_minor) {
$newest_minor = $version[2];
}
}
$newest_version = $newest_major . '.' . $newest_minor;
}
else {
$newest_version = NULL;
}
if (isset($module_info['version'])) {
$module_version = $module_info['version'];
$module_version = preg_replace('@^\\d\\.x-(.*)$@', '$1', $module_version);
if ($module_version != $newest_version) {
if ($newest_version) {
$this->messenger
->addMessage(t('There\'s an update available! The newest module version is @newest, yours is @current.', [
'@newest' => $newest_version,
'@current' => $module_version,
]));
}
else {
$this->messenger
->addMessage(t('Please enable the "update" module to see if you\'re running the latest Content Sync version.'));
}
}
}
else {
$module_version = NULL;
if ($newest_version) {
$this->messenger
->addWarning(t('You\'re running a dev release. The newest module version is @newest.', [
'@newest' => $newest_version,
]));
}
}
$push_failures_hard = $this
->countStatusEntitiesWithFlag(EntityStatus::FLAG_PUSH_FAILED);
$push_failures_soft = $this
->countStatusEntitiesWithFlag(EntityStatus::FLAG_PUSH_FAILED_SOFT);
$pull_failures_hard = $this
->countStatusEntitiesWithFlag(EntityStatus::FLAG_PULL_FAILED);
$pull_failures_soft = $this
->countStatusEntitiesWithFlag(EntityStatus::FLAG_PULL_FAILED_SOFT);
$version_differences['local'] = $this
->getLocalVersionDifferences();
$moduleHandler = $this->moduleHandler;
$dblog_enabled = $moduleHandler
->moduleExists('dblog');
if ($dblog_enabled) {
$site_log_disabled = FALSE;
$error_log = $this
->getLocalLogMessages([
RfcLogLevel::EMERGENCY,
RfcLogLevel::ALERT,
RfcLogLevel::CRITICAL,
RfcLogLevel::ERROR,
]);
$warning_log = $this
->getLocalLogMessages([
RfcLogLevel::WARNING,
]);
}
else {
$site_log_disabled = TRUE;
$error_log = NULL;
$warning_log = NULL;
}
return [
'#theme' => 'cms_content_sync_sync_health_overview',
'#sync_cores' => $sync_cores,
'#module_version' => $module_version,
'#newest_version' => $newest_version,
'#push_failures_hard' => $push_failures_hard,
'#push_failures_soft' => $push_failures_soft,
'#pull_failures_hard' => $pull_failures_hard,
'#pull_failures_soft' => $pull_failures_soft,
'#version_differences' => $version_differences,
'#error_log' => $error_log,
'#warning_log' => $warning_log,
'#site_log_disabled' => $site_log_disabled,
];
}