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

ShipmentFormBuilder   A

Coupling/Cohesion

Components 1
Dependencies 3

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 43
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAlias() 0 4 1
B buildForm() 0 35 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