GetStatsController.php
48 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @copyright © Melograno Ventures. All rights reserved. |
| 5 | * @licence See LICENCE.md for license details. |
| 6 | */ |
| 7 | |
| 8 | namespace AmeliaBooking\Application\Controller\Stats; |
| 9 | |
| 10 | use AmeliaBooking\Application\Commands\Stats\GetStatsCommand; |
| 11 | use AmeliaBooking\Application\Controller\Controller; |
| 12 | use RuntimeException; |
| 13 | use AmeliaVendor\Psr\Http\Message\ServerRequestInterface as Request; |
| 14 | |
| 15 | /** |
| 16 | * Class GetStatsController |
| 17 | * |
| 18 | * @package AmeliaBooking\Application\Controller\Stats |
| 19 | */ |
| 20 | class GetStatsController extends Controller |
| 21 | { |
| 22 | /** |
| 23 | * Instantiates the Get Stats command to hand it over to the Command Handler |
| 24 | * |
| 25 | * @param Request $request |
| 26 | * @param $args |
| 27 | * |
| 28 | * @return mixed |
| 29 | * @throws RuntimeException |
| 30 | */ |
| 31 | protected function instantiateCommand(Request $request, $args) |
| 32 | { |
| 33 | $command = new GetStatsCommand($args); |
| 34 | |
| 35 | $params = (array)$request->getQueryParams(); |
| 36 | |
| 37 | $this->setArrayParams($params); |
| 38 | |
| 39 | $command->setField('params', $params); |
| 40 | |
| 41 | $requestBody = $request->getQueryParams(); |
| 42 | |
| 43 | $this->setCommandFields($command, $requestBody); |
| 44 | |
| 45 | return $command; |
| 46 | } |
| 47 | } |
| 48 |