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