Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
OnContinuouslyEndpoint
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 2
12
0.00% covered (danger)
0.00%
0 / 1
 parseInput
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 handle
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 1
6
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}