Skip to content

Commit

Permalink
add support of symfony3, reuse builder from bridge, remove twig facto…
Browse files Browse the repository at this point in the history
…ry usage.
  • Loading branch information
makasim committed Feb 25, 2016
1 parent 3b5967b commit 41138b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 26 deletions.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
],
"require": {
"php": ">=5.5.2",
"silex/silex": "~1.2",
"payum/core": "^1.0"
"silex/silex": "^1.2",
"symfony/form": "^3",
"payum/core": "^1.2"
},
"suggest": {
"payum/payum": "If you want to install all supported gateways at once"
Expand Down
29 changes: 5 additions & 24 deletions src/Payum/Silex/PayumProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,17 @@
use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\Bridge\Symfony\Action\GetHttpRequestAction;
use Payum\Core\Bridge\Symfony\Action\ObtainCreditCardAction;
use Payum\Core\Bridge\Symfony\Builder\HttpRequestVerifierBuilder;
use Payum\Core\Bridge\Symfony\Builder\TokenFactoryBuilder;
use Payum\Core\Bridge\Symfony\Form\Type\CreditCardExpirationDateType;
use Payum\Core\Bridge\Symfony\Form\Type\CreditCardType;
use Payum\Core\Bridge\Symfony\Form\Type\GatewayConfigType;
use Payum\Core\Bridge\Symfony\Form\Type\GatewayFactoriesChoiceType;
use Payum\Core\Bridge\Symfony\Form\Type\GatewayChoiceType;
use Payum\Core\Bridge\Symfony\ReplyToSymfonyResponseConverter;
use Payum\Core\Bridge\Symfony\Security\HttpRequestVerifier;
use Payum\Core\Bridge\Symfony\Security\TokenFactory;
use Payum\Core\Bridge\Twig\TwigFactory;
use Payum\Core\Payum;
use Payum\Core\PayumBuilder;
use Payum\Core\Registry\StorageRegistryInterface;
use Payum\Core\Reply\ReplyInterface;
use Payum\Core\Storage\StorageInterface;
use Silex\Application;
use Silex\ControllerCollection;
use Silex\ControllerProviderInterface;
Expand All @@ -33,8 +30,6 @@ public function register(Application $app)
$app['payum.builder'] = $app->share(function($app) {
$builder = new PayumBuilder();

$builder->addDefaultStorages();

$builder->setCoreGatewayFactoryConfig([
'twig.env' => $app['twig'],

Expand All @@ -61,13 +56,9 @@ public function register(Application $app)
'refund' => 'payum_refund_do'
]);

$builder->setTokenFactory(function(StorageInterface $tokenStorage, StorageRegistryInterface $registry) use ($app) {
return new TokenFactory($tokenStorage, $registry, $app['url_generator']);
});
$builder->setTokenFactory(new TokenFactoryBuilder($app['url_generator']));

$builder->setHttpRequestVerifier(function(StorageInterface $tokenStorage) {
return new HttpRequestVerifier($tokenStorage);
});
$builder->setHttpRequestVerifier(new HttpRequestVerifierBuilder());

return $builder;
});
Expand All @@ -79,16 +70,6 @@ public function register(Application $app)
return $builder->getPayum();
});

$app['twig.loader.filesystem'] = $app->share($app->extend('twig.loader.filesystem', function($loader, $app) {
/** @var \Twig_Loader_Filesystem $loader */

foreach (TwigFactory::createGenericPaths() as $path => $name) {
$loader->addPath($path, $name);
}

return $loader;
}));

$app['payum.reply_to_symfony_response_converter'] = $app->share(function($app) {
return new ReplyToSymfonyResponseConverter();
});
Expand All @@ -113,7 +94,7 @@ public function register(Application $app)
continue;
}

$choices[$name] = ucwords(str_replace(['_', 'omnipay'], ' ', $name));
$choices[ucwords(str_replace(['_', 'omnipay'], ' ', $name))] = $name;
}

return $choices;
Expand Down

0 comments on commit 41138b8

Please sign in to comment.