vendor/payum/core/Payum/Core/Registry/FallbackRegistry.php line 54

Open in your IDE?
  1. <?php
  2. namespace Payum\Core\Registry;
  3. use Payum\Core\Exception\InvalidArgumentException;
  4. class FallbackRegistry implements RegistryInterface
  5. {
  6.     /**
  7.      * @var RegistryInterface
  8.      */
  9.     private $registry;
  10.     /**
  11.      * @var RegistryInterface
  12.      */
  13.     private $fallbackRegistry;
  14.     /**
  15.      * @param RegistryInterface $registry
  16.      * @param RegistryInterface $fallbackRegistry
  17.      */
  18.     public function __construct(RegistryInterface $registry, RegistryInterface $fallbackRegistry)
  19.     {
  20.         $this->registry = $registry;
  21.         $this->fallbackRegistry = $fallbackRegistry;
  22.     }
  23.     /**
  24.      * {@inheritDoc}
  25.      */
  26.     public function getGatewayFactory($name)
  27.     {
  28.         try {
  29.             return $this->registry->getGatewayFactory($name);
  30.         } catch (InvalidArgumentException $e) {
  31.             return $this->fallbackRegistry->getGatewayFactory($name);
  32.         }
  33.     }
  34.     /**
  35.      * {@inheritDoc}
  36.      */
  37.     public function getGatewayFactories()
  38.     {
  39.         return array_replace($this->fallbackRegistry->getGatewayFactories(), $this->registry->getGatewayFactories());
  40.     }
  41.     /**
  42.      * {@inheritDoc}
  43.      */
  44.     public function getGateway($name)
  45.     {
  46.         try {
  47.             return $this->registry->getGateway($name);
  48.         } catch (InvalidArgumentException $e) {
  49.             return $this->fallbackRegistry->getGateway($name);
  50.         }
  51.     }
  52.     /**
  53.      * {@inheritDoc}
  54.      */
  55.     public function getGateways()
  56.     {
  57.         return array_replace($this->fallbackRegistry->getGateways(), $this->registry->getGateways());
  58.     }
  59.     /**
  60.      * {@inheritDoc}
  61.      */
  62.     public function getStorage($class)
  63.     {
  64.         try {
  65.             return $this->registry->getStorage($class);
  66.         } catch (InvalidArgumentException $e) {
  67.             return $this->fallbackRegistry->getStorage($class);
  68.         }
  69.     }
  70.     /**
  71.      * {@inheritDoc}
  72.      */
  73.     public function getStorages()
  74.     {
  75.         return array_replace($this->fallbackRegistry->getStorages(), $this->registry->getStorages());
  76.     }
  77. }