Browse Source

added dynamic namespace

tags/0.1.0
Robin Thoni 9 years ago
parent
commit
14feb663ca

+ 34
- 28
src/Generator/LuGenerator.php View File

13
     private $_config = array("dbo" =>
13
     private $_config = array("dbo" =>
14
         array(
14
         array(
15
             "namespace" => 'App\Http\DBO',
15
             "namespace" => 'App\Http\DBO',
16
-            "folder" => '../app/Http/DBO',
17
-            "mode" => 0775
16
+            "folder" => '../app/Http/DBO'
18
         ),
17
         ),
19
         "models" =>
18
         "models" =>
20
             array(
19
             array(
21
                 "namespace" => 'App\Http\DataAccess\Models',
20
                 "namespace" => 'App\Http\DataAccess\Models',
22
-                "folder" => '../app/Http/DataAccess/Models',
23
-                "mode" => 0775
21
+                "folder" => '../app/Http/DataAccess/Models'
24
             ),
22
             ),
25
         "sp" =>
23
         "sp" =>
26
             array(
24
             array(
27
                 "namespace" => 'App\Http\DataAccess\SP',
25
                 "namespace" => 'App\Http\DataAccess\SP',
28
-                "folder" => '../app/Http/DataAccess/SP',
29
-                "mode" => 0775
26
+                "folder" => '../app/Http/DataAccess/SP'
30
             ),
27
             ),
31
         "dataaccess" =>
28
         "dataaccess" =>
32
             array(
29
             array(
33
                 "namespace" => 'App\Http\DataAccess',
30
                 "namespace" => 'App\Http\DataAccess',
34
-                "folder" => '../app/Http/DataAccess',
35
-                "mode" => 0775
31
+                "folder" => '../app/Http/DataAccess'
36
             ),
32
             ),
37
         "business" =>
33
         "business" =>
38
             array(
34
             array(
39
                 "namespace" => 'App\Http\Business',
35
                 "namespace" => 'App\Http\Business',
40
-                "folder" => '../app/Http/Business',
41
-                "mode" => 0775
42
-            )
36
+                "folder" => '../app/Http/Business'
37
+            ),
38
+        "mode" => 0755
43
     );
39
     );
44
     /**
40
     /**
45
      * @return array
41
      * @return array
157
         return $array;
153
         return $array;
158
     }
154
     }
159
 
155
 
160
-    public function generateDbo($name, $columns, $file)
156
+    public function generateDbo($name, $columns, $file, $namespace)
161
     {
157
     {
162
         $vars = array(
158
         $vars = array(
163
             "dbo_name" => $name,
159
             "dbo_name" => $name,
164
-            "columns" => $columns
160
+            "columns" => $columns,
161
+            "namespace" => $namespace
165
         );
162
         );
166
         $this->buildTwig('dbo.php', $file, $vars);
163
         $this->buildTwig('dbo.php', $file, $vars);
167
     }
164
     }
168
 
165
 
169
-    public function generateModel($modelName, $dboName, $columns, $file)
166
+    public function generateModel($modelName, $dboName, $columns, $file, $namespace)
170
     {
167
     {
171
         $vars = array(
168
         $vars = array(
172
             "model_name" => $modelName,
169
             "model_name" => $modelName,
173
             "dbo_name" => $dboName,
170
             "dbo_name" => $dboName,
174
-            "columns" => $columns
171
+            "columns" => $columns,
172
+            "namespace" => $namespace
175
         );
173
         );
176
         $this->buildTwig('model.php', $file, $vars);
174
         $this->buildTwig('model.php', $file, $vars);
177
     }
175
     }
233
         $this->buildTwig('sp.php', $file, $vars);
231
         $this->buildTwig('sp.php', $file, $vars);
234
     }
232
     }
235
 
233
 
236
-    public function generateDataAccess($dataAccessName, $modelName, $dboName, $file)
234
+    public function generateDataAccess($dataAccessName, $modelName, $dboName, $file, $namespace)
237
     {
235
     {
238
         if (file_exists($file))
236
         if (file_exists($file))
239
             return;
237
             return;
240
         $vars = array(
238
         $vars = array(
241
             "data_access_name" => $dataAccessName,
239
             "data_access_name" => $dataAccessName,
242
             "model_name" => $modelName,
240
             "model_name" => $modelName,
243
-            "dbo_name" => $dboName
241
+            "dbo_name" => $dboName,
242
+            "namespace" => $namespace
244
         );
243
         );
245
         $this->buildTwig('dataaccess.php', $file, $vars);
244
         $this->buildTwig('dataaccess.php', $file, $vars);
246
     }
245
     }
247
 
246
 
248
-    public function generateBusiness($businessName, $dataAccessName, $dboName, $file)
247
+    public function generateBusiness($businessName, $dataAccessName, $dboName, $file, $namespace)
249
     {
248
     {
250
         if (file_exists($file))
249
         if (file_exists($file))
251
             return;
250
             return;
252
         $vars = array(
251
         $vars = array(
253
             "business_name" => $businessName,
252
             "business_name" => $businessName,
254
             "data_access_name" => $dataAccessName,
253
             "data_access_name" => $dataAccessName,
255
-            "dbo_name" => $dboName
254
+            "dbo_name" => $dboName,
255
+            "namespace" => $namespace
256
         );
256
         );
257
         $this->buildTwig('business.php', $file, $vars);
257
         $this->buildTwig('business.php', $file, $vars);
258
     }
258
     }
271
         $manager_dir = $this->_config["dataaccess"]["folder"] . "/";
271
         $manager_dir = $this->_config["dataaccess"]["folder"] . "/";
272
         $business_dir = $this->_config["business"]["folder"] . "/";
272
         $business_dir = $this->_config["business"]["folder"] . "/";
273
 
273
 
274
-        $this->mkdir($dbo_dir, $this->_config["dbo"]["mode"]);
275
-        $this->mkdir($model_dir, $this->_config["models"]["mode"]);
276
-        $this->mkdir($sp_dir, $this->_config["sp"]["mode"]);
277
-        $this->mkdir($manager_dir, $this->_config["dataaccess"]["mode"]);
278
-        $this->mkdir($business_dir, $this->_config["business"]["mode"]);
274
+        $mode = $this->_config["mode"];
275
+
276
+        $this->mkdir($dbo_dir, $mode);
277
+        $this->mkdir($model_dir, $mode);
278
+        $this->mkdir($sp_dir, $mode);
279
+        $this->mkdir($manager_dir, $mode);
280
+        $this->mkdir($business_dir, $mode);
279
 
281
 
280
         $tables = $this->getTables();
282
         $tables = $this->getTables();
281
         if (!is_null($tables)) {
283
         if (!is_null($tables)) {
290
                 $dboName = $baseName . "Dbo";
292
                 $dboName = $baseName . "Dbo";
291
                 $dataAccessName = $baseName . "DataAccess";
293
                 $dataAccessName = $baseName . "DataAccess";
292
                 $businessName = $baseName . "Business";
294
                 $businessName = $baseName . "Business";
293
-                $this->generateDbo($dboName, $columns, $dbo_dir . $dboName . ".php");
294
-                $this->generateModel($modelName, $dboName, $columns, $model_dir . $modelName . ".php");
295
-                $this->generateDataAccess($dataAccessName, $modelName, $dboName, $manager_dir . $dataAccessName . ".php");
296
-                $this->generateBusiness($businessName, $dataAccessName, $dboName, $business_dir . $businessName . ".php");
295
+                $this->generateDbo($dboName, $columns, $dbo_dir . $dboName . ".php",
296
+                    $this->_config["dbo"]["namespace"]);
297
+                $this->generateModel($modelName, $dboName, $columns, $model_dir . $modelName . ".php",
298
+                    $this->_config["models"]["namespace"]);
299
+                $this->generateDataAccess($dataAccessName, $modelName, $dboName,
300
+                    $manager_dir . $dataAccessName . ".php", $this->_config["dataaccess"]["namespace"]);
301
+                $this->generateBusiness($businessName, $dataAccessName, $dboName,
302
+                    $business_dir . $businessName . ".php", $this->_config["business"]["namespace"]);
297
             }
303
             }
298
         }
304
         }
299
         $sps = $this->getStoredProcedures();
305
         $sps = $this->getStoredProcedures();

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

1
 {{ "<?php" }}
1
 {{ "<?php" }}
2
 
2
 
3
-namespace App\Http\Business;
3
+namespace {{ 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 }};
6
 use App\Http\DataAccess\{{ data_access_name.as_it }};

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

1
 {{ "<?php" }}
1
 {{ "<?php" }}
2
 
2
 
3
-namespace App\Http\DataAccess;
3
+namespace {{ 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 }};
6
 use App\Http\DataAccess\Models\{{ model_name.as_it }};

+ 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 App\Http\DBO;
8
+namespace {{ namespace.as_it }};
9
 
9
 
10
 use Luticate\Utils\LuDbo;
10
 use Luticate\Utils\LuDbo;
11
 
11
 

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

5
 * ANY CHANGES WILL BE OVERWRITTEN
5
 * ANY CHANGES WILL BE OVERWRITTEN
6
 */
6
 */
7
 
7
 
8
-namespace App\Http\DataAccess\Models;
8
+namespace {{ namespace.as_it }};
9
 
9
 
10
 use Luticate\Utils\LuModel;
10
 use Luticate\Utils\LuModel;
11
 use App\Http\DBO\{{ dbo_name.camel_upper }};
11
 use App\Http\DBO\{{ dbo_name.camel_upper }};

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

1
 {{ "<?php" }}
1
 {{ "<?php" }}
2
 
2
 
3
-namespace App\Http\DataAccess\SP;
3
+namespace {{ namespace.as_it }};
4
 
4
 
5
 use Luticate\Utils\LuSpModel;
5
 use Luticate\Utils\LuSpModel;
6
 use Illuminate\Support\Facades\DB;
6
 use Illuminate\Support\Facades\DB;

Loading…
Cancel
Save