Skip to content

Commit

Permalink
⬆️ Symfony ~2.8|~3.0 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Leny BERNARD committed Mar 4, 2016
1 parent 6631fe2 commit 043adbf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 23 deletions.
3 changes: 2 additions & 1 deletion Controller/PaymentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use AppVentus\MangopayBundle\Entity\Order;
use AppVentus\MangopayBundle\Event\OrderEvent;
use AppVentus\MangopayBundle\Event\PreAuthorisationEvent;
use AppVentus\MangopayBundle\Form\CardType;
use AppVentus\MangopayBundle\OrderEvents;
use MangoPay\CardRegistration;
use MangoPay\PayIn;
Expand Down Expand Up @@ -36,7 +37,7 @@ public function newAction(Request $request, $order)
throw $this->createNotFoundException('Order not found');
}
//create card form
$form = $this->createForm('appventus_mangopaybundle_card_type');
$form = $this->createForm(CardType::class);
$form->handleRequest($request);

if ($form->isValid()) {
Expand Down
34 changes: 13 additions & 21 deletions Form/CardType.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
namespace AppVentus\MangopayBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\NotBlank;

Expand All @@ -16,7 +19,7 @@ class CardType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('cardNumber', 'text', array(
->add('cardNumber', TextType::class, array(
'constraints' => array(new NotBlank(['groups' => ['card']])),
'label' => 'appventus_mangopay.card_number.label',
'attr' => array(
Expand All @@ -25,7 +28,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
),
'mapped' => false
))
->add('cardHolder', 'text', array(
->add('cardHolder', TextType::class, array(
'constraints' => array(new NotBlank(['groups' => ['card']])),
'label' => 'appventus_mangopay.card_holder.label',
'attr' => array(
Expand All @@ -34,7 +37,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
),
'mapped' => false
))
->add('ccv', 'integer', array(
->add('ccv', IntegerType::class, array(
'constraints' => array(new NotBlank(['groups' => ['card']])),
'label' => 'appventus_mangopay.card_ccv.label',
'attr' => array(
Expand All @@ -43,23 +46,11 @@ public function buildForm(FormBuilderInterface $builder, array $options)
),
'mapped' => false
))
->add('cardExpiryMonth', 'choice', array(
->add('cardExpiryMonth', ChoiceType::class, array(
'constraints' => array(new NotBlank(['groups' => ['card']])),
'label' => 'appventus_mangopay.card_expiry_month.label',
'choices' => array(
"01" => "01",
"02" => "02",
"03" => "03",
"04" => "04",
"05" => "05",
"06" => "06",
"07" => "07",
"08" => "08",
"09" => "09",
"10" => "10",
"11" => "11",
"12" => "12",
),
'choices' => ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"],
'choices_as_values' => true,
'attr' => array(
'data-id' => 'appventus_mangopay_card_expiry_month',
'placeholder' => 'appventus_mangopay.card_expiry_month.placeholder',
Expand All @@ -75,9 +66,10 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$year = (int) $year + 1;
}

$builder->add('cardExpiryYear', 'choice', array(
'constraints' => array(new NotBlank(['groups' => ['card']])),
$builder->add('cardExpiryYear', ChoiceType::class, array(
'constraints' => array(new NotBlank(['groups' => ['card']])),
'choices' => $years,
'choices_as_values' => true,
'attr' => array(
'data-id' => 'appventus_mangopay_card_expiry_year',
'placeholder' => 'appventus_mangopay.card_expiry_year.placeholder',
Expand All @@ -92,7 +84,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
/**
* @return string
*/
public function getName()
public function getBlockPrefix()
{
return 'appventus_mangopaybundle_card_type';
}
Expand Down
2 changes: 1 addition & 1 deletion Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ services:
appventus_mangopay.form.card:
class: %appventus_mangopay.form.card%
tags:
- { name: form.type, alias: appventus_mangopaybundle_card_type }
- { name: form.type }

0 comments on commit 043adbf

Please sign in to comment.