Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 15831 | Ir a la última revisión | | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
15459 efrain 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Form\Network;
6
 
7
use Laminas\Form\Form;
8
use Laminas\Db\Adapter\AdapterInterface;
9
use Laminas\Log\LoggerInterface;
10
use LeadersLinked\Mapper\ThemeMapper;
11
use LeadersLinked\Model\Network;
12
 
13
class NetworkEditForm extends Form
14
{
15
 
16
    /**
17
     *
18
     * @param AdapterInterface $adapter
19
     */
20
    public function __construct($adapter)
21
    {
22
 
23
        parent::__construct();
24
        $this->setInputFilter(new NetworkEditFilter($adapter));
25
 
26
 
27
        $this->add([
28
            'name' => 'name',
29
            'type' => \Laminas\Form\Element\Text::class,
30
             'attributes' => [
31
                'maxlength' 	=> 128,
32
                'id' 			=> 'name',
33
            ]
34
         ]);
35
 
36
        $this->add([
37
            'name' => 'main_hostname',
38
            'type' => \Laminas\Form\Element\Text::class,
39
            'attributes' => [
40
                'maxlength' 	=> 250,
41
                'id' 			=> 'main_hostname',
42
            ]
43
        ]);
44
 
45
        $this->add([
46
            'name' => 'alternative_hostname',
47
            'type' => \Laminas\Form\Element\Text::class,
48
            'attributes' => [
49
                'maxlength' 	=> 250,
50
                'id' 			=> 'alternative_hostname',
51
            ]
52
        ]);
53
 
54
 
55
 
56
        $this->add([
57
            'name' => 'admin_hostname',
58
            'type' => \Laminas\Form\Element\Text::class,
59
            'attributes' => [
60
                'maxlength' 	=> 250,
61
                'id' 			=> 'admin_hostname',
62
            ]
63
        ]);
64
 
65
        $this->add([
66
            'name' => 'status',
67
            'type' => \Laminas\Form\Element\Checkbox::class,
68
            'attributes' => [
69
                'id' 			=> 'status',
70
            ],
71
            'options' => [
72
                'use_hidden_element' => 0,
73
                'unchecked_value' => \LeadersLinked\Model\Network::STATUS_INACTIVE,
74
                'checked_value'=> \LeadersLinked\Model\Network::STATUS_ACTIVE,
75
            ]
76
        ]);
77
 
78
        $this->add([
79
            'name' => 'moodle_url',
80
            'type' => \Laminas\Form\Element\Text::class,
81
            'attributes' => [
82
                'maxlength' 	=> 250,
83
                'id' 			=> 'moodle_url',
84
            ]
85
        ]);
86
 
87
 
88
        $this->add([
89
            'name' => 'relationship_user_mode',
90
            'type' => \Laminas\Form\Element\Select::class,
91
            'attributes' => [
92
                'id' => 'relationship_user_mode',
93
            ],
94
            'options' => [
95
                'value_options' => [
96
                    Network::RELATIONSHIP_USER_MODE_USER_2_USER => 'LABEL_RELATIONSHIP_USER_MODE_USER_2_USER',
97
                    Network::RELATIONSHIP_USER_MODE_ALL_2_ALL => 'LABEL_RELATIONSHIP_USER_MODE_ALL_2_ALL',
98
                ]
99
            ]
100
        ]);
101
 
102
 
103
        $this->add([
104
            'name' => 'theme_id',
105
            'type' => \Laminas\Form\Element\Select::class,
106
            'attributes' => [
107
                'id' => 'theme_id',
108
            ],
109
            'options' => [
110
                'disable_inarray_validator' => true,
111
                'value_options' => $this->optionsTheme($adapter)
112
            ]
113
        ]);
114
 
115
 
116
    }
117
 
118
    /**
119
     *
120
     * @param AdapterInterface $adapter
121
     */
122
    private function optionsTheme($adapter)
123
    {
124
        $options = [];
125
 
126
        $mapper = ThemeMapper::getInstance($adapter);
127
        $records = $mapper->fetchAll();
128
 
129
        foreach($records as $record)
130
        {
131
            $options[$record->uuid] = $record->name;
132
        }
133
        return $options;
134
    }
135
 
136
 
137
 
138
}