MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
phpconfigloader.class
Ir para a documentação deste ficheiro.
1<?php
2
8{
13
17 var $maps = array();
18
32
34 {
35 $this->broker = &$broker; // factory
36 }
37
38 function &getMap($classMapName)
39 {
40 global $MIOLO;
41
42 if (!$this->maps[$classMapName])
43 {
44 $MIOLO->Assert(class_exists(strtolower($classMapName)),
45 'PHPConfigLoader::getMap() ' . _M('Error') . ": $classMapName - " . _M('Class not found'));
46
47 eval("\$map = new {$classMapName}();");
48 $this->maps[$class] = &$map;
49 }
50
51 return $this->maps[$class];
52 }
53
54 function &getClassMap($classMapName)
55 {
56 global $MIOLO;
57 $classMap = $this->getMap($classMapName);
58 echo $classMapName;
59 echo $classMap->databaseName;
60 $database = $MIOLO->GetDatabase($classMap->databaseName);
61 $cm = new ClassMap($classMap->className, $database, $this->broker);
62 $dm = new DatabaseMap($classMap->databaseName);
63 $tableMap = new TableMap();
64 $tableMap->setName($classMap->tableName);
65 $tableMap->setDatabaseMap($dm);
66
67 foreach ($classMap->attributes as $attr)
68 {
69 $am = new AttributeMap($attr['name']);
70 $converter = $this->getConverter($attr['converter']);
71
72 if (isset($attr['column']))
73 {
74 $colm = new ColumnMap($attr['column'], $tableMap, $converter);
75
76 if (isset($attr['key']))
77 {
78 if ($attr['key'] == 'primary')
79 {
80 $colm->setKeyType('primary');
81
82 if (isset($attr['id_generator']))
83 {
84 $idGenerator = $attr['id_generator'];
85 $colm->setIdGenerator($idGenerator);
86 }
87 }
88 elseif ($attr['key'] == 'foreign')
89 {
90 $colm->setKeyType('foreign');
91 }
92 }
93 else
94 {
95 $colm->setKeyType('none');
96 }
97
98 $am->setColumnMap($colm);
99 }
100
101 if ($attr['proxy'] === false)
102 {
103 $am->setProxy(false);
104 }
105
106 if ((isset($attr['reference'])) && ($cm->superClass != null))
107 {
108 $referenceAttribute = &$cm->superClass->getAttributeMap($attr['reference']);
109
110 if ($referenceAttribute)
111 $am->setReference($referenceAttribute);
112 }
113
114 if ($attr['name'] == 'timestamp')
115 {
116 $cm->setTimestampAttributeMap($am);
117 }
118 else
119 {
120 $cm->addAttributeMap($am);
121 }
122 }
123
124 return $cm;
125 }
126
127 function &getAssociationMap($classMapName)
128 {
129 $classMap = &$this->getMap($classMapName);
130
131 if (!count($classMap->associations))
132 return;
133
134 foreach ($classMap->associations as $assoc)
135 {
136 $fromClassMap = &$this->broker->getClassMap($assoc['from_class']);
137 $toClassMap = &$this->broker->getClassMap($assoc['to_class']);
139 $am->setForClass($toClassMap);
140 $am->setTargetName($assoc['target']);
141 $am->setTarget($fromClassMap->getAttributeMap($assoc['target']));
142 $am->setDeleteAutomatic($assoc['delete_automatic']);
143 $am->setSaveAutomatic($assoc['save_automatic']);
144 $am->setRetrieveAutomatic($assoc['retrieve_automatic']);
145 $am->setInverse($assoc['inverse']);
146 $am->setCardinality($assoc['cardinality']);
147
148 if ($assoc['cardinality'] == 'manyToMany')
149 {
150 $associativeClassMap = &$this->broker->getClassMap($assoc['associative_class']);
151 $am->setAssociativeClass($associativeClassMap);
152
153 foreach ($assoc['direction'] as $direction)
154 {
155 $am->addDirection($direction);
156 }
157 }
158 else
159 {
160 foreach ($assoc['entry'] as $entry)
161 {
162 $fromAttribute = $entry['from'];
163 $toAttribute = $entry['to'];
164 $e = new UDAMapEntry($fromClassMap->getAttributeMap($fromAttribute), $toClassMap->getAttributeMap($toAttribute));
165 $am->addEntry($e);
166 }
167 }
168
169 $fromClassMap->putAssociationMap($am);
170 }
171 }
172
173 function &getConverter($name = null)
174 {
175 if (!$name)
176 {
178 }
179 else
180 {
181 $converter = &$this->broker->getConverter($name);
182
183 if (!$converter)
184 {
185 $converter = new ConverterFactory($name);
186 $this->broker->putConverter($name, $converter);
187 }
188 }
189
190 return $converter;
191 }
192}
193?>
& getConverter($name=null)
& getClassMap($classMapName)
& getAssociationMap($classMapName)
& getMap($classMapName)
PHPConfigLoader(&$broker)