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