-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1 payment options, honorary and free of charge
- Loading branch information
Showing
13 changed files
with
327 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace DMKClub\Bundle\PaymentBundle; | ||
|
||
use Symfony\Component\HttpKernel\Bundle\Bundle; | ||
|
||
class DMKClubPaymentBundle extends Bundle | ||
{ | ||
} |
29 changes: 29 additions & 0 deletions
29
src/DMKClub/Bundle/PaymentBundle/DependencyInjection/Configuration.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace DMKClub\Bundle\PaymentBundle\DependencyInjection; | ||
|
||
use Symfony\Component\Config\Definition\Builder\TreeBuilder; | ||
use Symfony\Component\Config\Definition\ConfigurationInterface; | ||
|
||
/** | ||
* This is the class that validates and merges configuration from your app/config files | ||
* | ||
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class} | ||
*/ | ||
class Configuration implements ConfigurationInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getConfigTreeBuilder() | ||
{ | ||
$treeBuilder = new TreeBuilder(); | ||
$rootNode = $treeBuilder->root('dmk_club_payment'); | ||
|
||
// Here you should define the parameters that are allowed to | ||
// configure your bundle. See the documentation linked above for | ||
// more information on that topic. | ||
|
||
return $treeBuilder; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/DMKClub/Bundle/PaymentBundle/DependencyInjection/DMKClubPaymentExtension.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace DMKClub\Bundle\PaymentBundle\DependencyInjection; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\Config\FileLocator; | ||
use Symfony\Component\HttpKernel\DependencyInjection\Extension; | ||
use Symfony\Component\DependencyInjection\Loader; | ||
|
||
/** | ||
* This is the class that loads and manages your bundle configuration | ||
* | ||
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} | ||
*/ | ||
class DMKClubPaymentExtension extends Extension | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function load(array $configs, ContainerBuilder $container) | ||
{ | ||
$configuration = new Configuration(); | ||
$config = $this->processConfiguration($configuration, $configs); | ||
|
||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); | ||
$loader->load('services.yml'); | ||
$loader->load('form.yml'); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
src/DMKClub/Bundle/PaymentBundle/Form/Type/PaymentOptionsType.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
namespace DMKClub\Bundle\PaymentBundle\Form\Type; | ||
|
||
use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
use Symfony\Component\Form\AbstractType; | ||
|
||
use Oro\Bundle\UserBundle\Provider\GenderProvider; | ||
|
||
class PaymentOptionsType extends AbstractType | ||
{ | ||
const NAME = 'dmkclub_paymentoptions'; | ||
|
||
/** | ||
* @var PaymentOptionsProvider | ||
*/ | ||
protected $paymentOptionsProvider; | ||
|
||
/** | ||
* @param PaymentOptionsProvider $paymentOptionsProvider | ||
*/ | ||
public function __construct(PaymentOptionsProvider $paymentOptionsProvider) | ||
{ | ||
$this->paymentOptionsProvider = $paymentOptionsProvider; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getName() | ||
{ | ||
return self::NAME; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getParent() | ||
{ | ||
return 'choice'; | ||
} | ||
|
||
/** | ||
* @param OptionsResolverInterface $resolver | ||
*/ | ||
public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
{ | ||
$resolver->setDefaults( | ||
array( | ||
'choices' => $this->paymentOptionsProvider->getChoices(), | ||
'multiple' => false, | ||
'expanded' => false, | ||
'empty_value' => 'dmkclub.payment.form.choose_option', | ||
'translatable_options' => false | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace DMKClub\Bundle\PaymentBundle\Model; | ||
|
||
class PaymentOption { | ||
const SEPA_DIRECT_DEBIT = 'sepa_direct_debit'; | ||
const BANKTRANSFER = 'banktransfer'; | ||
const CREDITCARD = 'creditcard'; | ||
} |
66 changes: 66 additions & 0 deletions
66
src/DMKClub/Bundle/PaymentBundle/Provider/PaymentOptionsProvider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
namespace DMKClub\Bundle\MemberBundle\Provider; | ||
|
||
use Symfony\Component\Translation\TranslatorInterface; | ||
use DMKClub\Bundle\PaymentBundle\Model\PaymentOption; | ||
|
||
class PaymentOptionsProvider | ||
{ | ||
/** | ||
* @var TranslatorInterface | ||
*/ | ||
protected $translator; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $choices = array( | ||
PaymentOption::SEPA_DIRECT_DEBIT => 'dmkclub.payment_option.sepa_direct_debit', | ||
PaymentOption::BANKTRANSFER => 'dmkclub.payment_option.banktransfer', | ||
PaymentOption::CREDITCARD => 'dmkclub.payment_option.creditcard', | ||
); | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $translatedChoices; | ||
|
||
/** | ||
* @param TranslatorInterface $translator | ||
*/ | ||
public function __construct(TranslatorInterface $translator) | ||
{ | ||
$this->translator = $translator; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getChoices() | ||
{ | ||
if (null === $this->translatedChoices) { | ||
$this->translatedChoices = array(); | ||
foreach ($this->choices as $name => $label) { | ||
$this->translatedChoices[$name] = $this->translator->trans($label); | ||
} | ||
} | ||
|
||
return $this->translatedChoices; | ||
} | ||
|
||
/** | ||
* @param string $name | ||
* @return string | ||
* @throws \LogicException | ||
*/ | ||
public function getLabelByName($name) | ||
{ | ||
$choices = $this->getChoices(); | ||
if (!isset($choices[$name])) { | ||
throw new \LogicException(sprintf('Unknown payment option with name "%s"', $name)); | ||
} | ||
|
||
return $choices[$name]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
parameters: | ||
dmkclub.form.type.payment_options.class: DMKClub\Bundle\PaymentBundle\Form\Type\PaymentOptionsType | ||
services: | ||
dmkclub.form.type.payment_options: | ||
class: "%dmkclub.form.type.payment_options.class%" | ||
arguments: | ||
- @dmkclub.payment.options_provider | ||
tags: | ||
- { name: form.type, alias: dmkclub_paymentoptions } |
Oops, something went wrong.