Proyectos de Subversion LeadersLinked - Backend

Rev

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

<?php

declare(strict_types=1);

namespace LeadersLinked\Form\DiscoveryContact;

use Laminas\InputFilter\InputFilter;
use Laminas\Db\Adapter\Adapter;
use LeadersLinked\Mapper\DiscoveryContactMapper;

class ContactFilter extends InputFilter
{

    /**
     * 
     * @param Adapter $adapter
     * @param int $company_id
     * @param int $exclude_id
     */
    public function __construct($adapter, $company_id, $exclude_id)
    {
        $this->add([
            'name' => 'first_name',
            'required' => true,
            'filters' => [
                ['name' => \Laminas\Filter\StripTags::class],
                ['name' => \Laminas\Filter\StringTrim::class],
            ],
            'validators' => [
                [
                    'name' => \Laminas\Validator\StringLength::class,
                    'options' => [
                        'encoding' => 'UTF-8',
                        'max' => 128,
                    ],
                ],
                [
                    'name' => \Laminas\Validator\NotEmpty::class,
                ],
            ],
        ]);
        
        $this->add([
            'name' => 'last_name',
            'required' => true,
            'filters' => [
                ['name' => \Laminas\Filter\StripTags::class],
                ['name' => \Laminas\Filter\StringTrim::class],
            ],
            'validators' => [
                [
                    'name' => \Laminas\Validator\StringLength::class,
                    'options' => [
                        'encoding' => 'UTF-8',
                        'max' => 128,
                    ],
                ],
                [
                    'name' => \Laminas\Validator\NotEmpty::class,
                ],
            ],
        ]);
        
        $this->add([
            'name' => 'corporate_email',
            'required' => true,
            'filters' => [
                ['name' => \Laminas\Filter\StripTags::class],
                ['name' => \Laminas\Filter\StringTrim::class],
            ],
            'validators' => [
                [
                    'name' => \Laminas\Validator\StringLength::class,
                    'options' => [
                        'encoding' => 'UTF-8',
                        'max' => 250,
                    ],
                ],
                [
                    'name' => \Laminas\Validator\NotEmpty::class,
                ],
                [
                    'name' => \Laminas\Validator\EmailAddress::class,
                ],
                [
                    'name' => \LeadersLinked\Validator\NoRecordExistsMultiFields::class,
                    'options' => [
                        'adapter' => $adapter,
                        'table' => DiscoveryContactMapper::_TABLE,
                        'field' => 'corporate_email',
                        'exclude' => [
                            'field' => 'id',
                            'value' => $exclude_id
                            
                        ],
                        'custom_fields' => [
                            'company_id' => $company_id,
                        ]
                    ]
                ]
            ],
        ]);
        
        $this->add([
            'name' => 'company',
            'required' => true,
            'filters' => [
                ['name' => \Laminas\Filter\StripTags::class],
                ['name' => \Laminas\Filter\StringTrim::class],
            ],
            'validators' => [
                [
                    'name' => \Laminas\Validator\StringLength::class,
                    'options' => [
                        'encoding' => 'UTF-8',
                        'max' => 128,
                    ],
                ],
                [
                    'name' => \Laminas\Validator\NotEmpty::class,
                ],
            ],
        ]);
        
        $this->add([
            'name' => 'position',
            'required' => true,
            'filters' => [
                ['name' => \Laminas\Filter\StripTags::class],
                ['name' => \Laminas\Filter\StringTrim::class],
            ],
            'validators' => [
                [
                    'name' => \Laminas\Validator\StringLength::class,
                    'options' => [
                        'encoding' => 'UTF-8',
                        'max' => 128,
                    ],
                ],
                [
                    'name' => \Laminas\Validator\NotEmpty::class,
                ],
            ],
        ]);

        $this->add([
            'name' => 'country',
            'required' => true,
            'filters' => [
                ['name' => \Laminas\Filter\StripTags::class],
                ['name' => \Laminas\Filter\StringTrim::class],
            ],
            'validators' => [
                [
                    'name' => \Laminas\Validator\StringLength::class,
                    'options' => [
                        'encoding' => 'UTF-8',
                        'max' => 128,
                    ],
                ],
                [
                    'name' => \Laminas\Validator\NotEmpty::class,
                ],
            ],
        ]);
        
        $this->add([
            'name' => 'state',
            'required' => false,
            'filters' => [
                ['name' => \Laminas\Filter\StripTags::class],
                ['name' => \Laminas\Filter\StringTrim::class],
            ],
            'validators' => [
                [
                    'name' => \Laminas\Validator\StringLength::class,
                    'options' => [
                        'encoding' => 'UTF-8',
                        'max' => 128,
                    ],
                ],
                [
                    'name' => \Laminas\Validator\NotEmpty::class,
                ],
            ],
        ]);
        
        $this->add([
            'name' => 'city',
            'required' => false,
            'filters' => [
                ['name' => \Laminas\Filter\StripTags::class],
                ['name' => \Laminas\Filter\StringTrim::class],
            ],
            'validators' => [
                [
                    'name' => \Laminas\Validator\StringLength::class,
                    'options' => [
                        'encoding' => 'UTF-8',
                        'max' => 128,
                    ],
                ],
                [
                    'name' => \Laminas\Validator\NotEmpty::class,
                ],
            ],
        ]);
        
        
        $this->add([
            'name' => 'personal_email',
            'required' => false,
            'filters' => [
                ['name' => \Laminas\Filter\StripTags::class],
                ['name' => \Laminas\Filter\StringTrim::class],
            ],
            'validators' => [
                [
                    'name' => \Laminas\Validator\StringLength::class,
                    'options' => [
                        'encoding' => 'UTF-8',
                        'max' => 250,
                    ],
                ],
                [
                    'name' => \Laminas\Validator\NotEmpty::class,
                ],
                [
                    'name' => \Laminas\Validator\EmailAddress::class,
                ],
                [
                    'name' => \LeadersLinked\Validator\NoRecordExistsMultiFields::class,
                    'options' => [
                        'adapter' => $adapter,
                        'table' => DiscoveryContactMapper::_TABLE,
                        'field' => 'personal_email',
                        'exclude' => [
                            'field' => 'id',
                            'value' => $exclude_id
                            
                        ],
                        'custom_fields' => [
                            'company_id' => $company_id,
                        ]
                    ]
                ]
            ],
        ]);
        
        $this->add([
            'name' => 'phone',
            'required' => false,
            'filters' => [
                ['name' => \Laminas\Filter\StripTags::class],
                ['name' => \Laminas\Filter\StringTrim::class],
            ],
            'validators' => [
                [
                    'name' => \Laminas\Validator\StringLength::class,
                    'options' => [
                        'encoding' => 'UTF-8',
                        'max' => 25,
                    ],
                ],
                [
                    'name' => \Laminas\Validator\NotEmpty::class,
                ],
            ],
        ]);
        
        $this->add([
            'name' => 'phone_extension',
            'required' => false,
            'filters' => [
                ['name' => \Laminas\Filter\StripTags::class],
                ['name' => \Laminas\Filter\StringTrim::class],
            ],
            'validators' => [
                [
                    'name' => \Laminas\Validator\StringLength::class,
                    'options' => [
                        'encoding' => 'UTF-8',
                        'max' => 5,
                    ],
                ],
                [
                    'name' => \Laminas\Validator\NotEmpty::class,
                ],
            ],
        ]);
        
        $this->add([
            'name' => 'celular',
            'required' => false,
            'filters' => [
                ['name' => \Laminas\Filter\StripTags::class],
                ['name' => \Laminas\Filter\StringTrim::class],
            ],
            'validators' => [
                [
                    'name' => \Laminas\Validator\StringLength::class,
                    'options' => [
                        'encoding' => 'UTF-8',
                        'max' => 25,
                    ],
                ],
                [
                    'name' => \Laminas\Validator\NotEmpty::class,
                ],
            ],
        ]);
        
        $this->add([
            'name' => 'whatsapp',
            'required' => false,
            'filters' => [
                ['name' => \Laminas\Filter\StripTags::class],
                ['name' => \Laminas\Filter\StringTrim::class],
            ],
            'validators' => [
                [
                    'name' => \Laminas\Validator\StringLength::class,
                    'options' => [
                        'encoding' => 'UTF-8',
                        'max' => 25,
                    ],
                ],
                [
                    'name' => \Laminas\Validator\NotEmpty::class,
                ],
            ],
        ]);
        
        
        
        $this->add([
            'name' => 'linkedin',
            'required' => false,
            'filters' => [
                ['name' => \Laminas\Filter\StripTags::class],
                ['name' => \Laminas\Filter\StringTrim::class],
            ],
            'validators' => [
                [
                    'name' => \Laminas\Validator\StringLength::class,
                    'options' => [
                        'encoding' => 'UTF-8',
                        'max' => 250,
                    ],
                ],
                [
                    'name' => \Laminas\Validator\NotEmpty::class,
                ],
                [
                    'name' => \Laminas\Validator\Uri::class,
                ],
            ],
        ]);


        
        $this->add([
            'name' => 'sector',
            'required' => false,
            'filters' => [
                ['name' => \Laminas\Filter\StripTags::class],
                ['name' => \Laminas\Filter\StringTrim::class],
            ],
            'validators' => [
                [
                    'name' => \Laminas\Validator\StringLength::class,
                    'options' => [
                        'encoding' => 'UTF-8',
                        'max' => 250,
                    ],
                ],
                [
                    'name' => \Laminas\Validator\NotEmpty::class,
                ],
            ],
        ]);
        
        $this->add([
            'name' => 'scholarship',
            'required' => false,
            'filters' => [
                ['name' => \Laminas\Filter\StripTags::class],
                ['name' => \Laminas\Filter\StringTrim::class],
            ],
            'validators' => [
                [
                    'name' => \Laminas\Validator\StringLength::class,
                    'options' => [
                        'encoding' => 'UTF-8',
                        'max' => 250,
                    ],
                ],
                [
                    'name' => \Laminas\Validator\NotEmpty::class,
                ],
            ],
        ]);
    }
}