Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
13 / 13 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| OnContinuouslyEndpoint | |
100.00% |
13 / 13 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
| parseInput | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| handle | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Olz\Api\Endpoints; |
| 4 | |
| 5 | use Olz\Api\OlzTypedEndpoint; |
| 6 | use PhpTypeScriptApi\HttpError; |
| 7 | use Symfony\Component\Console\Input\ArrayInput; |
| 8 | use Symfony\Component\Console\Output\BufferedOutput; |
| 9 | use Symfony\Component\HttpFoundation\Request; |
| 10 | |
| 11 | /** |
| 12 | * @extends OlzTypedEndpoint< |
| 13 | * array{ |
| 14 | * authenticityCode: non-empty-string, |
| 15 | * }, |
| 16 | * ?array{} |
| 17 | * > |
| 18 | */ |
| 19 | class 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 | } |