From 43d8a5af15a1ad038fdae5e0963b071738c1f32f Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20CHAZALLET?= Date: Thu, 15 Nov 2012 13:02:09 +0100 Subject: [PATCH] =?utf8?q?Formulaire=20:=20=C3=A9tape=202,=20modification=20?= =?utf8?q?du=20mod=C3=A8le?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- module/Galerie/src/Galerie/Model/Galerie.php | 70 ++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 3 deletions(-) diff --git a/module/Galerie/src/Galerie/Model/Galerie.php b/module/Galerie/src/Galerie/Model/Galerie.php index 89a3794..6b46e20 100644 --- a/module/Galerie/src/Galerie/Model/Galerie.php +++ b/module/Galerie/src/Galerie/Model/Galerie.php @@ -2,9 +2,14 @@ namespace Galerie\Model; +use Zend\InputFilter\Factory as InputFactory; +use Zend\InputFilter\InputFilter; +use Zend\InputFilter\InputFilterInterface; +use Zend\InputFilter\InputFilterAwareInterface; + use Custom\Model\Entity; -class Galerie extends Entity +class Galerie extends Entity implements InputFilterAwareInterface { public $id; public $id_user; @@ -13,6 +18,8 @@ class Galerie extends Entity public $created; public $updated; + protected $inputFilter; + protected $columns = array( 'id', @@ -27,12 +34,69 @@ class Galerie extends Entity 'id_user', 'name', 'description', - 'created', - 'updated', ); protected $primary_columns = array( 'id', ); + public function getArrayCopy() + { + return $this->toArray(); + } + + public function setInputFilter(InputFilterInterface $inputfilter) + { + throw new \Exception("This entity does not allow to set Input Filter"); + } + + 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' => 'name', + 'required' => true, + 'filters' => array( + array('name' => 'StripTags'), + array('name' => 'StringTrim'), + ), + 'validators' => array( + array( + 'name' => 'StringLength', + 'options' => array( + 'encoding' => 'UTF-8', + 'min' => 1, + 'max' => 32, + ), + ), + ), + ))); + + $inputFilter->add($factory->createInput(array( + 'name' => 'description', + 'required' => true, + 'filters' => array( + array('name' => 'StripTags'), + array('name' => 'StringTrim'), + ), + ))); + + $this->inputFilter = $inputFilter; + } + + return $this->inputFilter; + + } + } -- 1.7.10.4