Browse Source

fixed namespaces

tags/0.1.0
Robin Thoni 9 years ago
parent
commit
531af3411a

+ 8
- 2
composer.json View File

7
             "email": "robin@rthoni.com"
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
     "require": {
14
     "require": {
11
       "laravel/lumen-framework": "5.1.x-dev",
15
       "laravel/lumen-framework": "5.1.x-dev",
12
       "vlucas/phpdotenv": "~1.0",
16
       "vlucas/phpdotenv": "~1.0",
13
-      "twig/twig": "1.x-dev"
17
+      "twig/twig": "1.x-dev",
18
+      "luticate/utils": "*"
14
     },
19
     },
15
     "autoload": {
20
     "autoload": {
16
       "psr-4": {
21
       "psr-4": {
17
         "Luticate\\": "src/"
22
         "Luticate\\": "src/"
18
       }
23
       }
19
-    }
24
+    },
25
+    "minimum-stability": "dev"
20
 }
26
 }

+ 23
- 22
src/Generator/LuGenerator.php View File

91
 
91
 
92
     protected function buildTwig($templateFile, $destFile, $vars)
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
         $twig_vars = $this->buildTwigVars($vars);
100
         $twig_vars = $this->buildTwigVars($vars);
95
 
101
 
96
         Twig_Autoloader::register();
102
         Twig_Autoloader::register();
157
         return $array;
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
         $vars = array(
168
         $vars = array(
163
             "dbo_name" => $name,
169
             "dbo_name" => $name,
164
-            "columns" => $columns,
165
-            "namespace" => $namespace
170
+            "columns" => $columns
166
         );
171
         );
167
         $this->buildTwig('dbo.php', $file, $vars);
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
         $vars = array(
177
         $vars = array(
173
             "model_name" => $modelName,
178
             "model_name" => $modelName,
174
             "model_user_name" => $modelUserName,
179
             "model_user_name" => $modelUserName,
175
             "dbo_name" => $dboName,
180
             "dbo_name" => $dboName,
176
-            "columns" => $columns,
177
-            "namespace" => $namespace
181
+            "columns" => $columns
178
         );
182
         );
179
         $this->buildTwig('model.php', $file, $vars);
183
         $this->buildTwig('model.php', $file, $vars);
180
 
184
 
231
             return $this->printError($spQuery, "Failed to get arguments for stored procedure " . $sp_name);
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
         $vars = array(
240
         $vars = array(
237
             "sp" => $sp,
241
             "sp" => $sp,
238
-            "args" => $args,
239
-            "namespace" => $namespace
242
+            "args" => $args
240
         );
243
         );
241
         $this->buildTwig('sp.php', $file, $vars);
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
         if (file_exists($file))
249
         if (file_exists($file))
247
             return;
250
             return;
248
         $vars = array(
251
         $vars = array(
249
             "data_access_name" => $dataAccessName,
252
             "data_access_name" => $dataAccessName,
250
             "model_name" => $modelName,
253
             "model_name" => $modelName,
251
-            "dbo_name" => $dboName,
252
-            "namespace" => $namespace
254
+            "model_user_name" => $modelUserName,
255
+            "dbo_name" => $dboName
253
         );
256
         );
254
         $this->buildTwig('dataaccess.php', $file, $vars);
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
         if (file_exists($file))
262
         if (file_exists($file))
260
             return;
263
             return;
261
         $vars = array(
264
         $vars = array(
262
             "business_name" => $businessName,
265
             "business_name" => $businessName,
263
             "data_access_name" => $dataAccessName,
266
             "data_access_name" => $dataAccessName,
264
-            "dbo_name" => $dboName,
265
-            "namespace" => $namespace
267
+            "dbo_name" => $dboName
266
         );
268
         );
267
         $this->buildTwig('business.php', $file, $vars);
269
         $this->buildTwig('business.php', $file, $vars);
268
     }
270
     }
318
                 $dboName = $baseName . "Dbo";
320
                 $dboName = $baseName . "Dbo";
319
                 $dataAccessName = $baseName . "DataAccess";
321
                 $dataAccessName = $baseName . "DataAccess";
320
                 $businessName = $baseName . "Business";
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
                 $this->generateModel($modelName, $modelUserName, $dboName, $columns, $model_dir . $modelName . ".php",
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
                 $this->generateBusiness($businessName, $dataAccessName, $dboName,
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
         $sps = $this->getStoredProcedures();
332
         $sps = $this->getStoredProcedures();
343
                 $args["in"] = $this->sqlTypesToPhpTypes($args["in"]);
344
                 $args["in"] = $this->sqlTypesToPhpTypes($args["in"]);
344
                 $args["out"] = $this->sqlTypesToPhpTypes($args["out"]);
345
                 $args["out"] = $this->sqlTypesToPhpTypes($args["out"]);
345
                 $sp_model_name = $this->snakeToCamelCase($sp_name, true);
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 View File

1
 {{ "<?php" }}
1
 {{ "<?php" }}
2
 
2
 
3
-namespace {{ namespace.as_it }};
3
+namespace {{ business_namespace.as_it }};
4
 
4
 
5
 use Luticate\Utils\LuBusiness;
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
 class {{ business_name.as_it }} extends LuBusiness {
9
 class {{ business_name.as_it }} extends LuBusiness {
10
     public function __construct()
10
     public function __construct()

+ 4
- 4
src/Generator/dataaccess.php.twig View File

1
 {{ "<?php" }}
1
 {{ "<?php" }}
2
 
2
 
3
-namespace {{ namespace.as_it }};
3
+namespace {{ dataaccess_namespace.as_it }};
4
 
4
 
5
 use Luticate\Utils\LuDataAccess;
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
 class {{ data_access_name.as_it }} extends LuDataAccess {
9
 class {{ data_access_name.as_it }} extends LuDataAccess {
10
     public function __construct()
10
     public function __construct()
11
     {
11
     {
12
         parent::__construct();
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 View File

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

+ 3
- 3
src/Generator/model.php.twig View File

8
  * TO MAKE YOUR CHANGES AND DATABASE ACCESS
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
 use Luticate\Utils\LuModel;
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
 class {{ model_name.camel_upper }} extends LuModel
16
 class {{ model_name.camel_upper }} extends LuModel
17
 {
17
 {
33
     }
33
     }
34
 
34
 
35
     /**
35
     /**
36
-     * @param $dbo \App\Http\DBO\{{ dbo_name.camel_upper }}
36
+     * @param $dbo {{ dbo_name.camel_upper }}
37
      * @param $model LuModel|null
37
      * @param $model LuModel|null
38
      * @return {{ model_user_name.camel_upper }}
38
      * @return {{ model_user_name.camel_upper }}
39
      */
39
      */

+ 2
- 2
src/Generator/model_user.php.twig View File

1
 {{ "<?php" }}
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
 class {{ model_user_name.camel_upper }} extends {{ model_name.camel_upper }}
7
 class {{ model_user_name.camel_upper }} extends {{ model_name.camel_upper }}
8
 {
8
 {

+ 1
- 1
src/Generator/sp.php.twig View File

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

Loading…
Cancel
Save