Completed
Push — master ( 0fb6c2...a0d538 )
by Adam
19:02
created

ShipmentFormBuilder::buildForm()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 35
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 35
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 24
nc 1
nop 1
1
<?php
2
/*
3
 * WellCommerce Open-Source E-Commerce Platform
4
 *
5
 * This file is part of the WellCommerce package.
6
 *
7
 * (c) Adam Piotrowski <[email protected]>
8
 *
9
 * For the full copyright and license information,
10
 * please view the LICENSE file that was distributed with this source code.
11
 */
12
namespace WellCommerce\Bundle\ShipmentBundle\Form\Admin;
13
14
use WellCommerce\Bundle\CoreBundle\Form\AbstractFormBuilder;
15
use WellCommerce\Component\Form\Elements\FormInterface;
16
17
/**
18
 * Class ShipmentFormBuilder
19
 *
20
 * @author  Adam Piotrowski <[email protected]>
21
 */
22
class ShipmentFormBuilder extends AbstractFormBuilder
23
{
24
    public function getAlias(): string
25
    {
26
        return 'admin.shipment';
27
    }
28
    
29
    public function buildForm(FormInterface $form)
30
    {
31
        $orderStatuses = $this->get('order_status.dataset.admin')->getResult('select');
32
        
33
        $requiredData = $form->addChild($this->getElement('nested_fieldset', [
34
            'name'  => 'required_data',
35
            'label' => 'common.fieldset.general',
36
        ]));
37
    
38
        $requiredData->addChild($this->getElement('hidden', [
39
            'name'  => 'guid',
40
            'label' => '',
41
        ]));
42
    
43
        $requiredData->addChild($this->getElement('hidden', [
44
            'name'  => 'courier',
45
            'label' => '',
46
        ]));
47
        
48
        $requiredData->addChild($this->getElement('select', [
49
            'name'        => 'orderStatus',
50
            'label'       => 'order_status_history.label.order_status',
51
            'options'     => $orderStatuses,
52
            'transformer' => $this->getRepositoryTransformer('entity', $this->get('order_status.repository')),
53
        ]))->setValue(12);
54
        
55
        $requiredData->addChild($this->getElement('checkbox', [
56
            'name'  => 'notify',
57
            'label' => 'order_status_history.label.nofity',
58
        ]))->setValue(1);
59
        
60
        $form->addFilter($this->getFilter('no_code'));
61
        $form->addFilter($this->getFilter('trim'));
62
        $form->addFilter($this->getFilter('secure'));
63
    }
64
}
65