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

systemsdk / docker-symfony-api / #74

pending completion
#74

push

DKravtsov
Php 8.2, symfony 6.2, updated RabbitMQ, updated composer dependencies, refactoring.

51 of 51 new or added lines in 44 files covered. (100.0%)

1479 of 2668 relevant lines covered (55.43%)

23.59 hits per line

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

0.0
/src/User/Transport/Form/Type/Console/UserGroupType.php
1
<?php
2

3
declare(strict_types=1);
4

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

7
use App\General\Transport\Form\Type\Interfaces\FormTypeLabelInterface;
8
use App\General\Transport\Form\Type\Traits\AddBasicFieldToForm;
9
use App\Role\Application\Resource\RoleResource;
10
use App\Role\Application\Security\RolesService;
11
use App\Role\Domain\Entity\Role as RoleEntity;
12
use App\Role\Transport\Form\DataTransformer\RoleTransformer;
13
use App\User\Application\DTO\UserGroup\UserGroup;
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
 * Class UserGroupType
23
 *
24
 * @package App\User
25
 */
26
class UserGroupType extends AbstractType
27
{
28
    use AddBasicFieldToForm;
29

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

47
    public function __construct(
48
        private readonly RolesService $rolesService,
49
        private readonly RoleResource $roleResource,
50
        private readonly RoleTransformer $roleTransformer,
51
    ) {
52
    }
×
53

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

63
        $this->addBasicFieldToForm($builder, self::$formFields);
×
64
        $builder
×
65
            ->add(
×
66
                'role',
×
67
                Type\ChoiceType::class,
×
68
                [
×
69
                    FormTypeLabelInterface::LABEL => 'Role',
×
70
                    FormTypeLabelInterface::CHOICES => $this->getRoleChoices(),
×
71
                    FormTypeLabelInterface::REQUIRED => true,
×
72
                ],
×
73
            );
×
74
        $builder->get('role')->addModelTransformer($this->roleTransformer);
×
75
    }
76

77
    /**
78
     * Configures the options for this type.
79
     *
80
     * @throws AccessException
81
     */
82
    public function configureOptions(OptionsResolver $resolver): void
83
    {
84
        parent::configureOptions($resolver);
×
85

86
        $resolver->setDefaults([
×
87
            'data_class' => UserGroup::class,
×
88
        ]);
×
89
    }
90

91
    /**
92
     * Method to get choices array for user groups.
93
     *
94
     * @throws Throwable
95
     *
96
     * @return array<string, string>
97
     */
98
    public function getRoleChoices(): array
99
    {
100
        // Initialize output
101
        $choices = [];
×
102
        $iterator = function (RoleEntity $role) use (&$choices): void {
×
103
            $choices[$this->rolesService->getRoleLabel($role->getId())] = $role->getId();
×
104
        };
×
105

106
        array_map($iterator, $this->roleResource->find());
×
107

108
        return $choices;
×
109
    }
110
}
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