Failed Conditions
Push — issue#767 ( b130a3...4d8d6b )
by Guilherme
11:45 queued 06:37
created

ClientMetadataForm::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the login-cidadao project or it's bundles.
4
 *
5
 * (c) Guilherme Donato <guilhermednt on github>
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
namespace LoginCidadao\OpenIDBundle\Form;
12
13
use LoginCidadao\OpenIDBundle\Manager\ClientManager;
14
use Symfony\Component\Form\AbstractType;
15
use Symfony\Component\Form\FormBuilderInterface;
16
use Symfony\Component\Form\FormEvent;
17
use Symfony\Component\Form\FormEvents;
18
use Symfony\Component\OptionsResolver\OptionsResolver;
19
20
class ClientMetadataForm extends AbstractType
21
{
22
    /** @var ClientManager */
23
    private $clientManager;
24
25
    /**
26
     * @inheritDoc
27
     */
28
    public function __construct(ClientManager $clientManager)
29
    {
30
        $this->clientManager = $clientManager;
31
    }
32
33
    public function buildForm(FormBuilderInterface $builder, array $options)
34
    {
35
        $builder
36
            ->add('client_id')
37
            ->add('client_secret')
38
            ->add('redirect_uris')
39
            ->add('post_logout_redirect_uris')
40
            ->add('response_types')
41
            ->add('grant_types')
42
            ->add('application_type')
43
            ->add('contacts')
44
            ->add('client_name')
45
            ->add('logo_uri', 'text')
46
            ->add('client_uri', 'text')
47
            ->add('policy_uri', 'text')
48
            ->add('tos_uri', 'text')
49
            ->add('jwks_uri')
50
            ->add('jwks')
51
            ->add('sector_identifier_uri', 'text')
52
            ->add('subject_type')
53
            ->add('id_token_signed_response_alg')
54
            ->add('id_token_encrypted_response_alg')
55
            ->add('id_token_encrypted_response_enc')
56
            ->add('userinfo_signed_response_alg')
57
            ->add('userinfo_encrypted_response_alg')
58
            ->add('userinfo_encrypted_response_enc')
59
            ->add('request_object_signing_alg')
60
            ->add('request_object_encryption_alg')
61
            ->add('request_object_encryption_enc')
62
            ->add('token_endpoint_auth_method')
63
            ->add('token_endpoint_auth_signing_alg')
64
            ->add('default_max_age')
65
            ->add('require_auth_time')
66
            ->add('default_acr_values')
67
            ->add('initiate_login_uri', 'text')
68
            ->add('request_uris')
69
            ->addEventListener(FormEvents::SUBMIT, [$this, 'onSubmit']);
70
    }
71
72
    public function configureOptions(OptionsResolver $resolver)
73
    {
74
        parent::configureOptions($resolver);
75
        $resolver->setDefaults([
76
            'data_class' => 'LoginCidadao\OpenIDBundle\Entity\ClientMetadata',
77
            'csrf_protection' => false,
78
        ]);
79
    }
80
81
    public function onSubmit(FormEvent $event)
82
    {
83
        $data = $this->clientManager->populateNewMetadata($event->getData());
84
85
        $event->setData($data);
86
    }
87
88
    public function getName()
89
    {
90
        return '';
91
    }
92
}
93