forked from koala-framework/koala-framework
/
Row.php
58 lines (56 loc) · 1.77 KB
/
Row.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/**
* @package Model
* @internal
*/
class Kwf_Model_Mongo_Row extends Kwf_Model_Row_Data_Abstract
{
public function __set($name, $value)
{
if (in_array($name, $this->_model->getExprColumns())) {
//TODO: expr column setzen nicht erlauben
//ist im moment aber noch nötig wegen updaten der expr werte
$n = $this->_transformColumnName($name);
if ($this->$name !== $value) {
$this->_setDirty($name);
}
$this->_data[$n] = $value;
$this->_postSet($name, $value);
} else {
parent::__set($name, $value);
}
}
public function __get($name)
{
if (in_array($name, $this->_model->getExprColumns())) {
$name = $this->_transformColumnName($name);
if (!isset($this->_data[$name])) {
$ret = null;
} else {
$ret = $this->_data[$name];
}
} else {
$ret = parent::__get($name);
}
if ($ret instanceof MongoDate) {
$ret = date('Y-m-d H:i:s', $ret->sec);
}
return $ret;
}
protected function _beforeSave()
{
parent::_beforeSave();
foreach ($this->getModel()->getExprColumns() as $name) {
$this->$name = $this->getModel()->getExprValue($this, $name);
}
foreach ($this->getModel()->getProxyContainerModels() as $model) {
foreach ($model->getExprColumns() as $name) {
foreach ($model->getExistingRows() as $proxyRow) {
if ($proxyRow->getProxiedRow() === $this) {
$this->$name = $model->getExprValue($proxyRow, $name);
}
}
}
}
}
}