Proyectos de Subversion LeadersLinked - Backend

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
15341 efrain 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Form;
6
 
7
use Laminas\Form\Form;
8
use Laminas\Db\Adapter\AdapterInterface;
9
use Laminas\Log\LoggerInterface;
10
use LeadersLinked\Mapper\CompanySizeMapper;
11
use LeadersLinked\Mapper\IndustryMapper;
12
 
13
class NetworkCreateForm extends Form
14
{
15
    /**
16
     *
17
     * @param AdapterInterface $adapter
18
     */
19
    public function __construct($adapter)
20
    {
21
 
22
        parent::__construct();
23
        $this->setInputFilter(new NetworkCreateFilter($adapter));
24
 
25
        $this->add([
26
            'name' => 'first_name',
27
            'type' => \Laminas\Form\Element\Text::class,
28
            'attributes' => [
29
                'maxlength' 	=> 64,
30
                'id' 			=> 'first_name',
31
            ]
32
        ]);
33
        $this->add([
34
            'name' => 'last_name',
35
            'type' => \Laminas\Form\Element\Text::class,
36
            'attributes' => [
37
                'maxlength' 	=> 64,
38
                'id' 			=> 'last_name',
39
            ]
40
        ]);
41
        $this->add([
42
            'name' => 'email',
43
            'type' => \Laminas\Form\Element\Text::class,
44
            'attributes' => [
45
                'maxlength' 	=> 64,
46
                'id' 			=> 'email',
47
            ]
48
        ]);
49
        $this->add([
50
            'name' => 'password',
51
            'type' => \Laminas\Form\Element\Text::class,
52
            'attributes' => [
53
                'maxlength' 	=> 16,
54
                'id' 			=> 'password',
55
            ]
56
        ]);
57
        $this->add([
58
            'name' => 'confirmation',
59
            'type' => \Laminas\Form\Element\Text::class,
60
            'attributes' => [
61
                'maxlength' 	=> 16,
62
                'id' 			=> 'confirmation',
63
            ]
64
        ]);
65
 
66
        $this->add([
67
            'name' => 'company',
68
            'type' => \Laminas\Form\Element\Text::class,
69
             'attributes' => [
70
                'maxlength' 	=> 128,
71
                'id' 			=> 'company',
72
            ]
73
         ]);
74
        $this->add([
75
             'name' => 'industry_id',
76
             'type' => \Laminas\Form\Element\Select::class,
77
             'options' => [
78
                 'value_options' => $this->optionsIndustry($adapter),
79
             ],
80
             'attributes' => [
81
                 'id' => 'industry_id',
82
             ]
83
         ]);
84
        $this->add([
85
            'name' => 'company_size_id',
86
            'type' => \Laminas\Form\Element\Select::class,
87
            'options' => [
88
                'value_options' => $this->optionsCompanySize($adapter),
89
            ],
90
            'attributes' => [
91
                'id' => 'company_size_id',
92
            ]
93
        ]);
94
        $this->add([
95
            'name' => 'main_hostname',
96
            'type' => \Laminas\Form\Element\Text::class,
97
            'attributes' => [
98
                'maxlength' 	=> 250,
99
                'id' 			=> 'admin_hostname',
100
            ]
101
        ]);
102
        $this->add([
103
            'name' => 'admin_hostname',
104
            'type' => \Laminas\Form\Element\Text::class,
105
            'attributes' => [
106
                'maxlength' 	=> 250,
107
                'id' 			=> 'admin_hostname',
108
            ]
109
        ]);
110
    }
111
 
112
    /**
113
     *
114
     * @param AdapterInterface $adapter
115
     * @param LoggerInterface $logger
116
     * @return array
117
     */
118
    private function optionsCompanySize($adapter)
119
    {
120
        $companySizeMapper = CompanySizeMapper::getInstance($adapter);
121
        $companySizes = $companySizeMapper->fetchAllActive();
122
 
123
        $options = [];
124
        foreach($companySizes as $companySize)
125
        {
126
            $options[$companySize->uuid] = $companySize->name . ' ( ' . $companySize->minimum_no_of_employee . ' - ' . $companySize->maximum_no_of_employee . ' )';
127
        }
128
 
129
        return $options;
130
    }
131
 
132
    /**
133
     *
134
     * @param AdapterInterface $adapter
135
     * @return array
136
     */
137
    private function optionsIndustry($adapter)
138
    {
139
        $industryMapper = IndustryMapper::getInstance($adapter);
140
        $industries  = $industryMapper->fetchAllActive();
141
 
142
        $options = [];
143
        foreach($industries as $industry)
144
        {
145
            $options[$industry->uuid] = $industry->name;
146
        }
147
 
148
        return $options;
149
    }
150
 
151
}