Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16770 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
15446 efrain 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Form\Competency;
6
 
7
use Laminas\InputFilter\InputFilter;
8
use Laminas\Db\Adapter\AdapterInterface;
9
use LeadersLinked\Mapper\CompetencyTypeMapper;
10
use LeadersLinked\Mapper\BehaviorMapper;
11
 
12
class CompetencyFilter extends InputFilter
13
{
14
 
15
    /**
16
     *
17
     * @param AdapterInterface $adapter
18
     */
19
    public function __construct(AdapterInterface $adapter)
20
    {
21
        $this->add([
22
            'name' => 'competency_type_id',
23
            'required' => true,
24
            'validators' => [
25
                [
26
                    'name' => \Laminas\Validator\NotEmpty::class,
27
                ],
28
                [
29
                    'name' => \LeadersLinked\Validator\RecordExistsMultiFields::class,
30
                    'options' => [
31
                        'adapter' => $adapter,
32
                        'table' => CompetencyTypeMapper::_TABLE,
33
                        'field' => 'uuid',
34
                        'custom_fields' => [
35
 
36
                        ]
37
                    ]
38
                ]
39
            ],
40
        ]);
41
 
42
        $this->add([
43
            'name' => 'name',
44
            'required' => true,
45
            'filters' => [
46
                ['name' => \Laminas\Filter\StringTrim::class],
17002 efrain 47
                ['name' => \Laminas\Filter\StripTags::class]
15446 efrain 48
            ],
49
            'validators' => [
50
                [
51
                    'name' => \Laminas\Validator\StringLength::class,
52
                    'options' => [
53
                        'encoding' => 'UTF-8',
54
                        'max' => 128,
55
                    ],
56
                ],
57
                [
58
                    'name' => \Laminas\Validator\NotEmpty::class,
59
                ],
60
            ],
61
        ]);
62
 
63
        $this->add([
64
            'name' => 'description',
65
            'required' => true,
66
            'filters' => [
67
                ['name' => \Laminas\Filter\StringTrim::class],
17002 efrain 68
                ['name' => \LeadersLinked\Filter\HtmlPurify::class],
69
                [
70
                    'name' => \Laminas\Filter\StripTags::class,
71
                    'options' => [
72
                        'allowTags'     => [
73
                            'h1','h2','h3','h4','h5','h6','p','strong','em','s','span','big','small','tt',
74
                            'hr','table','thead','tr','th','td','img', 'a','style'
75
                        ],
76
                    ]
77
 
78
                ],
15446 efrain 79
            ],
80
            'validators' => [
81
                [
82
                    'name' => \Laminas\Validator\StringLength::class,
83
                    'options' => [
84
                        'encoding' => 'UTF-8',
85
                        'max' => 512,
86
                    ],
87
                ],
88
                [
89
                    'name' => \Laminas\Validator\NotEmpty::class,
90
                ],
91
 
92
            ],
93
        ]);
94
 
95
 
96
        $this->add([
97
            'name' => 'behavior_id',
98
            'required' => true,
99
            'validators' => [
100
                [
101
                    'name' => \LeadersLinked\Validator\RecordExistsMultiValues::class,
102
                    'options' => [
103
                        'adapter' => $adapter,
104
                        'table' => BehaviorMapper::_TABLE,
105
                        'field' => 'uuid',
106
                        'custom_fields' => [
107
 
108
                        ]
109
                    ]
110
                ]
111
            ],
112
        ]);
113
 
114
        $this->add([
115
            'name' => 'status',
116
            'required' => false,
117
            'filters' => [
118
                ['name' => \Laminas\Filter\StripTags::class],
119
                ['name' => \Laminas\Filter\StringTrim::class],
120
            ],
121
            'validators' =>[
122
                [
123
                    'name' =>\Laminas\Validator\NotEmpty::class,
124
                ],
125
            ]
126
        ]);
127
 
128
 
129
 
130
    }
131
}