From 2dc5b7d5b7c7a5763864c4b2e5495a7aa97a0d8d Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Thu, 29 Oct 2015 18:38:14 +0000 Subject: [PATCH] add gateway choice form type. --- src/Payum/Silex/PayumProvider.php | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/Payum/Silex/PayumProvider.php b/src/Payum/Silex/PayumProvider.php index 2533fcc..6dc205a 100644 --- a/src/Payum/Silex/PayumProvider.php +++ b/src/Payum/Silex/PayumProvider.php @@ -1,22 +1,22 @@ function() use($app) { - $action = new ObtainCreditCardAction($app['form.factory'], $app['payum.template.obtain_credit_card']); + 'payum.action.obtain_credit_card' => function(ArrayObject $config) use($app) { + $action = new ObtainCreditCardAction($app['form.factory'], $config['payum.template.obtain_credit_card']); $action->setRequest($app['request']); return $action; @@ -114,13 +114,14 @@ protected function registerService(Application $app) $app['form.types'] = $app->share($app->extend('form.types', function ($types) use ($app) { $types[] = new CreditCardType(); $types[] = new CreditCardExpirationDateType(); - $types[] = new GatewayFactoriesChoiceType($app['payum.gateway_choices']); + $types[] = new GatewayFactoriesChoiceType($app['payum.gateway_factory_choices']); + $types[] = new GatewayChoiceType($app['payum.gateway_choices']); $types[] = new GatewayConfigType($app['payum']); return $types; })); - $app['payum.gateway_choices'] = $app->share(function ($app) { + $app['payum.gateway_factory_choices'] = $app->share(function ($app) { /** @var Payum $payum */ $payum = $app['payum']; @@ -135,6 +136,18 @@ protected function registerService(Application $app) return $choices; }); + + $app['payum.gateway_choices'] = $app->share(function ($app) { + /** @var Payum $payum */ + $payum = $app['payum']; + + $choices = []; + foreach ($payum->getGateways() as $name => $gateway) { + $choices[$name] = ucwords(str_replace(['_'], ' ', $name)); + } + + return $choices; + }); } /**