Last active
December 20, 2015 14:29
-
-
Save eminetto/6147100 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace Aluno\Model; | |
| use Zend\InputFilter\Factory as InputFactory; | |
| use Zend\InputFilter\InputFilter; | |
| use Zend\InputFilter\InputFilterAwareInterface; | |
| use Zend\InputFilter\InputFilterInterface; | |
| class Aluno | |
| { | |
| public $matricula; | |
| public $nome; | |
| protected $inputFilter; | |
| public function exchangeArray($data) | |
| { | |
| $this->id = (isset($data['id'])) ? $data['id'] : null; | |
| $this->matricula = (isset($data['matricula'])) ? $data['matricula'] : null; | |
| $this->nome = (isset($data['nome'])) ? $data['nome'] : null; | |
| } | |
| public function getInputFilter() | |
| { | |
| if (!$this->inputFilter) { | |
| $inputFilter = new InputFilter(); | |
| $factory = new InputFactory(); | |
| $inputFilter->add($factory->createInput(array( | |
| 'name' => 'matricula', | |
| 'required' => false, | |
| 'filters' => array( | |
| array('name' => 'Int'), | |
| ), | |
| ))); | |
| $inputFilter->add($factory->createInput(array( | |
| 'name' => 'nome', | |
| 'required' => true, | |
| 'filters' => array( | |
| array('name' => 'StripTags'), | |
| array('name' => 'StringTrim'), | |
| ), | |
| 'validators' => array( | |
| array( | |
| 'name' => 'StringLength', | |
| 'options' => array( | |
| 'encoding' => 'UTF-8', | |
| 'min' => 1, | |
| 'max' => 100, | |
| ), | |
| ), | |
| ), | |
| ))); | |
| $this->inputFilter = $inputFilter; | |
| } | |
| return $this->inputFilter; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment