86 lines
1.2 KiB
PHP
Executable File
86 lines
1.2 KiB
PHP
Executable File
<?php
|
|
|
|
class EntityObject implements ArrayAccess, IteratorAggregate {
|
|
|
|
private $model, $data;
|
|
|
|
public function __construct ( Model $model, $data = array() ) {
|
|
|
|
$this->model = $model;
|
|
$this->data = $data;
|
|
|
|
}
|
|
|
|
public function getModel () {
|
|
|
|
return $this->model;
|
|
|
|
}
|
|
|
|
public function getData () {
|
|
|
|
return $this->data;
|
|
|
|
}
|
|
|
|
public function setData ( $data = array() ) {
|
|
|
|
$this->data = $data;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
public function apply () {
|
|
|
|
$this->data = $this->model->apply($this->data);
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
public function invalid () {
|
|
|
|
return $this->model->invalid($this->data);
|
|
|
|
}
|
|
|
|
public function getState ( $service = '' ) {
|
|
|
|
return $this->model->getState($this->data, $service);
|
|
|
|
}
|
|
|
|
public function offsetSet ( $offset, $value ) {
|
|
|
|
return $this->data[$offset] = $value;
|
|
|
|
}
|
|
|
|
public function offsetGet ( $offset ) {
|
|
|
|
return !empty($this->data[$offset]) ? $this->data[$offset] : null;
|
|
|
|
}
|
|
|
|
public function offsetExists ( $offset ) {
|
|
|
|
return array_key_exists($offre, $this->data);
|
|
|
|
}
|
|
|
|
public function offsetUnset ( $offset ) {
|
|
|
|
unset($this->data[$offset]);
|
|
|
|
}
|
|
|
|
public function getIterator () {
|
|
|
|
return new ArrayIterator($this->data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|