Skip to content

Commit

Permalink
#1 payment options, honorary and free of charge
Browse files Browse the repository at this point in the history
  • Loading branch information
digedag committed Oct 8, 2015
1 parent 7db544b commit 7b51d68
Show file tree
Hide file tree
Showing 13 changed files with 327 additions and 5 deletions.
96 changes: 92 additions & 4 deletions src/DMKClub/Bundle/MemberBundle/Entity/Member.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,20 @@ class Member extends ExtendMember implements Taggable, ChannelAwareInterface, Cu
*/
protected $isActive = false;

/**
* @var boolean
*
* @ORM\Column(type="boolean", name="is_honorary")
*/
protected $isHonorary = false;

/**
* @var boolean
*
* @ORM\Column(type="boolean", name="is_free_of_charge")
*/
protected $isFreeOfCharge = false;

/**
* @var string
*
Expand All @@ -219,6 +233,21 @@ class Member extends ExtendMember implements Taggable, ChannelAwareInterface, Cu
*/
protected $status;

/**
* @var string
*
* @ORM\Column(name="payment_option", type="string", length=20, nullable=true)
* @Soap\ComplexType("string", nillable=true)
* @Oro\Versioned
* @ConfigField(
* defaultValues={
* "dataaudit"={
* "auditable"=true
* }
* }
* )
*/
protected $paymentOption;

/**
* @var Address $postalAddress
Expand Down Expand Up @@ -321,7 +350,7 @@ public function getName()
/**
* @param Contact $contact
*
* @return Customer
* @return Member
*/
public function setContact($contact)
{
Expand All @@ -338,6 +367,46 @@ public function getContact()
return $this->contact;
}

/**
* @param bool $isFreeOfCharge
*
* @return Member
*/
public function setIsHonorary($isHonorary)
{
$this->isHonorary = $isHonorary;

return $this;
}

/**
* @return bool
*/
public function getIsHonorary()
{
return $this->isHonorary;
}

/**
* @param bool $isFreeOfCharge
*
* @return Member
*/
public function setIsFreeOfCharge($isFreeOfCharge)
{
$this->isFreeOfCharge = $isFreeOfCharge;

return $this;
}

/**
* @return bool
*/
public function getIsFreeOfCharge()
{
return $this->isFreeOfCharge;
}

/**
* @param bool $isActive
*
Expand Down Expand Up @@ -366,11 +435,28 @@ public function getStatus() {
}

/**
*
* @param string $value
* @return Member
*/
public function setStatus($value) {
$this->status = $value;
return $this;
}

/**
* @return string
*/
public function getPaymentOption() {
return $this->paymentOption;
}

/**
* @param string $value
* @return Member
*/
public function setPaymentOption($value) {
$this->paymentOption = $value;
return $this;
}

/**
Expand All @@ -387,6 +473,7 @@ public function getPostalAddress()
public function setPostalAddress(Address $address)
{
$this->postalAddress = $address;
return $this;
}

/**
Expand All @@ -403,13 +490,14 @@ public function getOwner()
public function setOwner(User $user)
{
$this->owner = $user;
return $this;
}

/**
* Set organization
*
* @param Organization $organization
* @return Customer
* @return Member
*/
public function setOrganization(Organization $organization = null)
{
Expand All @@ -431,7 +519,7 @@ public function getOrganization()
/**
* @param Account $account
*
* @return Customer
* @return Member
*/
public function setAccount($account) {
$this->account = $account;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class DMKClubMemberBundle implements Migration
* - Antragssteller
* - aktives Mitglied
* - Ex-Mitglied
* PaymentStatus, Ehrenmitglied und beitragsfrei
*
*
* @inheritdoc
Expand All @@ -26,7 +27,10 @@ class DMKClubMemberBundle implements Migration
public function up(Schema $schema, QueryBag $queries)
{
$table = $schema->getTable('dmkclub_member');
$table->addColumn('status', 'string', ['notnull' => false, 'length' => 8]);
$table->addColumn('status', 'string', ['notnull' => false, 'length' => 20]);
$table->addColumn('payment_option', 'string', ['notnull' => false, 'length' => 20]);
$table->addColumn('is_honorary', 'boolean', []);
$table->addColumn('is_free_of_charge', 'boolean', []);
}


Expand Down
9 changes: 9 additions & 0 deletions src/DMKClub/Bundle/PaymentBundle/DMKClubPaymentBundle.php
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
{
}
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;
}
}
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 src/DMKClub/Bundle/PaymentBundle/Form/Type/PaymentOptionsType.php
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
)
);
}
}
9 changes: 9 additions & 0 deletions src/DMKClub/Bundle/PaymentBundle/Model/PaymentOption.php
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';
}
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];
}
}
9 changes: 9 additions & 0 deletions src/DMKClub/Bundle/PaymentBundle/Resources/config/form.yml
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 }
Loading

0 comments on commit 7b51d68

Please sign in to comment.