ReceiveEquip.php 1.91 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
<?php
/**
 * gredu_labs
 *
 * @link https://github.com/eellak/gredu_labs for the canonical source repository
 * @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
 * @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
 */

namespace GrEduLabs\ReceiveEquip\InputFilter;

use GrEduLabs\ReceiveEquip\Service\ReceiveEquipServiceInterface;
use GrEduLabs\Schools\Service\SchoolServiceInterface;
use Zend\Filter;
use Zend\InputFilter\CollectionInputFilter;
use Zend\InputFilter\Input;
use Zend\InputFilter\InputFilter;
18
use Zend\InputFilter\FileInput;
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
use Zend\Validator;

class ReceiveEquip extends InputFilter
{
    public function __construct(
        ReceiveEquipServiceInterface $receiveEquipService,
        SchoolServiceInterface $schoolService,
        CollectionInputFilter $itemsInputFilter
    ) {
        $id = new Input('id');
        $id->setRequired(true)
          ->getFilterChain()
          ->attach(new Filter\ToInt());
        $id->getValidatorChain()
          ->attach(new Validator\NotEmpty());
34

35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
        $schoolId = new Input('school_id');
        $schoolId->setRequired(true)
            ->getFilterChain()
            ->attach(new Filter\ToInt());
        $schoolId->getValidatorChain()
            ->attach(new Validator\NotEmpty());

        $submittedBy = new Input('submitted_by');
        $submittedBy->setRequired(true)
            ->getValidatorChain()
            ->attach(new Validator\NotEmpty())
            ->attach(new Validator\EmailAddress([
                'useDomainCheck' => false,
            ]));

50 51 52 53
/*        $received_document = new FileInput('received_document');
        $received_document->getValidatorChain()
            ->attach(new Validator\File\UploadFile()); */

54 55 56
        $this->add($id)
            ->add($schoolId)
            ->add($submittedBy)
57
//            ->add($received_document)
58 59 60
            ->add($itemsInputFilter, 'items');
    }
}