Skip to content

Commit

Permalink
Auto register storages as extension in a gateways.
Browse files Browse the repository at this point in the history
  • Loading branch information
makasim committed Apr 23, 2015
1 parent 812a5ea commit f96a9f6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
31 changes: 31 additions & 0 deletions src/Payum/Silex/DynamicRegistry.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
namespace Payum\Silex;

use Payum\Core\Extension\StorageExtension;
use Payum\Core\Gateway;
use Payum\Core\Registry\DynamicRegistry as CoreDynamicRegistry;

class DynamicRegistry extends CoreDynamicRegistry
{
/**
* {@inheritDoc}
*/
public function getGateway($name)
{
$gateway = parent::getGateway($name);

$this->addStorageToGateway($gateway);

return $gateway;
}

/**
* @param Gateway $gateway
*/
protected function addStorageToGateway(Gateway $gateway)
{
foreach ($this->getStorages() as $storage) {
$gateway->addExtension(new StorageExtension($storage));
}
}
}
3 changes: 0 additions & 3 deletions src/Payum/Silex/PayumProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
use Payum\Core\Bridge\Symfony\Security\TokenFactory;
use Payum\Core\Bridge\Twig\TwigFactory;
use Payum\Core\GatewayFactory;
use Payum\Core\GatewayFactoryInterface;
use Payum\Core\Registry\DynamicRegistry;
use Payum\Core\Registry\SimpleRegistry;
use Payum\Core\Reply\ReplyInterface;
use Payum\Core\Security\GenericTokenFactory;
use Payum\Silex\Controller\AuthorizeController;
Expand Down

0 comments on commit f96a9f6

Please sign in to comment.