1 | <?php |
||
14 | class CodeGeneratorService extends AbstractService { |
||
15 | |||
16 | private $codegen; |
||
|
|||
17 | |||
18 | public function getCodegenFile() { |
||
21 | 7 | ||
22 | /** |
||
23 | * Returns codegen from project |
||
24 | * |
||
25 | * @throws JsonEmptyException |
||
26 | * @throws \RuntimeException |
||
27 | * @return CodegenSchema |
||
28 | */ |
||
29 | public function getCodegen() { |
||
32 | 7 | ||
33 | 7 | /** |
|
34 | 7 | * Adds authors to the docblock of the given struct |
|
35 | * |
||
36 | 7 | * @param AbstractPhpStruct $struct |
|
37 | 12 | * @param PackageSchema $package |
|
38 | */ |
||
39 | public function addAuthors(AbstractPhpStruct $struct, PackageSchema $package = null) { |
||
57 | |||
58 | /** |
||
59 | * Returns code for hydrating a propel model |
||
60 | * |
||
61 | * @param string $modelName |
||
62 | * @return string |
||
63 | */ |
||
64 | public function getWriteFields($modelName) { |
||
83 | 15 | ||
84 | /** |
||
85 | * Returns the fields for a model |
||
86 | * |
||
87 | * @param string $modelName |
||
88 | * @return array |
||
89 | */ |
||
90 | public function getReadFields($modelName) { |
||
91 | 5 | $codegen = $this->getCodegen(); |
|
92 | 5 | $model = $this->modelService->getModel($modelName); |
|
93 | 5 | // $computed = $this->getComputedFields($model); |
|
94 | 5 | $filter = $codegen->getReadFilter($modelName); |
|
95 | 5 | // $filter = array_merge($filter, $computed); |
|
96 | 5 | ||
97 | 5 | $fields = []; |
|
98 | $cols = $model->getColumns(); |
||
99 | 5 | foreach ($cols as $col) { |
|
100 | 5 | $prop = $col->getName(); |
|
101 | 5 | ||
102 | 5 | if (!in_array($prop, $filter) && !$col->isForeignKey() && !$col->isPrimaryKey()) { |
|
103 | $fields[] = $prop; |
||
104 | 5 | } |
|
105 | 5 | } |
|
106 | |||
107 | 5 | return $fields; |
|
108 | } |
||
109 | |||
110 | /** |
||
111 | 5 | * Returns computed model fields |
|
112 | 5 | * |
|
113 | 5 | * @param Table $table |
|
114 | * @return array<string> |
||
115 | 5 | */ |
|
116 | 5 | public function getComputedFields(Table $table) { |
|
135 | |||
136 | /** |
||
137 | * Helper to represent an array as php code |
||
138 | * |
||
139 | * @param array $array |
||
140 | * @return string |
||
141 | */ |
||
142 | public function arrayToCode(array $array) { |
||
154 | 5 | ||
155 | 5 | /** |
|
156 | 5 | * Returns the filename for a given struct |
|
157 | 5 | * |
|
158 | 5 | * @param AbstractPhpStruct $struct |
|
159 | 5 | * @return string |
|
160 | */ |
||
161 | 5 | public function getFilename(AbstractPhpStruct $struct) { |
|
175 | |||
176 | 2 | /** |
|
177 | 2 | * Returns a file object for a given struct |
|
178 | 2 | * |
|
179 | * @param AbstractPhpStruct $struct |
||
180 | 2 | * @return File |
|
181 | */ |
||
182 | 2 | public function getFile(AbstractPhpStruct $struct) { |
|
185 | |||
186 | 2 | public function dumpStruct(AbstractPhpStruct $struct, $overwrite = false) { |
|
202 | } |
||
203 |
This check marks private properties in classes that are never used. Those properties can be removed.