Rajout de la gestion des formulaires dans \Custom
[zf2.biz/galerie.git] / vendor / zf2biz / Custom / Model / Entity.php
index 7788491..f261e5a 100644 (file)
@@ -1,9 +1,19 @@
 <?php
+
 namespace Custom\Model;
 
-class Entity
+
+use Zend\InputFilter\Factory as InputFactory;
+use Zend\InputFilter\InputFilter;
+use Zend\InputFilter\InputFilterInterface;
+use Zend\InputFilter\InputFilterAwareInterface;
+
+
+class Entity implements InputFilterAwareInterface
 {
 
+    protected $inputFilter;
+
     public function exchangeArray($data, $overwrite=true)
     {
         foreach($this->columns as $col) {
@@ -23,6 +33,14 @@ class Entity
         return $result;
     }
 
+    public function getArrayCopy() {
+        $result = array();
+        foreach($this->columns as $col) {
+            $result[$col] = $this->$col;
+        }
+        return $result;
+    }
+
     public function toUpdatableArray() {
         $result = array();
         foreach($this->updatable_columns as $col) {
@@ -38,4 +56,39 @@ class Entity
         }
         return $result;
     }
+
+
+
+    public function setInputFilter(InputFilterInterface $inputfilter)
+    {
+        $this->inputFilter = $inputFilter;
+    }
+
+    public function getInputFilter()
+    {
+        if (!$this->inputFilter) {
+            $this->setDefaultInputFilter();
+        }
+        return $this->inputFilter;
+    }
+
+    protected function setDefaultInputFilter()
+    {
+        $inputFilter = new InputFilter;
+        $factory = new InputFactory;
+
+        for ($this->getDefaultInputFilterArrays() as $params) {
+            $inputFilter->add($factory->createInput($params))
+        }
+        $this->inputFilter = $inputFilter;
+
+        return $this->inputFilter;
+
+    }
+
+    protected function getDefaultInputFilterArrays()
+    {
+        return array();
+    }
+
 }