|
1 | 1 | <?php |
2 | 2 |
|
3 | | -include_once __DIR__ . '/../include/prepend.inc'; |
4 | | -include_once __DIR__ . '/../include/branches.inc'; |
5 | | - |
6 | | -header('Content-Type: application/json; charset=UTF-8'); |
| 3 | +use phpweb\Releases\VersionData; |
7 | 4 |
|
8 | | -function formatDate($date = null) { |
9 | | - return $date !== null ? $date->format('c') : null; |
10 | | -} |
| 5 | +include_once __DIR__ . '/../include/prepend.inc'; |
11 | 6 |
|
12 | 7 | $current = []; |
13 | | -foreach (get_all_branches() as $major => $releases) { |
14 | | - foreach ($releases as $branch => $release) { |
15 | | - $current[$branch] = [ |
16 | | - 'branch' => $branch, |
17 | | - 'latest' => ($release['version'] ?? null), |
18 | | - 'state' => get_branch_support_state($branch), |
19 | | - 'initial_release' => formatDate(get_branch_release_date($branch)), |
20 | | - 'active_support_end' => formatDate(get_branch_bug_eol_date($branch)), |
21 | | - 'security_support_end' => formatDate(get_branch_security_eol_date($branch)), |
22 | | - ]; |
23 | | - } |
| 8 | +foreach (VersionData::sort(VersionData::all(), 'desc') as $release) { |
| 9 | + $current[] = [ |
| 10 | + 'branch' => $release->label, |
| 11 | + 'latest' => $release->latestRelease?->label, |
| 12 | + 'state' => $release->supportState->value, |
| 13 | + 'initial_release' => $release->releaseDate?->format('c'), |
| 14 | + 'active_support_end' => $release->bugfixEOL?->format('c'), |
| 15 | + 'security_support_end' => $release->securityEOL?->format('c'), |
| 16 | + ]; |
24 | 17 | } |
25 | 18 |
|
26 | | -// Sorting should already be correct based on return of get_all_branches(), |
27 | | -// but enforce it here anyway, just to be nice. |
28 | 19 | usort($current, fn($a, $b) => version_compare($b['branch'], $a['branch'])); |
29 | 20 |
|
| 21 | +header('Content-Type: application/json; charset=UTF-8'); |
30 | 22 | echo json_encode($current); |
0 commit comments