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