Proyectos de Subversion LeadersLinked - Backend

Rev

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

<?php

declare(strict_types=1);

namespace LeadersLinked\Form\Competency;

use Laminas\InputFilter\InputFilter;
use Laminas\Db\Adapter\AdapterInterface;
use LeadersLinked\Mapper\CompetencyTypeMapper;
use LeadersLinked\Mapper\BehaviorMapper;

class CompetencyFilter extends InputFilter
{

    /**
     * 
     * @param AdapterInterface $adapter
     */
    public function __construct(AdapterInterface $adapter)
    {
        $this->add([
            'name' => 'competency_type_id',
            'required' => true,
            'validators' => [
                [
                    'name' => \Laminas\Validator\NotEmpty::class,
                ],
                [
                    'name' => \LeadersLinked\Validator\RecordExistsMultiFields::class,
                    'options' => [
                        'adapter' => $adapter,
                        'table' => CompetencyTypeMapper::_TABLE,
                        'field' => 'uuid',
                        'custom_fields' => [
                            
                        ]
                    ]
                ]
            ],
        ]);
        
        $this->add([
            'name' => 'name',
            'required' => true,
            'filters' => [
                ['name' => \Laminas\Filter\StringTrim::class],
                ['name' => \Laminas\Filter\StripTags::class]
            ],
            'validators' => [
                [
                    'name' => \Laminas\Validator\StringLength::class,
                    'options' => [
                        'encoding' => 'UTF-8',
                        'max' => 128,
                    ],
                ],
                [
                    'name' => \Laminas\Validator\NotEmpty::class,
                ],
            ],
        ]);

        $this->add([
            'name' => 'description',
            'required' => true,
            'filters' => [
                ['name' => \Laminas\Filter\StringTrim::class],
                ['name' => \LeadersLinked\Filter\HtmlPurify::class],
                [
                    'name' => \Laminas\Filter\StripTags::class,
                    'options' => [
                        'allowTags'     => [
                            'h1','h2','h3','h4','h5','h6','p','strong','em','s','span','big','small','tt',
                            'hr','table','thead','tr','th','td','img', 'a','style'
                        ],
                    ]
                    
                ],
            ],
            'validators' => [
                [
                    'name' => \Laminas\Validator\StringLength::class,
                    'options' => [
                        'encoding' => 'UTF-8',
                        'max' => 512,
                    ],
                ],
                [
                    'name' => \Laminas\Validator\NotEmpty::class,
                ],

            ],
        ]);
        
        
        $this->add([
            'name' => 'behavior_id',
            'required' => true,
            'validators' => [
                [
                    'name' => \LeadersLinked\Validator\RecordExistsMultiValues::class,
                    'options' => [
                        'adapter' => $adapter,
                        'table' => BehaviorMapper::_TABLE,
                        'field' => 'uuid',
                        'custom_fields' => [
  
                        ]
                    ]
                ]
            ],
        ]);
        
        $this->add([
            'name' => 'status',
            'required' => false,
            'filters' => [
                ['name' => \Laminas\Filter\StripTags::class],
                ['name' => \Laminas\Filter\StringTrim::class],
            ],
            'validators' =>[
                [
                    'name' =>\Laminas\Validator\NotEmpty::class,
                ],
            ]
        ]);
        
       
        
    }
}