1: <?php
2:
3: namespace PHPixie\ORM\Relationships\Relationship\Implementation\Property;
4:
5: abstract class Entity extends \PHPixie\ORM\Relationships\Relationship\Implementation\Property
6: implements \PHPixie\ORM\Relationships\Relationship\Property\Entity
7: {
8: protected $entity;
9: protected $value;
10: protected $isLoaded = false;
11:
12: public function __construct($handler, $side, $entity)
13: {
14: parent::__construct($handler, $side);
15: $this->entity = $entity;
16: }
17:
18: public function __invoke()
19: {
20: return $this->value();
21: }
22:
23: public function reload()
24: {
25: $this->load();
26: return $this->value;
27: }
28:
29: public function reset()
30: {
31: $this->value = null;
32: $this->isLoaded = false;
33: }
34:
35: public function entity()
36: {
37: return $this->entity;
38: }
39:
40: public function value()
41: {
42: if ($this->isLoaded === false) {
43: $this->reload();
44: }
45: return $this->value;
46: }
47:
48: public function setValue($value)
49: {
50: $this->value = $value;
51: $this->isLoaded = true;
52: }
53:
54: public function isLoaded()
55: {
56: return $this->isLoaded;
57: }
58:
59: abstract protected function load();
60: }