|
@@ -91,6 +91,12 @@ class LuGenerator {
|
91
|
91
|
|
92
|
92
|
protected function buildTwig($templateFile, $destFile, $vars)
|
93
|
93
|
{
|
|
94
|
+ $vars["dbo_namespace"] = $this->_config["dbo"]["namespace"];
|
|
95
|
+ $vars["models_namespace"] = $this->_config["models"]["namespace"];
|
|
96
|
+ $vars["sp_namespace"] = $this->_config["sp"]["namespace"];
|
|
97
|
+ $vars["dataaccess_namespace"] = $this->_config["dataaccess"]["namespace"];
|
|
98
|
+ $vars["business_namespace"] = $this->_config["business"]["namespace"];
|
|
99
|
+
|
94
|
100
|
$twig_vars = $this->buildTwigVars($vars);
|
95
|
101
|
|
96
|
102
|
Twig_Autoloader::register();
|
|
@@ -157,24 +163,22 @@ WHERE table_type = 'BASE TABLE' AND table_schema NOT IN ('pg_catalog', 'informat
|
157
|
163
|
return $array;
|
158
|
164
|
}
|
159
|
165
|
|
160
|
|
- public function generateDbo($name, $columns, $file, $namespace)
|
|
166
|
+ public function generateDbo($name, $columns, $file)
|
161
|
167
|
{
|
162
|
168
|
$vars = array(
|
163
|
169
|
"dbo_name" => $name,
|
164
|
|
- "columns" => $columns,
|
165
|
|
- "namespace" => $namespace
|
|
170
|
+ "columns" => $columns
|
166
|
171
|
);
|
167
|
172
|
$this->buildTwig('dbo.php', $file, $vars);
|
168
|
173
|
}
|
169
|
174
|
|
170
|
|
- public function generateModel($modelName, $modelUserName, $dboName, $columns, $file, $fileUser, $namespace)
|
|
175
|
+ public function generateModel($modelName, $modelUserName, $dboName, $columns, $file, $fileUser)
|
171
|
176
|
{
|
172
|
177
|
$vars = array(
|
173
|
178
|
"model_name" => $modelName,
|
174
|
179
|
"model_user_name" => $modelUserName,
|
175
|
180
|
"dbo_name" => $dboName,
|
176
|
|
- "columns" => $columns,
|
177
|
|
- "namespace" => $namespace
|
|
181
|
+ "columns" => $columns
|
178
|
182
|
);
|
179
|
183
|
$this->buildTwig('model.php', $file, $vars);
|
180
|
184
|
|
|
@@ -231,38 +235,36 @@ ORDER BY parameters.ordinal_position;");
|
231
|
235
|
return $this->printError($spQuery, "Failed to get arguments for stored procedure " . $sp_name);
|
232
|
236
|
}
|
233
|
237
|
|
234
|
|
- public function generateSp($sp, $args, $file, $namespace)
|
|
238
|
+ public function generateSp($sp, $args, $file)
|
235
|
239
|
{
|
236
|
240
|
$vars = array(
|
237
|
241
|
"sp" => $sp,
|
238
|
|
- "args" => $args,
|
239
|
|
- "namespace" => $namespace
|
|
242
|
+ "args" => $args
|
240
|
243
|
);
|
241
|
244
|
$this->buildTwig('sp.php', $file, $vars);
|
242
|
245
|
}
|
243
|
246
|
|
244
|
|
- public function generateDataAccess($dataAccessName, $modelName, $dboName, $file, $namespace)
|
|
247
|
+ public function generateDataAccess($dataAccessName, $modelName, $modelUserName, $dboName, $file)
|
245
|
248
|
{
|
246
|
249
|
if (file_exists($file))
|
247
|
250
|
return;
|
248
|
251
|
$vars = array(
|
249
|
252
|
"data_access_name" => $dataAccessName,
|
250
|
253
|
"model_name" => $modelName,
|
251
|
|
- "dbo_name" => $dboName,
|
252
|
|
- "namespace" => $namespace
|
|
254
|
+ "model_user_name" => $modelUserName,
|
|
255
|
+ "dbo_name" => $dboName
|
253
|
256
|
);
|
254
|
257
|
$this->buildTwig('dataaccess.php', $file, $vars);
|
255
|
258
|
}
|
256
|
259
|
|
257
|
|
- public function generateBusiness($businessName, $dataAccessName, $dboName, $file, $namespace)
|
|
260
|
+ public function generateBusiness($businessName, $dataAccessName, $dboName, $file)
|
258
|
261
|
{
|
259
|
262
|
if (file_exists($file))
|
260
|
263
|
return;
|
261
|
264
|
$vars = array(
|
262
|
265
|
"business_name" => $businessName,
|
263
|
266
|
"data_access_name" => $dataAccessName,
|
264
|
|
- "dbo_name" => $dboName,
|
265
|
|
- "namespace" => $namespace
|
|
267
|
+ "dbo_name" => $dboName
|
266
|
268
|
);
|
267
|
269
|
$this->buildTwig('business.php', $file, $vars);
|
268
|
270
|
}
|
|
@@ -318,14 +320,13 @@ ORDER BY parameters.ordinal_position;");
|
318
|
320
|
$dboName = $baseName . "Dbo";
|
319
|
321
|
$dataAccessName = $baseName . "DataAccess";
|
320
|
322
|
$businessName = $baseName . "Business";
|
321
|
|
- $this->generateDbo($dboName, $columns, $dbo_dir . $dboName . ".php",
|
322
|
|
- $this->_config["dbo"]["namespace"]);
|
|
323
|
+ $this->generateDbo($dboName, $columns, $dbo_dir . $dboName . ".php");
|
323
|
324
|
$this->generateModel($modelName, $modelUserName, $dboName, $columns, $model_dir . $modelName . ".php",
|
324
|
|
- $model_dir . $modelUserName . ".php", $this->_config["models"]["namespace"]);
|
325
|
|
- $this->generateDataAccess($dataAccessName, $modelName, $dboName,
|
326
|
|
- $manager_dir . $dataAccessName . ".php", $this->_config["dataaccess"]["namespace"]);
|
|
325
|
+ $model_dir . $modelUserName . ".php");
|
|
326
|
+ $this->generateDataAccess($dataAccessName, $modelName, $modelUserName, $dboName,
|
|
327
|
+ $manager_dir . $dataAccessName . ".php");
|
327
|
328
|
$this->generateBusiness($businessName, $dataAccessName, $dboName,
|
328
|
|
- $business_dir . $businessName . ".php", $this->_config["business"]["namespace"]);
|
|
329
|
+ $business_dir . $businessName . ".php");
|
329
|
330
|
}
|
330
|
331
|
}
|
331
|
332
|
$sps = $this->getStoredProcedures();
|
|
@@ -343,7 +344,7 @@ ORDER BY parameters.ordinal_position;");
|
343
|
344
|
$args["in"] = $this->sqlTypesToPhpTypes($args["in"]);
|
344
|
345
|
$args["out"] = $this->sqlTypesToPhpTypes($args["out"]);
|
345
|
346
|
$sp_model_name = $this->snakeToCamelCase($sp_name, true);
|
346
|
|
- $this->generateSp($sp, $args, $sp_dir . $sp_model_name . ".php", $this->_config["sp"]["namespace"]);
|
|
347
|
+ $this->generateSp($sp, $args, $sp_dir . $sp_model_name . ".php");
|
347
|
348
|
}
|
348
|
349
|
}
|
349
|
350
|
}
|