Refactor progress_alert_format parsing in goals_criteria to support object structures and update enum mapping in goals_criteria_progress_alert_style
This commit is contained in:
@@ -186,11 +186,33 @@ class goals_criteria implements goals_criteria_i
|
||||
}
|
||||
}
|
||||
|
||||
// Parse progress alert format (string)
|
||||
if (isset($data['progress_alert_format']) && is_string($data['progress_alert_format'])) {
|
||||
$criteria->progress_alert_format = trim((string)$data['progress_alert_format']);
|
||||
} elseif (isset($data['progressAlertFormat']) && is_string($data['progressAlertFormat'])) {
|
||||
$criteria->progress_alert_format = trim((string)$data['progressAlertFormat']);
|
||||
// Parse progress alert format (string or object with render)
|
||||
if (isset($data['progress_alert_format'])) {
|
||||
$fmt = $data['progress_alert_format'];
|
||||
if (is_string($fmt)) {
|
||||
$criteria->progress_alert_format = trim($fmt);
|
||||
} elseif (is_array($fmt) || is_object($fmt)) {
|
||||
// Support structures coming from classes implementing goals_criteria_progress_alert_format_t
|
||||
// Expected keys: 'render' or 'format'
|
||||
$arr = (array)$fmt;
|
||||
if (isset($arr['render']) && is_string($arr['render'])) {
|
||||
$criteria->progress_alert_format = trim($arr['render']);
|
||||
} elseif (isset($arr['format']) && is_string($arr['format'])) {
|
||||
$criteria->progress_alert_format = trim($arr['format']);
|
||||
}
|
||||
}
|
||||
} elseif (isset($data['progressAlertFormat'])) {
|
||||
$fmt = $data['progressAlertFormat'];
|
||||
if (is_string($fmt)) {
|
||||
$criteria->progress_alert_format = trim($fmt);
|
||||
} elseif (is_array($fmt) || is_object($fmt)) {
|
||||
$arr = (array)$fmt;
|
||||
if (isset($arr['render']) && is_string($arr['render'])) {
|
||||
$criteria->progress_alert_format = trim($arr['render']);
|
||||
} elseif (isset($arr['format']) && is_string($arr['format'])) {
|
||||
$criteria->progress_alert_format = trim($arr['format']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Parse progress alert weekdays (array of strings)
|
||||
|
||||
Reference in New Issue
Block a user