|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @author Rafał Muszyński <[email protected]> |
|
5
|
|
|
* @copyright 2013 Sourcefabric o.p.s. |
|
6
|
|
|
* @license http://www.gnu.org/licenses/gpl-3.0.txt |
|
7
|
|
|
*/ |
|
8
|
|
|
namespace Newscoop\PaywallBundle\Form\Type; |
|
9
|
|
|
|
|
10
|
|
|
use Symfony\Component\Form\AbstractType; |
|
11
|
|
|
use Symfony\Component\Form\FormBuilderInterface; |
|
12
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolverInterface; |
|
13
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
14
|
|
|
|
|
15
|
|
|
class SubscriptionConfType extends AbstractType |
|
16
|
|
|
{ |
|
17
|
|
|
public function buildForm(FormBuilderInterface $builder, array $options) |
|
18
|
|
|
{ |
|
19
|
|
|
$builder |
|
20
|
|
|
->add('name', null, array( |
|
21
|
|
|
'label' => 'paywall.step1.form.label.name', |
|
22
|
|
|
'error_bubbling' => true, |
|
23
|
|
|
'invalid_message' => 'paywall.step1.form.error.name', |
|
24
|
|
|
)) |
|
25
|
|
|
->add('description', 'textarea', array( |
|
26
|
|
|
'label' => 'paywall.step1.form.label.description', |
|
27
|
|
|
'required' => false, |
|
28
|
|
|
'error_bubbling' => true, |
|
29
|
|
|
)) |
|
30
|
|
|
->add('type', 'choice', array( |
|
31
|
|
|
'label' => 'paywall.step1.form.label.type', |
|
32
|
|
|
'choices' => array( |
|
33
|
|
|
'publication' => 'paywall.step1.form.select.type.publication', |
|
34
|
|
|
'issue' => 'paywall.step1.form.select.type.issue', |
|
35
|
|
|
'section' => 'paywall.step1.form.select.type.section', |
|
36
|
|
|
'article' => 'paywall.step1.form.select.type.article', |
|
37
|
|
|
), |
|
38
|
|
|
)) |
|
39
|
|
|
->add('isTemplate', 'checkbox', array( |
|
40
|
|
|
'label' => 'paywall.step1.form.label.istemplate', |
|
41
|
|
|
'required' => false, |
|
42
|
|
|
)) |
|
43
|
|
|
->add('price', null, array( |
|
44
|
|
|
'label' => 'paywall.step1.form.label.price', |
|
45
|
|
|
'error_bubbling' => true, |
|
46
|
|
|
'required' => true, |
|
47
|
|
|
'precision' => 2, |
|
48
|
|
|
'invalid_message' => 'paywall.step1.form.error.price', |
|
49
|
|
|
'constraints' => array( |
|
50
|
|
|
new Assert\Range(array( |
|
51
|
|
|
'min' => '0.01', |
|
52
|
|
|
'max' => '99999999.99', |
|
53
|
|
|
'minMessage' => 'paywall.errors.price.min', |
|
54
|
|
|
'maxMessage' => 'paywall.errors.price.max', |
|
55
|
|
|
)), |
|
56
|
|
|
), |
|
57
|
|
|
)); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function setDefaultOptions(OptionsResolverInterface $resolver) |
|
61
|
|
|
{ |
|
62
|
|
|
$resolver->setDefaults(array( |
|
63
|
|
|
'data_class' => 'Newscoop\PaywallBundle\Entity\Subscription', |
|
64
|
|
|
'csrf_protection' => false, |
|
65
|
|
|
)); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function getName() |
|
69
|
|
|
{ |
|
70
|
|
|
return 'subscriptionconf'; |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|