vendor/wearemarketing/paymentbundle/DependencyInjection/Configuration.php line 32

Open in your IDE?
  1. <?php
  2. namespace WAM\Bundle\PaymentBundle\DependencyInjection;
  3. use Symfony\Component\Config\Definition\Builder\TreeBuilder;
  4. use Symfony\Component\Config\Definition\ConfigurationInterface;
  5. use WAM\Bundle\PaymentBundle\Service\PaymentBridge;
  6. /**
  7.  * Class Configuration.
  8.  *
  9.  * @author Juanjo Martínez <jmartinez@wearemarketing.com>
  10.  */
  11. class Configuration implements ConfigurationInterface
  12. {
  13.     const FREE_PAYMENT_METHOD 'wam_payment.free_payment';
  14.     const PAYLANDS_METHOD 'wam_payment.paylands';
  15.     const PAYPAL_WEB_CHECKOUT_METHOD 'wam_payment.paypal_web_checkout';
  16.     const REDSYS_METHOD 'wam_payment.redsys';
  17.     const STRIPE_METHOD 'wam_payment.stripe';
  18.     const ENABLED_METHODS = [
  19.         self::FREE_PAYMENT_METHOD,
  20.     ];
  21.     /**
  22.      * {@inheritdoc}
  23.      */
  24.     public function getConfigTreeBuilder()
  25.     {
  26.         $treeBuilder = new TreeBuilder();
  27.         $rootNode $treeBuilder->root('wam_payment');
  28.         $rootNode
  29.             ->children()
  30.                 ->scalarNode('payment_bridge_class')->defaultValue(PaymentBridge::class)->end()
  31.                 ->arrayNode('enabled_methods')
  32.                    ->defaultValue(self::ENABLED_METHODS)
  33.                     ->prototype('scalar')
  34.                         ->validate()
  35.                             ->ifTrue(function ($value) {
  36.                                 return != count(explode('.'$value)) or 'wam_payment.' != substr($value012);
  37.                             })
  38.                             ->thenInvalid('Method name should follow the pattern wam_payment.{method_name}')
  39.                         ->end()
  40.                     ->end()
  41.                 ->end()
  42.             ->end()
  43.         ;
  44.         return $treeBuilder;
  45.     }
  46. }