ScanQrCodeController.php
44 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AmeliaBooking\Application\Controller\QrCode; |
| 4 | |
| 5 | use AmeliaBooking\Application\Commands\QrCode\ScanQrCodeCommand; |
| 6 | use AmeliaBooking\Application\Controller\Controller; |
| 7 | use RuntimeException; |
| 8 | use Slim\Http\Request; |
| 9 | |
| 10 | /** |
| 11 | * Class ScanQrCodeController |
| 12 | * |
| 13 | * @package AmeliaBooking\Application\Controller\QrCode |
| 14 | */ |
| 15 | class ScanQrCodeController extends Controller |
| 16 | { |
| 17 | public $allowedFields = [ |
| 18 | 'ticketManualCode', |
| 19 | 'scannedAt', |
| 20 | ]; |
| 21 | |
| 22 | /** |
| 23 | * Instantiates the Scan Qr Code command to hand it over to the Command Handler |
| 24 | * @param Request $request |
| 25 | * @param $args |
| 26 | * @return ScanQrCodeCommand |
| 27 | * @throws RuntimeException |
| 28 | */ |
| 29 | protected function instantiateCommand(Request $request, $args) |
| 30 | { |
| 31 | $command = new ScanQrCodeCommand($args); |
| 32 | |
| 33 | $params = (array)$request->getQueryParams(); |
| 34 | $command->setField('params', $params); |
| 35 | |
| 36 | $requestBody = $request->getParsedBody(); |
| 37 | $this->setCommandFields($command, $requestBody); |
| 38 | |
| 39 | $command->setToken($request); |
| 40 | |
| 41 | return $command; |
| 42 | } |
| 43 | } |
| 44 |