Corrections sur Custom\Model, Entity et Manager
[zf2.biz/galerie.git] / vendor / zf2biz / Custom / Model / Entity.php
1 <?php
2 namespace Custom\Model;
3
4 class Entity
5 {
6
7     public function exchangeArray($data, $overwrite=false)
8     {
9         foreach($this->columns as $col) {
10             if (array_key_exists($col, $data)) {
11                 $this->$col = $data[$col];
12             } elseif ($overwrite) {
13                 $this->$col = null;
14             }
15         }
16     }
17
18     public function toArray() {
19         $result = array();
20         foreach($this->columns as $col) {
21             $result[$col] = $this->$col;
22         }
23         return $result;
24     }
25
26     public function toUpdatableArray() {
27         $result = array();
28         foreach($this->updatable_columns as $col) {
29             $result[$col] = $this->$col;
30         }
31         return $result;
32     }
33
34     public function toPrimaryArray() {
35         $result = array();
36         foreach($this->primary_columns as $col) {
37             $result[$col] = $this->$col;
38         }
39         return $result;
40     }
41 }