-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApiTokenFormType.php
More file actions
72 lines (68 loc) · 1.88 KB
/
ApiTokenFormType.php
File metadata and controls
72 lines (68 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
namespace SyncEngine\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use SyncEngine\Entity\ApiToken;
use SyncEngine\Form\Type\JsonType;
class ApiTokenFormType extends AbstractType
{
public function buildForm( FormBuilderInterface $builder, array $options ): void
{
$builder
->add( 'token', TextType::class, [
'row_attr' => [
'class' => 'form-floating mb-3',
],
] )
->add( 'description', TextType::class, [
'row_attr' => [
'class' => 'form-floating mb-3',
],
] )
->add( 'expires', DateTimeType::class, [
'row_attr' => [
'class' => 'form-floating mb-3',
],
'widget' => 'single_text',
] )
->add( 'config', JsonType::class, [
'row_attr' => [
'class' => 'form-floating mb-3',
],
'attr' => [
'data-controller' => 'react',
'data-type' => 'fields',
'data-args' => json_encode( [
'fields' => [
'restrictions' => [
'label' => 'Restrictions',
'icon' => 'restrict',
'description' => 'Restrictions limit an API key’s usage and improves security',
'nested' => [
'ip' => [
'label' => 'Restrict by IP addresses',
'type' => 'text',
'placeholder' => '0.0.0.0, 0.0.0.0',
],
'host' => [
'label' => 'Restrict by host domains',
'type' => 'text',
'placeholder' => 'domain.com, sub.domain.ext, *.wildcard.com',
],
]
]
],
] ),
]
] );
}
public function configureOptions( OptionsResolver $resolver ): void
{
$resolver->setDefaults( [
'data_class' => ApiToken::class,
] );
}
}