Created
November 2, 2012 14:46
-
-
Save eminetto/4001782 to your computer and use it in GitHub Desktop.
This file contains 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 Admin\Model; | |
use Zend\InputFilter\Factory as InputFactory; | |
use Zend\InputFilter\InputFilter; | |
use Zend\InputFilter\InputFilterAwareInterface; | |
use Zend\InputFilter\InputFilterInterface; | |
use Core\Model\Entity; | |
/** | |
* Entidade User | |
* | |
* @category Admin | |
* @package Model | |
*/ | |
class User extends Entity | |
{ | |
/** | |
* Nome da tabela. Campo obrigatório | |
* @var string | |
*/ | |
protected $tableName ='users'; | |
/** | |
* @var int | |
*/ | |
protected $id; | |
/** | |
* @var string | |
*/ | |
protected $username; | |
/** | |
* @var string | |
*/ | |
protected $password; | |
/** | |
* @var string | |
*/ | |
protected $name; | |
/** | |
* @var int | |
*/ | |
protected $valid; | |
/** | |
* @var string | |
*/ | |
protected $role; | |
/** | |
* Configura os filtros dos campos da entidade | |
* | |
* @return Zend\InputFilter\InputFilter | |
*/ | |
public function getInputFilter() | |
{ | |
if (!$this->inputFilter) { | |
$inputFilter = new InputFilter(); | |
$factory = new InputFactory(); | |
$inputFilter->add($factory->createInput(array( | |
'name' => 'id', | |
'required' => true, | |
'filters' => array( | |
array('name' => 'Int'), | |
), | |
))); | |
$inputFilter->add($factory->createInput(array( | |
'name' => 'username', | |
'required' => true, | |
'filters' => array( | |
array('name' => 'StripTags'), | |
array('name' => 'StringTrim'), | |
), | |
'validators' => array( | |
array( | |
'name' => 'StringLength', | |
'options' => array( | |
'encoding' => 'UTF-8', | |
'min' => 1, | |
'max' => 50, | |
), | |
), | |
), | |
))); | |
$inputFilter->add($factory->createInput(array( | |
'name' => 'password', | |
'required' => true, | |
'filters' => array( | |
array('name' => 'StripTags'), | |
array('name' => 'StringTrim'), | |
), | |
))); | |
$inputFilter->add($factory->createInput(array( | |
'name' => 'name', | |
'required' => true, | |
'filters' => array( | |
array('name' => 'StripTags'), | |
array('name' => 'StringTrim'), | |
), | |
))); | |
$inputFilter->add($factory->createInput(array( | |
'name' => 'valid', | |
'required' => true, | |
'filters' => array( | |
array('name' => 'Int'), | |
), | |
))); | |
$inputFilter->add($factory->createInput(array( | |
'name' => 'role', | |
'required' => true, | |
'filters' => array( | |
array('name' => 'StripTags'), | |
array('name' => 'StringTrim'), | |
), | |
'validators' => array( | |
array( | |
'name' => 'StringLength', | |
'options' => array( | |
'encoding' => 'UTF-8', | |
'min' => 1, | |
'max' => 20, | |
), | |
), | |
), | |
))); | |
$this->inputFilter = $inputFilter; | |
} | |
return $this->inputFilter; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment