• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

systemsdk / docker-symfony-api / #140

15 Apr 2025 03:38PM UTC coverage: 43.903%. Remained the same
#140

push

DKravtsov
Updated composer dependencies.

1631 of 3715 relevant lines covered (43.9%)

18.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/ApiKey/Transport/Form/Type/Console/ApiKeyType.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace App\ApiKey\Transport\Form\Type\Console;
6

7
use App\ApiKey\Application\DTO\ApiKey\ApiKey;
8
use App\General\Transport\Form\Type\Interfaces\FormTypeLabelInterface;
9
use App\General\Transport\Form\Type\Traits\AddBasicFieldToForm;
10
use App\User\Application\Resource\UserGroupResource;
11
use App\User\Transport\Form\DataTransformer\UserGroupTransformer;
12
use App\User\Transport\Form\Type\Traits\UserGroupChoices;
13
use Override;
14
use Symfony\Component\Form\AbstractType;
15
use Symfony\Component\Form\Extension\Core\Type;
16
use Symfony\Component\Form\FormBuilderInterface;
17
use Symfony\Component\OptionsResolver\Exception\AccessException;
18
use Symfony\Component\OptionsResolver\OptionsResolver;
19
use Throwable;
20

21
/**
22
 * @package App\ApiKey
23
 */
24
class ApiKeyType extends AbstractType
25
{
26
    use AddBasicFieldToForm;
27
    use UserGroupChoices;
28

29
    /**
30
     * Base form fields
31
     *
32
     * @var array<int, array<int, mixed>>
33
     */
34
    private static array $formFields = [
35
        [
36
            'description',
37
            Type\TextType::class,
38
            [
39
                FormTypeLabelInterface::LABEL => 'Description',
40
                FormTypeLabelInterface::REQUIRED => true,
41
                FormTypeLabelInterface::EMPTY_DATA => '',
42
            ],
43
        ],
44
    ];
45

46
    public function __construct(
47
        private readonly UserGroupResource $userGroupResource,
48
        private readonly UserGroupTransformer $userGroupTransformer,
49
    ) {
50
    }
×
51

52
    /**
53
     * {@inheritdoc}
54
     *
55
     * @throws Throwable
56
     */
57
    #[Override]
58
    public function buildForm(FormBuilderInterface $builder, array $options): void
59
    {
60
        parent::buildForm($builder, $options);
×
61

62
        $this->addBasicFieldToForm($builder, self::$formFields);
×
63

64
        $builder
×
65
            ->add(
×
66
                'userGroups',
×
67
                Type\ChoiceType::class,
×
68
                [
×
69
                    'choices' => $this->getUserGroupChoices(),
×
70
                    'multiple' => true,
×
71
                    'required' => true,
×
72
                    'empty_data' => '',
×
73
                ],
×
74
            );
×
75

76
        $builder->get('userGroups')->addModelTransformer($this->userGroupTransformer);
×
77
    }
78

79
    /**
80
     * Configures the options for this type.
81
     *
82
     * @throws AccessException
83
     */
84
    #[Override]
85
    public function configureOptions(OptionsResolver $resolver): void
86
    {
87
        parent::configureOptions($resolver);
×
88

89
        $resolver->setDefaults([
×
90
            'data_class' => ApiKey::class,
×
91
        ]);
×
92
    }
93
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc