1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of the FreshSinchBundle |
4
|
|
|
* |
5
|
|
|
* (c) Artem Henvald <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
declare(strict_types=1); |
12
|
|
|
|
13
|
|
|
namespace Fresh\SinchBundle\Form\Type; |
14
|
|
|
|
15
|
|
|
use Fresh\SinchBundle\Model\CallbackRequest; |
16
|
|
|
use Symfony\Component\Form\AbstractType; |
17
|
|
|
use Symfony\Component\Form\Extension\Core\Type as CoreType; |
18
|
|
|
use Symfony\Component\Form\FormBuilderInterface; |
19
|
|
|
use Symfony\Component\HttpFoundation\Request; |
20
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* CallbackRequestType. |
24
|
|
|
* |
25
|
|
|
* @author Artem Henvald <[email protected]> |
26
|
|
|
*/ |
27
|
|
|
class CallbackRequestType extends AbstractType |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* {@inheritdoc} |
31
|
|
|
*/ |
32
|
|
|
public function buildForm(FormBuilderInterface $builder, array $options): void |
33
|
|
|
{ |
34
|
|
|
$builder |
35
|
|
|
->add('event', CoreType\ChoiceType::class, [ |
36
|
|
|
'choices' => [ |
37
|
|
|
'incomingSms' => 'incomingSms', |
38
|
|
|
], |
39
|
|
|
'required' => true, |
40
|
|
|
]) |
41
|
|
|
->add('to', IdentityType::class, [ |
42
|
|
|
'required' => true, |
43
|
|
|
]) |
44
|
|
|
->add('from', IdentityType::class, [ |
45
|
|
|
'required' => true, |
46
|
|
|
]) |
47
|
|
|
->add('message', CoreType\TextType::class, [ |
48
|
|
|
'required' => true, |
49
|
|
|
]) |
50
|
|
|
->add('timestamp', CoreType\DateTimeType::class, [ |
51
|
|
|
'widget' => 'single_text', |
52
|
|
|
'required' => true, |
53
|
|
|
]) |
54
|
|
|
->add('version', CoreType\IntegerType::class, [ |
55
|
|
|
'required' => true, |
56
|
|
|
]); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* {@inheritdoc} |
61
|
|
|
*/ |
62
|
|
|
public function configureOptions(OptionsResolver $resolver): void |
63
|
|
|
{ |
64
|
|
|
$resolver->setDefaults([ |
65
|
|
|
'data_class' => CallbackRequest::class, |
66
|
|
|
'csrf_protection' => false, |
67
|
|
|
'method' => Request::METHOD_POST, |
68
|
|
|
]); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* {@inheritdoc} |
73
|
|
|
*/ |
74
|
|
|
public function getBlockPrefix(): string |
75
|
|
|
{ |
76
|
|
|
return ''; |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|