@@ -14,68 +14,68 @@ discard block |
||
14 | 14 | abstract class AbstractAdapter |
15 | 15 | { |
16 | 16 | |
17 | - protected $arrConfig = array ( |
|
17 | + protected $arrConfig = array( |
|
18 | 18 | ############################# DATABASE |
19 | 19 | //Driver do banco de dados |
20 | - 'driver' => null , |
|
20 | + 'driver' => null, |
|
21 | 21 | //Nome do banco de dados |
22 | - 'database' => null , |
|
22 | + 'database' => null, |
|
23 | 23 | //Host do banco |
24 | - 'host' => 'localhost' , |
|
24 | + 'host' => 'localhost', |
|
25 | 25 | //Port do banco |
26 | - 'port' => '' , |
|
26 | + 'port' => '', |
|
27 | 27 | //usuario do banco |
28 | - 'username' => null , |
|
28 | + 'username' => null, |
|
29 | 29 | //senha do banco |
30 | - 'password' => null , |
|
30 | + 'password' => null, |
|
31 | 31 | // lista de schemas do banco de dados |
32 | - 'schema' => array () , |
|
32 | + 'schema' => array(), |
|
33 | 33 | |
34 | - 'socket' => null , |
|
34 | + 'socket' => null, |
|
35 | 35 | |
36 | 36 | ########################### DOCS |
37 | 37 | // autor que gerou o script |
38 | - 'author' => "Pedro" , |
|
39 | - 'license' => "New BSD License" , |
|
40 | - 'copyright' => "ORM Generator - Pedro151" , |
|
41 | - 'link' => 'https://github.com/pedro151/orm-generator' , |
|
38 | + 'author' => "Pedro", |
|
39 | + 'license' => "New BSD License", |
|
40 | + 'copyright' => "ORM Generator - Pedro151", |
|
41 | + 'link' => 'https://github.com/pedro151/orm-generator', |
|
42 | 42 | // data que foi gerado o script |
43 | - 'last_modify' => null , |
|
43 | + 'last_modify' => null, |
|
44 | 44 | |
45 | 45 | ########################## Ambiente/Arquivos |
46 | 46 | |
47 | 47 | // Nome do framework para o adapter |
48 | - 'framework' => null , |
|
48 | + 'framework' => null, |
|
49 | 49 | // namespace das classes |
50 | - 'namespace' => "" , |
|
50 | + 'namespace' => "", |
|
51 | 51 | // caminho onde os arquivos devem ser criados |
52 | - 'path' => 'models' , |
|
52 | + 'path' => 'models', |
|
53 | 53 | // flag para gerar pasta com o nome do driver do banco de dados |
54 | - 'folder-database' => 0 , |
|
54 | + 'folder-database' => 0, |
|
55 | 55 | |
56 | 56 | ############################## Comandos adicionais |
57 | 57 | //flag para mostrar o status da execução ao termino do processo |
58 | - 'status' => false , |
|
58 | + 'status' => false, |
|
59 | 59 | // flags para criar todas as tabelas ou nao |
60 | - 'allTables' => true , |
|
60 | + 'allTables' => true, |
|
61 | 61 | //Lista de tabelas a serem ignoradas |
62 | - 'ignoreTable' => array () , |
|
62 | + 'ignoreTable' => array(), |
|
63 | 63 | ); |
64 | 64 | |
65 | 65 | /** |
66 | 66 | * @var string[] um array com todos os campos obrigatorios |
67 | 67 | */ |
68 | - protected $attRequered = array ( |
|
69 | - 'driver' => true , |
|
70 | - 'database' => true , |
|
71 | - 'host' => true , |
|
72 | - 'username' => true , |
|
68 | + protected $attRequered = array( |
|
69 | + 'driver' => true, |
|
70 | + 'database' => true, |
|
71 | + 'host' => true, |
|
72 | + 'username' => true, |
|
73 | 73 | 'path' => true |
74 | 74 | ); |
75 | 75 | |
76 | - protected $arrFunc = array (); |
|
76 | + protected $arrFunc = array(); |
|
77 | 77 | |
78 | - private $framworkFiles = array (); |
|
78 | + private $framworkFiles = array(); |
|
79 | 79 | |
80 | 80 | const SEPARETOR = ""; |
81 | 81 | |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return bool |
86 | 86 | */ |
87 | - protected function checkConfig () |
|
87 | + protected function checkConfig() |
|
88 | 88 | { |
89 | - if ( array_diff_key ( $this->attRequered , array_filter ( $this->arrConfig ) ) ) |
|
89 | + if (array_diff_key($this->attRequered, array_filter($this->arrConfig))) |
|
90 | 90 | { |
91 | 91 | return false; |
92 | 92 | } |
@@ -99,33 +99,33 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @return array |
101 | 101 | */ |
102 | - abstract protected function getParams (); |
|
102 | + abstract protected function getParams(); |
|
103 | 103 | |
104 | 104 | /** |
105 | 105 | * Popula as config do generater com as configuraçoes do framework |
106 | 106 | * |
107 | 107 | * @return mixed |
108 | 108 | */ |
109 | - abstract protected function parseFrameworkConfig (); |
|
109 | + abstract protected function parseFrameworkConfig(); |
|
110 | 110 | |
111 | 111 | /** |
112 | 112 | * Cria Instancias dos arquivos que devem ser gerados |
113 | 113 | * |
114 | 114 | * @return \Classes\AdapterMakerFile\AbstractAdapter[] |
115 | 115 | */ |
116 | - abstract public function getMakeFileInstances (); |
|
116 | + abstract public function getMakeFileInstances(); |
|
117 | 117 | |
118 | - abstract protected function init (); |
|
118 | + abstract protected function init(); |
|
119 | 119 | |
120 | 120 | /** |
121 | 121 | * retorna a base do Namespace |
122 | 122 | * |
123 | 123 | * @return array |
124 | 124 | */ |
125 | - protected function getBaseNamespace () |
|
125 | + protected function getBaseNamespace() |
|
126 | 126 | { |
127 | - return array ( |
|
128 | - $this->arrConfig[ 'namespace' ] , |
|
127 | + return array( |
|
128 | + $this->arrConfig['namespace'], |
|
129 | 129 | 'Model' |
130 | 130 | ); |
131 | 131 | } |
@@ -136,51 +136,51 @@ discard block |
||
136 | 136 | * @return mixed |
137 | 137 | */ |
138 | 138 | |
139 | - public function createClassNamespace ( $table ) |
|
139 | + public function createClassNamespace($table) |
|
140 | 140 | { |
141 | - $arrNames = $this->getBaseNamespace (); |
|
141 | + $arrNames = $this->getBaseNamespace(); |
|
142 | 142 | |
143 | - if ( isset( $this->arrConfig[ 'folder-database' ] ) |
|
144 | - && $this->arrConfig[ 'folder-database' ] |
|
143 | + if (isset($this->arrConfig['folder-database']) |
|
144 | + && $this->arrConfig['folder-database'] |
|
145 | 145 | ) |
146 | 146 | { |
147 | - $arrNames[] = AbstractMaker::getClassName ( $this->arrConfig[ 'driver' ] ); |
|
147 | + $arrNames[] = AbstractMaker::getClassName($this->arrConfig['driver']); |
|
148 | 148 | } |
149 | 149 | |
150 | - if ( isset( $this->arrConfig[ 'folder-name' ] ) |
|
151 | - && $this->arrConfig[ 'folder-name' ] |
|
150 | + if (isset($this->arrConfig['folder-name']) |
|
151 | + && $this->arrConfig['folder-name'] |
|
152 | 152 | ) |
153 | 153 | { |
154 | - $arrNames[] = AbstractMaker::getClassName ( $this->arrConfig[ 'folder-name' ] ); |
|
154 | + $arrNames[] = AbstractMaker::getClassName($this->arrConfig['folder-name']); |
|
155 | 155 | } |
156 | 156 | |
157 | - if ( $table->hasSchema () ) |
|
157 | + if ($table->hasSchema()) |
|
158 | 158 | { |
159 | - $arrNames[] = AbstractMaker::getClassName ( $table->getSchema () ); |
|
159 | + $arrNames[] = AbstractMaker::getClassName($table->getSchema()); |
|
160 | 160 | } else |
161 | 161 | { |
162 | - $arrNames[] = AbstractMaker::getClassName ( $table->getDatabase () ); |
|
162 | + $arrNames[] = AbstractMaker::getClassName($table->getDatabase()); |
|
163 | 163 | } |
164 | 164 | |
165 | - return implode ( static::SEPARETOR , array_filter ( $arrNames ) ); |
|
165 | + return implode(static::SEPARETOR, array_filter($arrNames)); |
|
166 | 166 | } |
167 | 167 | |
168 | - public function __construct ( $array ) |
|
168 | + public function __construct($array) |
|
169 | 169 | { |
170 | - $array += array ( |
|
171 | - 'author' => ucfirst ( get_current_user () ) , |
|
172 | - 'last_modify' => date ( "d-m-Y H:i:s." ) |
|
170 | + $array += array( |
|
171 | + 'author' => ucfirst(get_current_user()), |
|
172 | + 'last_modify' => date("d-m-Y H:i:s.") |
|
173 | 173 | ); |
174 | 174 | |
175 | - $this->setFrameworkFiles ( $array ); |
|
176 | - $this->parseFrameworkConfig (); |
|
177 | - $this->setParams ( $this->getParams () ); |
|
178 | - $this->setParams ( $array ); |
|
179 | - $this->init (); |
|
180 | - if ( ! $this->isValid () ) |
|
175 | + $this->setFrameworkFiles($array); |
|
176 | + $this->parseFrameworkConfig(); |
|
177 | + $this->setParams($this->getParams()); |
|
178 | + $this->setParams($array); |
|
179 | + $this->init(); |
|
180 | + if ( ! $this->isValid()) |
|
181 | 181 | { |
182 | - $var = array_diff_key ( $this->attRequered , array_filter ( $this->arrConfig ) ); |
|
183 | - throw new Exception( $var ); |
|
182 | + $var = array_diff_key($this->attRequered, array_filter($this->arrConfig)); |
|
183 | + throw new Exception($var); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
@@ -189,47 +189,47 @@ discard block |
||
189 | 189 | * |
190 | 190 | * @param $array |
191 | 191 | */ |
192 | - public function setFrameworkFiles ( $array ) |
|
192 | + public function setFrameworkFiles($array) |
|
193 | 193 | { |
194 | - $this->framworkFiles[ 'library' ] = isset( $array[ 'framework-path-library' ] ) |
|
195 | - ? $array[ 'framework-path-library' ] |
|
194 | + $this->framworkFiles['library'] = isset($array['framework-path-library']) |
|
195 | + ? $array['framework-path-library'] |
|
196 | 196 | : null; |
197 | 197 | |
198 | - $this->framworkFiles[ 'ini' ] = isset( $array[ 'framework-ini' ] ) |
|
199 | - ? $array[ 'framework-ini' ] |
|
198 | + $this->framworkFiles['ini'] = isset($array['framework-ini']) |
|
199 | + ? $array['framework-ini'] |
|
200 | 200 | : null; |
201 | 201 | |
202 | - $this->framworkFiles[ 'environment' ] = isset( $array[ 'environment' ] ) |
|
203 | - ? $array[ 'environment' ] |
|
202 | + $this->framworkFiles['environment'] = isset($array['environment']) |
|
203 | + ? $array['environment'] |
|
204 | 204 | : 'production'; |
205 | 205 | |
206 | 206 | } |
207 | 207 | |
208 | - protected function isValidFrameworkFiles () |
|
208 | + protected function isValidFrameworkFiles() |
|
209 | 209 | { |
210 | - if ( ! is_file ( $this->framworkFiles[ 'ini' ] ) ) |
|
210 | + if ( ! is_file($this->framworkFiles['ini'])) |
|
211 | 211 | { |
212 | 212 | return false; |
213 | 213 | } |
214 | 214 | |
215 | - if ( ! is_dir ( $this->framworkFiles[ 'library' ] ) ) |
|
215 | + if ( ! is_dir($this->framworkFiles['library'])) |
|
216 | 216 | { |
217 | 217 | return false; |
218 | 218 | } |
219 | 219 | |
220 | 220 | |
221 | - if ( ! isset ( $this->framworkFiles[ 'environment' ] ) |
|
222 | - or empty( $this->framworkFiles[ 'environment' ] ) |
|
221 | + if ( ! isset ($this->framworkFiles['environment']) |
|
222 | + or empty($this->framworkFiles['environment']) |
|
223 | 223 | ) |
224 | 224 | { |
225 | 225 | return false; |
226 | 226 | } |
227 | - set_include_path ( |
|
228 | - implode ( |
|
229 | - PATH_SEPARATOR , |
|
230 | - array ( |
|
231 | - realpath ( $this->framworkFiles[ 'library' ] ) , |
|
232 | - get_include_path () , |
|
227 | + set_include_path( |
|
228 | + implode( |
|
229 | + PATH_SEPARATOR, |
|
230 | + array( |
|
231 | + realpath($this->framworkFiles['library']), |
|
232 | + get_include_path(), |
|
233 | 233 | ) |
234 | 234 | ) |
235 | 235 | ); |
@@ -237,120 +237,120 @@ discard block |
||
237 | 237 | return true; |
238 | 238 | } |
239 | 239 | |
240 | - protected function getFrameworkIni () |
|
240 | + protected function getFrameworkIni() |
|
241 | 241 | { |
242 | - return $this->framworkFiles[ 'ini' ]; |
|
242 | + return $this->framworkFiles['ini']; |
|
243 | 243 | } |
244 | 244 | |
245 | - protected function getEnvironment () |
|
245 | + protected function getEnvironment() |
|
246 | 246 | { |
247 | - return $this->framworkFiles[ 'environment' ]; |
|
247 | + return $this->framworkFiles['environment']; |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
251 | 251 | * Popula as variaveis de acordo com o arquivo de configuração do seu framework |
252 | 252 | */ |
253 | - protected function isValid () |
|
253 | + protected function isValid() |
|
254 | 254 | { |
255 | - return $this->checkConfig (); |
|
255 | + return $this->checkConfig(); |
|
256 | 256 | } |
257 | 257 | |
258 | - private function setParams ( $array ) |
|
258 | + private function setParams($array) |
|
259 | 259 | { |
260 | - if ( count ( $array ) > 0 ) |
|
260 | + if (count($array) > 0) |
|
261 | 261 | { |
262 | - $this->arrConfig = array_filter ( $array ) + $this->arrConfig; |
|
262 | + $this->arrConfig = array_filter($array) + $this->arrConfig; |
|
263 | 263 | } |
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
267 | 267 | * @return string |
268 | 268 | */ |
269 | - public function getDatabase () |
|
269 | + public function getDatabase() |
|
270 | 270 | { |
271 | - return $this->arrConfig[ 'database' ]; |
|
271 | + return $this->arrConfig['database']; |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
275 | 275 | * @return bool |
276 | 276 | */ |
277 | - public function hasSchemas () |
|
277 | + public function hasSchemas() |
|
278 | 278 | { |
279 | - return ! empty ( $this->arrConfig[ 'schema' ] ); |
|
279 | + return ! empty ($this->arrConfig['schema']); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | /** |
283 | 283 | * @return string[] |
284 | 284 | */ |
285 | - public function getSchemas () |
|
285 | + public function getSchemas() |
|
286 | 286 | { |
287 | - if ( is_string ( $this->arrConfig[ 'schema' ] ) ) |
|
287 | + if (is_string($this->arrConfig['schema'])) |
|
288 | 288 | { |
289 | - return array ( $this->arrConfig[ 'schema' ] ); |
|
289 | + return array($this->arrConfig['schema']); |
|
290 | 290 | } |
291 | 291 | |
292 | - return $this->arrConfig[ 'schema' ]; |
|
292 | + return $this->arrConfig['schema']; |
|
293 | 293 | } |
294 | 294 | |
295 | - public function setSchema ( $schema ) |
|
295 | + public function setSchema($schema) |
|
296 | 296 | { |
297 | - $this->arrConfig[ 'schema' ] = $schema; |
|
297 | + $this->arrConfig['schema'] = $schema; |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | /** |
301 | 301 | * @return string |
302 | 302 | */ |
303 | - public function getHost () |
|
303 | + public function getHost() |
|
304 | 304 | { |
305 | - return $this->arrConfig[ 'host' ]; |
|
305 | + return $this->arrConfig['host']; |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
309 | 309 | * @return int |
310 | 310 | */ |
311 | - public function getPort () |
|
311 | + public function getPort() |
|
312 | 312 | { |
313 | - return $this->arrConfig[ 'port' ]; |
|
313 | + return $this->arrConfig['port']; |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
317 | 317 | * @return boolean |
318 | 318 | */ |
319 | - public function hasPort () |
|
319 | + public function hasPort() |
|
320 | 320 | { |
321 | - return ! empty( $this->arrConfig[ 'port' ] ); |
|
321 | + return ! empty($this->arrConfig['port']); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | /** |
325 | 325 | * @return string |
326 | 326 | */ |
327 | - public function getSocket () |
|
327 | + public function getSocket() |
|
328 | 328 | { |
329 | - return $this->arrConfig[ 'socket' ]; |
|
329 | + return $this->arrConfig['socket']; |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | /** |
333 | 333 | * @return string |
334 | 334 | */ |
335 | - public function getUser () |
|
335 | + public function getUser() |
|
336 | 336 | { |
337 | - return $this->arrConfig[ 'username' ]; |
|
337 | + return $this->arrConfig['username']; |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | /** |
341 | 341 | * @return string |
342 | 342 | */ |
343 | - public function getPassword () |
|
343 | + public function getPassword() |
|
344 | 344 | { |
345 | - return $this->arrConfig[ 'password' ]; |
|
345 | + return $this->arrConfig['password']; |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
349 | 349 | * @return bool |
350 | 350 | */ |
351 | - public function isStatusEnabled () |
|
351 | + public function isStatusEnabled() |
|
352 | 352 | { |
353 | - return (bool) $this->arrConfig[ 'status' ]; |
|
353 | + return (bool) $this->arrConfig['status']; |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | /** |
@@ -358,24 +358,24 @@ discard block |
||
358 | 358 | * |
359 | 359 | * @return string |
360 | 360 | */ |
361 | - public function __get ( $str ) |
|
361 | + public function __get($str) |
|
362 | 362 | { |
363 | - $arr = array ( |
|
364 | - 'namespace' , |
|
365 | - 'framework' , |
|
366 | - 'author' , |
|
367 | - 'license' , |
|
368 | - 'copyright' , |
|
369 | - 'link' , |
|
370 | - 'last_modify' , |
|
371 | - 'path' , |
|
363 | + $arr = array( |
|
364 | + 'namespace', |
|
365 | + 'framework', |
|
366 | + 'author', |
|
367 | + 'license', |
|
368 | + 'copyright', |
|
369 | + 'link', |
|
370 | + 'last_modify', |
|
371 | + 'path', |
|
372 | 372 | 'folder-database', |
373 | 373 | 'folder-name' |
374 | 374 | ); |
375 | 375 | |
376 | - if ( in_array ( $str , $arr ) ) |
|
376 | + if (in_array($str, $arr)) |
|
377 | 377 | { |
378 | - return $this->arrConfig[ strtolower ( $str ) ]; |
|
378 | + return $this->arrConfig[strtolower($str)]; |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | return; |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | protected $fileTpl = "entity.php"; |
23 | 23 | protected $overwrite = true; |
24 | 24 | |
25 | - protected $validFunc = array (); |
|
25 | + protected $validFunc = array(); |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * @param \Classes\MakerFile $makerFile |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return array |
32 | 32 | */ |
33 | - public function parseRelation ( \Classes\MakerFile $makerFile , \Classes\Db\DbTable $dbTable ) |
|
33 | + public function parseRelation(\Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable) |
|
34 | 34 | { |
35 | - return array ( |
|
36 | - 'parents' => $this->listParents ( $makerFile , $dbTable ) , |
|
37 | - 'depends' => $this->listDependence ( $makerFile , $dbTable ) |
|
35 | + return array( |
|
36 | + 'parents' => $this->listParents($makerFile, $dbTable), |
|
37 | + 'depends' => $this->listDependence($makerFile, $dbTable) |
|
38 | 38 | ); |
39 | 39 | } |
40 | 40 | |
@@ -44,35 +44,35 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return array |
46 | 46 | */ |
47 | - private function listParents ( \Classes\MakerFile $makerFile , \Classes\Db\DbTable $dbTable ) |
|
47 | + private function listParents(\Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable) |
|
48 | 48 | { |
49 | - $parents = array (); |
|
50 | - foreach ( $dbTable->getForeingkeys () as $objColumn ) |
|
49 | + $parents = array(); |
|
50 | + foreach ($dbTable->getForeingkeys() as $objColumn) |
|
51 | 51 | { |
52 | - $constrant = $objColumn->getFks (); |
|
52 | + $constrant = $objColumn->getFks(); |
|
53 | 53 | $name = |
54 | 54 | 'Parent' |
55 | 55 | . ZendFrameworkOne::SEPARETOR |
56 | - . AbstractMaker::getClassName ( $constrant->getTable () ) |
|
56 | + . AbstractMaker::getClassName($constrant->getTable()) |
|
57 | 57 | . ZendFrameworkOne::SEPARETOR |
58 | 58 | . 'By' |
59 | 59 | . ZendFrameworkOne::SEPARETOR |
60 | - . $objColumn->getName (); |
|
60 | + . $objColumn->getName(); |
|
61 | 61 | |
62 | - $arrClass = array ( |
|
63 | - $makerFile->getConfig ()->createClassNamespace ( $constrant ), |
|
64 | - AbstractMaker::getClassName ( $constrant->getTable () ) |
|
62 | + $arrClass = array( |
|
63 | + $makerFile->getConfig()->createClassNamespace($constrant), |
|
64 | + AbstractMaker::getClassName($constrant->getTable()) |
|
65 | 65 | ); |
66 | - $class = implode ( ZendFrameworkOne::SEPARETOR , array_filter ( $arrClass ) ); |
|
66 | + $class = implode(ZendFrameworkOne::SEPARETOR, array_filter($arrClass)); |
|
67 | 67 | |
68 | - $parents[] = array ( |
|
69 | - 'class' => $class , |
|
70 | - 'function' => AbstractMaker::getClassName ( $name ) , |
|
71 | - 'table' => $constrant->getTable () , |
|
72 | - 'column' => $objColumn->getName () , |
|
73 | - 'name' => $constrant->getNameConstrant () , |
|
68 | + $parents[] = array( |
|
69 | + 'class' => $class, |
|
70 | + 'function' => AbstractMaker::getClassName($name), |
|
71 | + 'table' => $constrant->getTable(), |
|
72 | + 'column' => $objColumn->getName(), |
|
73 | + 'name' => $constrant->getNameConstrant(), |
|
74 | 74 | ); |
75 | - unset( $name ); |
|
75 | + unset($name); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | return $parents; |
@@ -84,40 +84,40 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return array |
86 | 86 | */ |
87 | - private function listDependence ( \Classes\MakerFile $makerFile , \Classes\Db\DbTable $dbTable ) |
|
87 | + private function listDependence(\Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable) |
|
88 | 88 | { |
89 | - $depends = array (); |
|
90 | - foreach ( $dbTable->getDependences () as $objColumn ) |
|
89 | + $depends = array(); |
|
90 | + foreach ($dbTable->getDependences() as $objColumn) |
|
91 | 91 | { |
92 | - foreach ( $objColumn->getDependences () as $dependence ) |
|
92 | + foreach ($objColumn->getDependences() as $dependence) |
|
93 | 93 | { |
94 | 94 | $name = |
95 | 95 | 'Depend' |
96 | 96 | . ZendFrameworkOne::SEPARETOR |
97 | - . AbstractMaker::getClassName ( $dependence->getTable () ) |
|
97 | + . AbstractMaker::getClassName($dependence->getTable()) |
|
98 | 98 | . ZendFrameworkOne::SEPARETOR |
99 | 99 | . 'By' |
100 | 100 | . ZendFrameworkOne::SEPARETOR |
101 | - . $objColumn->getName (); |
|
101 | + . $objColumn->getName(); |
|
102 | 102 | |
103 | - if ( ! key_exists ( $name , $this->validFunc ) ) |
|
103 | + if ( ! key_exists($name, $this->validFunc)) |
|
104 | 104 | { |
105 | - $arrClass = array ( |
|
106 | - $makerFile->getConfig ()->createClassNamespace ( $dependence ), |
|
107 | - AbstractMaker::getClassName ( $dependence->getTable () ) |
|
105 | + $arrClass = array( |
|
106 | + $makerFile->getConfig()->createClassNamespace($dependence), |
|
107 | + AbstractMaker::getClassName($dependence->getTable()) |
|
108 | 108 | ); |
109 | - $class = implode ( ZendFrameworkOne::SEPARETOR , array_filter ( $arrClass ) ); |
|
109 | + $class = implode(ZendFrameworkOne::SEPARETOR, array_filter($arrClass)); |
|
110 | 110 | |
111 | - $this->validFunc[ $name ] = true; |
|
112 | - $depends[] = array ( |
|
111 | + $this->validFunc[$name] = true; |
|
112 | + $depends[] = array( |
|
113 | 113 | 'class' => $class, |
114 | - 'function' => AbstractMaker::getClassName ( $name ) , |
|
115 | - 'table' => $dependence->getTable () , |
|
116 | - 'column' => $dependence->getColumn () , |
|
117 | - 'name' => $dependence->getNameConstrant () |
|
114 | + 'function' => AbstractMaker::getClassName($name), |
|
115 | + 'table' => $dependence->getTable(), |
|
116 | + 'column' => $dependence->getColumn(), |
|
117 | + 'name' => $dependence->getNameConstrant() |
|
118 | 118 | ); |
119 | 119 | } |
120 | - unset( $name ); |
|
120 | + unset($name); |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 |
@@ -28,67 +28,67 @@ |
||
28 | 28 | * |
29 | 29 | * @return array |
30 | 30 | */ |
31 | - public function parseRelation ( \Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable ) |
|
31 | + public function parseRelation(\Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable) |
|
32 | 32 | { |
33 | 33 | $referenceMap = ''; |
34 | - $references = array (); |
|
34 | + $references = array(); |
|
35 | 35 | $dependentTables = ''; |
36 | - $dependents = array (); |
|
37 | - foreach ( $dbTable->getForeingkeys () as $objColumn ) |
|
36 | + $dependents = array(); |
|
37 | + foreach ($dbTable->getForeingkeys() as $objColumn) |
|
38 | 38 | { |
39 | - $constrant = $objColumn->getFks (); |
|
39 | + $constrant = $objColumn->getFks(); |
|
40 | 40 | |
41 | - $arrClass = array ( |
|
42 | - $makerFile->getConfig ()->createClassNamespace ( $constrant ), |
|
41 | + $arrClass = array( |
|
42 | + $makerFile->getConfig()->createClassNamespace($constrant), |
|
43 | 43 | 'DbTable', |
44 | - AbstractMaker::getClassName ( $constrant->getTable () ) |
|
44 | + AbstractMaker::getClassName($constrant->getTable()) |
|
45 | 45 | ); |
46 | - $class = implode ( ZendFrameworkOne::SEPARETOR , array_filter ( $arrClass ) ); |
|
46 | + $class = implode(ZendFrameworkOne::SEPARETOR, array_filter($arrClass)); |
|
47 | 47 | |
48 | - $references[] = sprintf ( |
|
48 | + $references[] = sprintf( |
|
49 | 49 | " |
50 | 50 | '%s' => array ( |
51 | 51 | 'columns' => '%s' , |
52 | 52 | 'refTableClass' => '%s', |
53 | 53 | 'refColumns' =>'%s' |
54 | 54 | )", |
55 | - AbstractMaker::getClassName ( $constrant->getNameConstrant () ), |
|
56 | - $objColumn->getName (), |
|
55 | + AbstractMaker::getClassName($constrant->getNameConstrant()), |
|
56 | + $objColumn->getName(), |
|
57 | 57 | $class, |
58 | - $constrant->getColumn () |
|
58 | + $constrant->getColumn() |
|
59 | 59 | |
60 | 60 | ); |
61 | 61 | } |
62 | 62 | |
63 | - if ( sizeof ( $references ) > 0 ) |
|
63 | + if (sizeof($references) > 0) |
|
64 | 64 | { |
65 | 65 | $referenceMap = "protected \$_referenceMap = array(" . |
66 | - join ( ',', $references ) . "\n );"; |
|
66 | + join(',', $references) . "\n );"; |
|
67 | 67 | } |
68 | 68 | |
69 | - foreach ( $dbTable->getDependences () as $objColumn ) |
|
69 | + foreach ($dbTable->getDependences() as $objColumn) |
|
70 | 70 | { |
71 | - foreach ( $objColumn->getDependences () as $dependence ) |
|
71 | + foreach ($objColumn->getDependences() as $dependence) |
|
72 | 72 | { |
73 | - $arrClass = array ( |
|
74 | - $makerFile->getConfig ()->createClassNamespace ( $dependence ), |
|
73 | + $arrClass = array( |
|
74 | + $makerFile->getConfig()->createClassNamespace($dependence), |
|
75 | 75 | 'DbTable', |
76 | - AbstractMaker::getClassName ( $dependence->getTable () ) |
|
76 | + AbstractMaker::getClassName($dependence->getTable()) |
|
77 | 77 | ); |
78 | - $class = implode ( ZendFrameworkOne::SEPARETOR , array_filter ( $arrClass ) ); |
|
78 | + $class = implode(ZendFrameworkOne::SEPARETOR, array_filter($arrClass)); |
|
79 | 79 | |
80 | 80 | $dependents[] = $class; |
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
84 | - if ( sizeof ( $dependents ) > 0 ) |
|
84 | + if (sizeof($dependents) > 0) |
|
85 | 85 | { |
86 | 86 | $dependentTables = "protected \$_dependentTables = array(\n '" . |
87 | - join ( "',\n '", $dependents ) . "'\n );"; |
|
87 | + join("',\n '", $dependents) . "'\n );"; |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | |
91 | - return array ( |
|
91 | + return array( |
|
92 | 92 | 'referenceMap' => $referenceMap, |
93 | 93 | 'dependentTables' => $dependentTables |
94 | 94 | ); |