Переглянути джерело

fixed namespaces

tags/0.1.0
Robin Thoni 9 роки тому
джерело
коміт
531af3411a

+ 8
- 2
composer.json Переглянути файл

@@ -7,14 +7,20 @@
7 7
             "email": "robin@rthoni.com"
8 8
         }
9 9
     ],
10
+    "repositories": [{
11
+      "type": "vcs",
12
+      "url":  "https://git.rthoni.com/luticate/utils.git"
13
+    }],
10 14
     "require": {
11 15
       "laravel/lumen-framework": "5.1.x-dev",
12 16
       "vlucas/phpdotenv": "~1.0",
13
-      "twig/twig": "1.x-dev"
17
+      "twig/twig": "1.x-dev",
18
+      "luticate/utils": "*"
14 19
     },
15 20
     "autoload": {
16 21
       "psr-4": {
17 22
         "Luticate\\": "src/"
18 23
       }
19
-    }
24
+    },
25
+    "minimum-stability": "dev"
20 26
 }

+ 23
- 22
src/Generator/LuGenerator.php Переглянути файл

@@ -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
     }

+ 3
- 3
src/Generator/business.php.twig Переглянути файл

@@ -1,10 +1,10 @@
1 1
 {{ "<?php" }}
2 2
 
3
-namespace {{ namespace.as_it }};
3
+namespace {{ business_namespace.as_it }};
4 4
 
5 5
 use Luticate\Utils\LuBusiness;
6
-use App\Http\DataAccess\{{ data_access_name.as_it }};
7
-use App\Http\DBO\{{ dbo_name.as_it }};
6
+use {{ dataaccess_namespace.as_it }}\{{ data_access_name.as_it }};
7
+use {{ dbo_namespace.as_it }}\{{ dbo_name.as_it }};
8 8
 
9 9
 class {{ business_name.as_it }} extends LuBusiness {
10 10
     public function __construct()

+ 4
- 4
src/Generator/dataaccess.php.twig Переглянути файл

@@ -1,15 +1,15 @@
1 1
 {{ "<?php" }}
2 2
 
3
-namespace {{ namespace.as_it }};
3
+namespace {{ dataaccess_namespace.as_it }};
4 4
 
5 5
 use Luticate\Utils\LuDataAccess;
6
-use App\Http\DataAccess\Models\{{ model_name.as_it }};
7
-use App\Http\DBO\{{ dbo_name.as_it }};
6
+use {{ models_namespace.as_it }}\{{ model_user_name.as_it }};
7
+use {{ dbo_namespace.as_it }}\{{ dbo_name.as_it }};
8 8
 
9 9
 class {{ data_access_name.as_it }} extends LuDataAccess {
10 10
     public function __construct()
11 11
     {
12 12
         parent::__construct();
13
-        $this->model = new {{ model_name.as_it }}();
13
+        $this->model = new {{ model_user_name.as_it }}();
14 14
     }
15 15
 }

+ 1
- 1
src/Generator/dbo.php.twig Переглянути файл

@@ -5,7 +5,7 @@
5 5
  * ANY CHANGES WILL BE OVERWRITTEN
6 6
  */
7 7
 
8
-namespace {{ namespace.as_it }};
8
+namespace {{ dbo_namespace.as_it }};
9 9
 
10 10
 use Luticate\Utils\LuDbo;
11 11
 

+ 3
- 3
src/Generator/model.php.twig Переглянути файл

@@ -8,10 +8,10 @@
8 8
  * TO MAKE YOUR CHANGES AND DATABASE ACCESS
9 9
 */
10 10
 
11
-namespace {{ namespace.as_it }};
11
+namespace {{ models_namespace.as_it }};
12 12
 
13 13
 use Luticate\Utils\LuModel;
14
-use App\Http\DBO\{{ dbo_name.camel_upper }};
14
+use {{ dbo_namespace.as_it }}\{{ dbo_name.camel_upper }};
15 15
 
16 16
 class {{ model_name.camel_upper }} extends LuModel
17 17
 {
@@ -33,7 +33,7 @@ class {{ model_name.camel_upper }} extends LuModel
33 33
     }
34 34
 
35 35
     /**
36
-     * @param $dbo \App\Http\DBO\{{ dbo_name.camel_upper }}
36
+     * @param $dbo {{ dbo_name.camel_upper }}
37 37
      * @param $model LuModel|null
38 38
      * @return {{ model_user_name.camel_upper }}
39 39
      */

+ 2
- 2
src/Generator/model_user.php.twig Переглянути файл

@@ -1,8 +1,8 @@
1 1
 {{ "<?php" }}
2 2
 
3
-namespace {{ namespace.as_it }};
3
+namespace {{ models_namespace.as_it }};
4 4
 
5
-use App\Http\DBO\{{ dbo_name.camel_upper }};
5
+use {{ dbo_namespace.as_it }}\{{ dbo_name.camel_upper }};
6 6
 
7 7
 class {{ model_user_name.camel_upper }} extends {{ model_name.camel_upper }}
8 8
 {

+ 1
- 1
src/Generator/sp.php.twig Переглянути файл

@@ -5,7 +5,7 @@
5 5
  * ANY CHANGES WILL BE OVERWRITTEN
6 6
  */
7 7
 
8
-namespace {{ namespace.as_it }};
8
+namespace {{ sp_namespace.as_it }};
9 9
 
10 10
 use Luticate\Utils\LuSpModel;
11 11
 use Illuminate\Support\Facades\DB;

Завантаження…
Відмінити
Зберегти