Created
November 4, 2012 13:50
-
-
Save eminetto/4011996 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 Application\Model; | |
use Zend\InputFilter\Factory as InputFactory; | |
use Zend\InputFilter\InputFilter; | |
use Zend\InputFilter\InputFilterAwareInterface; | |
use Zend\InputFilter\InputFilterInterface; | |
use Core\Model\Entity; | |
/** | |
* Entidade Comment | |
* | |
* @category Application | |
* @package Model | |
*/ | |
class Comment extends Entity | |
{ | |
/** | |
* Nome da tabela. Campo obrigatório | |
* @var string | |
*/ | |
protected $tableName ='comments'; | |
/** | |
* @var int | |
*/ | |
protected $id; | |
/** | |
* @var int | |
*/ | |
protected $post_id; | |
/** | |
* @var string | |
*/ | |
protected $description; | |
/** | |
* @var string | |
*/ | |
protected $name; | |
/** | |
* @var string | |
*/ | |
protected $email; | |
/** | |
* @var string | |
*/ | |
protected $webpage; | |
/** | |
* @var datetime | |
*/ | |
protected $comment_date; | |
/** | |
* 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' => 'post_id', | |
'required' => true, | |
'filters' => array( | |
array('name' => 'Int'), | |
), | |
))); | |
$inputFilter->add($factory->createInput(array( | |
'name' => 'description', | |
'required' => true, | |
'filters' => array( | |
array('name' => 'StripTags'), | |
array('name' => 'StringTrim'), | |
), | |
))); | |
$inputFilter->add($factory->createInput(array( | |
'name' => 'email', | |
'required' => true, | |
'filters' => array( | |
array('name' => 'StripTags'), | |
array('name' => 'StringTrim'), | |
), | |
'validators' => array( | |
array( | |
'name' => 'EmailAddress', | |
), | |
), | |
))); | |
$inputFilter->add($factory->createInput(array( | |
'name' => 'name', | |
'required' => true, | |
'filters' => array( | |
array('name' => 'StripTags'), | |
array('name' => 'StringTrim'), | |
), | |
'validators' => array( | |
array( | |
'name' => 'StringLength', | |
'options' => array( | |
'encoding' => 'UTF-8', | |
'min' => 1, | |
'max' => 100, | |
), | |
), | |
), | |
))); | |
$inputFilter->add($factory->createInput(array( | |
'name' => 'webpage', | |
'required' => true, | |
'filters' => array( | |
array('name' => 'StripTags'), | |
array('name' => 'StringTrim'), | |
), | |
'validators' => array( | |
array( | |
'name' => 'StringLength', | |
'options' => array( | |
'encoding' => 'UTF-8', | |
'min' => 1, | |
'max' => 200, | |
), | |
), | |
), | |
))); | |
$inputFilter->add($factory->createInput(array( | |
'name' => 'comment_date', | |
'required' => false, | |
'filters' => array( | |
array('name' => 'StripTags'), | |
array('name' => 'StringTrim'), | |
), | |
))); | |
$this->inputFilter = $inputFilter; | |
} | |
return $this->inputFilter; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment