X-Git-Url: https://git.mxchange.org/?p=shipsimu.git;a=blobdiff_plain;f=application%2Fship-simu%2Fmain%2Fcommands%2Fweb%2Fclass_WebShipsimuRefillCommand.php;h=d296235ea868d5a58b5a1178038abb4c20fcc422;hp=cca8a181727438a033d915f25398ff4f1d40076b;hb=13f890c63dd0c211d9b8e2989051df2fbc20a907;hpb=23fe4cf0991c5903597f5645dd5d3c3fd0dfff96 diff --git a/application/ship-simu/main/commands/web/class_WebShipsimuRefillCommand.php b/application/ship-simu/main/commands/web/class_WebShipsimuRefillCommand.php index cca8a18..d296235 100644 --- a/application/ship-simu/main/commands/web/class_WebShipsimuRefillCommand.php +++ b/application/ship-simu/main/commands/web/class_WebShipsimuRefillCommand.php @@ -59,10 +59,17 @@ class WebShipsimuRefillCommand extends BaseCommand implements Commandable { * @param $requestInstance An instance of a class with an Requestable interface * @param $responseInstance An instance of a class with an Responseable interface * @return void - * @todo 0% done */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { - $this->partialStub("Please implement this method."); + // Get template instance + $templateInstance = $responseInstance->getTemplateInstance(); + + // Set amount and type as variables + $templateInstance->assignVariable('refill_done', $requestInstance->getRequestElement('type')); + $templateInstance->assignVariable('amount' , $requestInstance->getRequestElement('amount')); + + // This method does currently redirect if all goes right + $responseInstance->redirectToConfiguredUrl('refill_page_done'); } /** @@ -91,11 +98,17 @@ class WebShipsimuRefillCommand extends BaseCommand implements Commandable { // Verify refill request $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('refill_request_validator_filter')); + // Construct config entry for wether automatic payment from API or waiting for approval + $paymentTypeConfig = sprintf("refill_request_%s_payment_type", $requestInstance->getRequestElement('type')); + // Prepare a filter based on the requested type we shall refill - $filterName = sprintf("refill_request_%s_book_filter", $requestInstance->getRequestElement('type')); + $filterName = sprintf("refill_request_%s_%s_book_filter", + $requestInstance->getRequestElement('type'), + $this->getConfigInstance()->readConfig($paymentTypeConfig) + ); // Now, try to load that filter - $controllerInstance->addPostFilter(ObjectFactory::createObjectByConfiguredName($filterName)); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName($filterName)); } }