1: <?php
2:
3: namespace PHPixie\ORM;
4:
5: class Models
6: {
7: 8: 9:
10: protected $ormBuilder;
11: protected $configSlice;
12: protected $wrappers;
13:
14: 15: 16:
17: protected $databaseModel;
18:
19: 20: 21:
22: protected $embeddedModel;
23:
24: public function __construct($ormBuilder, $configSlice, $wrappers = null)
25: {
26: $this->ormBuilder = $ormBuilder;
27: $this->configSlice = $configSlice;
28: $this->wrappers = $wrappers;
29: }
30:
31: public function modelConfigSlice($modelName)
32: {
33: return $this->configSlice->slice($modelName);
34: }
35:
36: public function wrappers()
37: {
38: return $this->wrappers;
39: }
40:
41: 42: 43:
44: public function database()
45: {
46: if($this->databaseModel === null)
47: {
48: $this->databaseModel = $this->buildDatabaseModel();
49: }
50:
51: return $this->databaseModel;
52: }
53:
54: 55: 56:
57: public function embedded()
58: {
59: if($this->embeddedModel === null)
60: {
61: $this->embeddedModel = $this->buildEmbeddedModel();
62: }
63:
64: return $this->embeddedModel;
65: }
66:
67: protected function buildDatabaseModel()
68: {
69: return new \PHPixie\ORM\Models\Type\Database(
70: $this,
71: $this->ormBuilder->configs(),
72: $this->ormBuilder->database(),
73: $this->ormBuilder->drivers()
74: );
75: }
76:
77: protected function buildEmbeddedModel()
78: {
79: return new \PHPixie\ORM\Models\Type\Embedded(
80: $this,
81: $this->ormBuilder->configs(),
82: $this->ormBuilder->data(),
83: $this->ormBuilder->maps()
84: );
85: }
86: }