Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
OnContinuouslyEndpoint
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
2 / 2
3
100.00% covered (success)
100.00%
1 / 1
 parseInput
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 handle
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3namespace Olz\Api\Endpoints;
4
5use Olz\Api\OlzTypedEndpoint;
6use PhpTypeScriptApi\HttpError;
7use Symfony\Component\Console\Input\ArrayInput;
8use Symfony\Component\Console\Output\BufferedOutput;
9use Symfony\Component\HttpFoundation\Request;
10
11/**
12 * @extends OlzTypedEndpoint<
13 *   array{
14 *     authenticityCode: non-empty-string,
15 *   },
16 *   ?array{}
17 * >
18 */
19class OnContinuouslyEndpoint extends OlzTypedEndpoint {
20    public function parseInput(Request $request): mixed {
21        return [
22            'authenticityCode' => $request->query->get('authenticityCode'),
23        ];
24    }
25
26    protected function handle(mixed $input): mixed {
27        $expected_code = $this->envUtils()->getCronAuthenticityCode();
28        $actual_code = $input['authenticityCode'];
29        if ($actual_code != $expected_code) {
30            throw new HttpError(403, "Kein Zugriff!");
31        }
32
33        set_time_limit(4000);
34        ignore_user_abort(true);
35
36        $command_input = new ArrayInput([]);
37        $command_output = new BufferedOutput();
38        $this->symfonyUtils()->callCommand('olz:on-continuously', $command_input, $command_output);
39
40        return [];
41    }
42}