LogEntryType::getBlockPrefix()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Setono\SyliusLogEntryPlugin\Form\Type;
6
7
use function Safe\sprintf;
8
use Setono\SyliusLogEntryPlugin\Model\LogEntry;
9
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
10
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
11
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
12
use Symfony\Component\Form\FormBuilderInterface;
13
14
class LogEntryType extends AbstractResourceType
15
{
16
    public function buildForm(FormBuilderInterface $builder, array $options): void
17
    {
18
        $builder
19
            ->add('level', ChoiceType::class, [
20
                'label' => 'setono_sylius_log_entry.form.log_entry.level',
21
                'choices' => LogEntry::getLevels(),
22
                'choice_label' => static function (string $level): string {
23
                    return sprintf('setono_sylius_log_entry.form.log_entry.levels.%s', $level);
24
                },
25
            ])
26
            ->add('message', TextareaType::class, [
27
                'label' => 'setono_sylius_log_entry.form.log_entry.message',
28
            ])
29
        ;
30
    }
31
32
    public function getBlockPrefix(): string
33
    {
34
        return 'setono_sylius_log_entry_log_entry';
35
    }
36
}
37