xref: /web-bugs/www/api.php (revision 9d47b05f)
1<?php
2/*
3    Hack note: This is for emailing the documentation team about commit/bugs emails, but could be expanded in the future.
4
5    The API itself will probably be abandoned in the future, but here's the current URL:
6    - https://bugs.php.net/api.php?type=docs&action=closed&interval=7
7*/
8
9use App\Repository\CommentRepository;
10
11require_once '../include/prepend.php';
12
13$type     = isset($_GET['type'])     ? $_GET['type']           : 'unknown';
14$action   = isset($_GET['action'])   ? $_GET['action']         : 'unknown';
15$interval = isset($_GET['interval']) ? (int) $_GET['interval'] : 7;
16
17if ($type === 'docs' && $action === 'closed' && $interval) {
18    $commentRepository = $container->get(CommentRepository::class);
19    $rows = $commentRepository->findDocsComments($interval);
20
21    //@todo add error handling
22    if (!$rows) {
23        echo 'The fail train has arrived.';
24        exit;
25    }
26
27    echo serialize($rows);
28
29} else {
30
31    echo "Unknown action";
32
33}
34