if (isset(self::$proposals[$view])) {
$best_proposals = [];
$all_sources = [];
foreach (self::$proposals[$view] as $proposal_source => $proposal) {
if (!isset($this->backend_branch) || substr($this->backend_branch, 0, 11) != "adjust-for:" || substr($this->backend_branch, 11) == $proposal_source) {
if ($proposal['orig_base'] == $curr_base || $relax_checking) {
$age = time() - $proposal['updated_at'];
if ($age < self::MAX_AGE) {
foreach ($proposal['proposals'] as $proposal_label => $proposal_price) {
if (!in_array($proposal_label, [self::SK_LABEL_AVIASALES, self::SK_LABEL_SKYSCANNER, self::SK_LABEL_YANDEX, self::SK_LABEL_MOMONDO])) {
$proposal_key = $proposal_label;
if (!isset($best_proposals[$proposal_key]) || $best_proposals[$proposal_key]['price'] > $proposal_price) {
$best_proposals[$proposal_key] = [
'price' => $proposal_price,
'name' => $proposal_price . "@" . implode("~", array_map(function ($part) {
return preg_replace('/[~|=#@ ]/', '_', $part);
}, [
'label' => $proposal_label,
'source' => $proposal_source,
])),
'age' => $age,
];
$all_sources[$proposal_source] = null;
}
}
}
}
}
}
}