| @@ 22-48 (lines=27) @@ | ||
| 19 | /** |
|
| 20 | * Analyze, generate and write class files. |
|
| 21 | */ |
|
| 22 | public function write() |
|
| 23 | { |
|
| 24 | // Create module cache folder if not exists |
|
| 25 | if (!file_exists($this->path)) { |
|
| 26 | @mkdir($path, 0777, true); |
|
| 27 | } |
|
| 28 | ||
| 29 | foreach ($this->analyzers as $analyzerClass => $analyzer) { |
|
| 30 | // Analyze database structure and get entities metadata |
|
| 31 | foreach ($analyzer->analyze() as $metadata) { |
|
| 32 | // Iterate all generators for analyzer |
|
| 33 | foreach ($this->generators[$analyzerClass] as $generator) { |
|
| 34 | /** @var Generic $generator Create class generator */ |
|
| 35 | $generator = new $generator($this->codeGenerator->defNamespace($this->namespace), $metadata); |
|
| 36 | ||
| 37 | // Create entity generated class names |
|
| 38 | $file = $this->path . $generator->className . '.php'; |
|
| 39 | ||
| 40 | // Create entity query class files |
|
| 41 | file_put_contents($file, '<?php' . $generator->generate()); |
|
| 42 | ||
| 43 | // Require files |
|
| 44 | require($file); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | } |
|
| 48 | } |
|
| 49 | } |
|
| 50 | //[PHPCOMPRESSOR(remove,end)] |
|
| 51 | ||
| @@ 70-96 (lines=27) @@ | ||
| 67 | /** |
|
| 68 | * Analyze, generate and write class files. |
|
| 69 | */ |
|
| 70 | public function write() |
|
| 71 | { |
|
| 72 | // Create module cache folder if not exists |
|
| 73 | if (!file_exists($this->path)) { |
|
| 74 | @mkdir($path, 0777, true); |
|
| 75 | } |
|
| 76 | ||
| 77 | foreach ($this->analyzers as $analyzerClass => $analyzer) { |
|
| 78 | // Analyze database structure and get entities metadata |
|
| 79 | foreach ($analyzer->analyze() as $metadata) { |
|
| 80 | // Iterate all generators for analyzer |
|
| 81 | foreach ($this->generators[$analyzerClass] as $generator) { |
|
| 82 | /** @var Generic $generator Create class generator */ |
|
| 83 | $generator = new $generator($this->codeGenerator->defNamespace($this->namespace), $metadata); |
|
| 84 | ||
| 85 | // Create entity generated class names |
|
| 86 | $file = $this->path . $generator->className . '.php'; |
|
| 87 | ||
| 88 | // Create entity query class files |
|
| 89 | file_put_contents($file, '<?php' . $generator->generate()); |
|
| 90 | ||
| 91 | // Require files |
|
| 92 | require($file); |
|
| 93 | } |
|
| 94 | } |
|
| 95 | } |
|
| 96 | } |
|
| 97 | } |
|
| 98 | //[PHPCOMPRESSOR(remove,end)] |
|
| 99 | ||