Failed Conditions
Push — master ( e0fde8...98a030 )
by
unknown
44:34 queued 15:21
created

QuoteItemSspAssetForm::addSspAssetField()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 8
rs 10
c 1
b 0
f 0
1
<?php
2
3
/**
4
 * Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerFeature\Yves\SelfServicePortal\Asset\Form;
9
10
use Spryker\Yves\Kernel\Form\AbstractType;
11
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
12
use Symfony\Component\Form\FormBuilderInterface;
13
use Symfony\Component\Validator\Constraints\NotBlank;
14
15
/**
16
 * @method \SprykerFeature\Yves\SelfServicePortal\SelfServicePortalConfig getConfig()
17
 */
18
class QuoteItemSspAssetForm extends AbstractType
19
{
20
    /**
21
     * @var string
22
     */
23
    public const FORM_NAME = 'quoteItemSspAsset';
24
25
    /**
26
     * @var string
27
     */
28
    public const FIELD_SSP_ASSET_REFERENCE = 'sspAssetReference';
29
30
    /**
31
     * @var string
32
     */
33
    public const FIELD_SKU = 'sku';
34
35
    /**
36
     * @var string
37
     */
38
    public const FIELD_GROUP_KEY = 'groupKey';
39
40
    public function getBlockPrefix(): string
41
    {
42
        return static::FORM_NAME;
43
    }
44
45
    /**
46
     * @param \Symfony\Component\Form\FormBuilderInterface $builder
47
     * @param array<string, mixed> $options
48
     *
49
     * @return void
50
     */
51
    public function buildForm(FormBuilderInterface $builder, array $options): void
52
    {
53
        $this->addSspAssetField($builder)
54
            ->addItemSkuField($builder)
55
            ->addGroupKeyField($builder);
56
    }
57
58
    /**
59
     * @param \Symfony\Component\Form\FormBuilderInterface $builder
60
     *
61
     * @return $this
62
     */
63
    protected function addSspAssetField(FormBuilderInterface $builder)
64
    {
65
        $builder->add(static::FIELD_SSP_ASSET_REFERENCE, HiddenType::class, [
66
            'label' => 'self_service_portal.asset.item_form.enter_asset_reference',
67
            'required' => false,
68
        ]);
69
70
        return $this;
71
    }
72
73
    /**
74
     * @param \Symfony\Component\Form\FormBuilderInterface $builder
75
     *
76
     * @return $this
77
     */
78
    protected function addItemSkuField(FormBuilderInterface $builder)
79
    {
80
        $builder->add(static::FIELD_SKU, HiddenType::class, [
81
            'required' => true,
82
            'constraints' => [
83
                new NotBlank(),
84
            ],
85
        ]);
86
87
        return $this;
88
    }
89
90
    /**
91
     * @param \Symfony\Component\Form\FormBuilderInterface $builder
92
     *
93
     * @return $this
94
     */
95
    protected function addGroupKeyField(FormBuilderInterface $builder)
96
    {
97
        $builder->add(static::FIELD_GROUP_KEY, HiddenType::class, [
98
            'required' => true,
99
            'constraints' => [
100
                new NotBlank(),
101
            ],
102
        ]);
103
104
        return $this;
105
    }
106
}
107