Formulaire : étape 2, modification du modèle
[zf2.biz/galerie.git] / module / Galerie / src / Galerie / Model / Galerie.php
1 <?php
2
3 namespace Galerie\Model;
4
5 use Zend\InputFilter\Factory as InputFactory;
6 use Zend\InputFilter\InputFilter;
7 use Zend\InputFilter\InputFilterInterface;
8 use Zend\InputFilter\InputFilterAwareInterface;
9
10 use Custom\Model\Entity;
11
12 class Galerie extends Entity implements InputFilterAwareInterface
13 {
14     public $id;
15     public $id_user;
16     public $name;
17     public $description;
18     public $created;
19     public $updated;
20
21     protected $inputFilter;
22
23
24     protected $columns = array(
25         'id',
26         'id_user',
27         'name',
28         'description',
29         'created',
30         'updated',
31     );
32
33     protected $updatable_columns = array(
34         'id_user',
35         'name',
36         'description',
37     );
38
39     protected $primary_columns = array(
40         'id',
41     );
42
43     public function getArrayCopy()
44     {
45         return $this->toArray();
46     }
47
48     public function setInputFilter(InputFilterInterface $inputfilter)
49     {
50         throw new \Exception("This entity does not allow to set Input Filter");
51     }
52
53     public function getInputFilter()
54     {
55         if (!$this->inputFilter) {
56             $inputFilter = new InputFilter;
57             $factory = new InputFactory;
58
59             $inputFilter->add($factory->createInput(array(
60                 'name' => 'id',
61                 'required' => true,
62                 'filters' => array(
63                     array('name' => 'Int'),
64                 ),
65             )));
66
67             $inputFilter->add($factory->createInput(array(
68                 'name' => 'name',
69                 'required' => true,
70                 'filters' => array(
71                     array('name' => 'StripTags'),
72                     array('name' => 'StringTrim'),
73                 ),
74                 'validators' => array(
75                     array(
76                         'name' => 'StringLength',
77                         'options' => array(
78                             'encoding' => 'UTF-8',
79                             'min' => 1,
80                             'max' => 32,
81                         ),
82                     ),
83                 ),
84             )));
85
86             $inputFilter->add($factory->createInput(array(
87                 'name' => 'description',
88                 'required' => true,
89                 'filters' => array(
90                     array('name' => 'StripTags'),
91                     array('name' => 'StringTrim'),
92                 ),
93             )));
94
95             $this->inputFilter = $inputFilter;
96         }
97
98         return $this->inputFilter;
99
100     }
101
102 }