Rajout d'une bibliothèque Custom
authorSébastien CHAZALLET <s.chazallet@gmail.com>
Tue, 6 Nov 2012 15:57:09 +0000 (16:57 +0100)
committerSébastien CHAZALLET <s.chazallet@gmail.com>
Tue, 6 Nov 2012 15:57:09 +0000 (16:57 +0100)
vendor/zf2biz/Custom/Model/Entity.php [new file with mode: 0644]
vendor/zf2biz/Custom/autoload_classmap.php [new file with mode: 0644]

diff --git a/vendor/zf2biz/Custom/Model/Entity.php b/vendor/zf2biz/Custom/Model/Entity.php
new file mode 100644 (file)
index 0000000..7788491
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+namespace Custom\Model;
+
+class Entity
+{
+
+    public function exchangeArray($data, $overwrite=true)
+    {
+        foreach($this->columns as $col) {
+            if (array_key_exists($col, $data)) {
+                $this->$col = $data[$col];
+            } elseif ($overwrite) {
+                $this->$col = null;
+            }
+        }
+    }
+
+    public function toArray() {
+        $result = array();
+        foreach($this->columns as $col) {
+            $result[$col] = $this->$col;
+        }
+        return $result;
+    }
+
+    public function toUpdatableArray() {
+        $result = array();
+        foreach($this->updatable_columns as $col) {
+            $result[$col] = $this->$col;
+        }
+        return $result;
+    }
+
+    public function toPrimaryArray() {
+        $result = array();
+        foreach($this->primary_columns as $col) {
+            $result[$col] = $this->$col;
+        }
+        return $result;
+    }
+}
diff --git a/vendor/zf2biz/Custom/autoload_classmap.php b/vendor/zf2biz/Custom/autoload_classmap.php
new file mode 100644 (file)
index 0000000..e7ebc58
--- /dev/null
@@ -0,0 +1,5 @@
+<?php
+
+return array(
+    'Custom\Model\entity' => __DIR__ . '/Model/Entity.php',
+);