Parcourir la source

default configuration

tags/0.1.0
Robin Thoni il y a 9 ans
Parent
révision
61bfa3780d
3 fichiers modifiés avec 79 ajouts et 12 suppressions
  1. 4
    1
      .gitignore
  2. 57
    11
      src/Generator/LuGenerator.php
  3. 18
    0
      test/generate.php

+ 4
- 1
.gitignore Voir le fichier

@@ -1,3 +1,6 @@
1 1
 /.idea
2 2
 /composer.lock
3
-/vendor
3
+/vendor
4
+/.env
5
+/app
6
+/test/generated

+ 57
- 11
src/Generator/LuGenerator.php Voir le fichier

@@ -10,6 +10,52 @@ use Twig_Loader_Filesystem;
10 10
 class LuGenerator {
11 11
     private $_pdo;
12 12
 
13
+    private $_config = array("dbo" =>
14
+        array(
15
+            "namespace" => 'App\Http\DBO',
16
+            "folder" => '../app/Http/DBO',
17
+            "mode" => 0775
18
+        ),
19
+        "models" =>
20
+            array(
21
+                "namespace" => 'App\Http\DataAccess\Models',
22
+                "folder" => '../app/Http/DataAccess/Models',
23
+                "mode" => 0775
24
+            ),
25
+        "sp" =>
26
+            array(
27
+                "namespace" => 'App\Http\DataAccess\SP',
28
+                "folder" => '../app/Http/DataAccess/SP',
29
+                "mode" => 0775
30
+            ),
31
+        "dataaccess" =>
32
+            array(
33
+                "namespace" => 'App\Http\DataAccess',
34
+                "folder" => '../app/Http/DataAccess',
35
+                "mode" => 0775
36
+            ),
37
+        "business" =>
38
+            array(
39
+                "namespace" => 'App\Http\Business',
40
+                "folder" => '../app/Http/Business',
41
+                "mode" => 0775
42
+            )
43
+    );
44
+    /**
45
+     * @return array
46
+     */
47
+    public function getConfig()
48
+    {
49
+        return $this->_config;
50
+    }
51
+    /**
52
+     * @param array $config
53
+     */
54
+    public function setConfig($config)
55
+    {
56
+        $this->_config = $config;
57
+    }
58
+
13 59
     public function __construct($db_connection, $db_database, $db_host, $db_port, $db_username, $db_password)
14 60
     {
15 61
         $dsn = $db_connection . ":dbname=" . $db_database . ";host="
@@ -217,19 +263,19 @@ ORDER BY parameters.ordinal_position;");
217 263
             mkdir($dir, $dir_mode, true);
218 264
     }
219 265
 
220
-    public function run($dir_mode, $dbo_dir, $model_dir, $sp_dir, $manager_dir, $business_dir)
266
+    public function run()
221 267
     {
222
-        $dbo_dir .= "/";
223
-        $model_dir .= "/";
224
-        $sp_dir .= "/";
225
-        $manager_dir .= "/";
226
-        $business_dir .= "/";
268
+        $dbo_dir = $this->_config["dbo"]["folder"] . "/";
269
+        $model_dir = $this->_config["models"]["folder"] . "/";
270
+        $sp_dir = $this->_config["sp"]["folder"] . "/";
271
+        $manager_dir = $this->_config["dataaccess"]["folder"] . "/";
272
+        $business_dir = $this->_config["business"]["folder"] . "/";
227 273
 
228
-        $this->mkdir($dbo_dir, $dir_mode);
229
-        $this->mkdir($model_dir, $dir_mode);
230
-        $this->mkdir($sp_dir, $dir_mode);
231
-        $this->mkdir($manager_dir, $dir_mode);
232
-        $this->mkdir($business_dir, $dir_mode);
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"]);
233 279
 
234 280
         $tables = $this->getTables();
235 281
         if (!is_null($tables)) {

+ 18
- 0
test/generate.php Voir le fichier

@@ -0,0 +1,18 @@
1
+<?php
2
+/**
3
+ * Created by PhpStorm.
4
+ * User: robin
5
+ * Date: 9/26/15
6
+ * Time: 2:53 PM
7
+ */
8
+
9
+use Luticate\Generator\LuGenerator;
10
+
11
+require_once('../vendor/autoload.php');
12
+
13
+Dotenv::load("..");
14
+
15
+$gen = new LuGenerator(getenv("DB_CONNECTION"), getenv("DB_DATABASE"), getenv("DB_HOST"),
16
+    getenv("DB_PORT"), getenv("DB_USERNAME"), getenv("DB_PASSWORD"));
17
+
18
+$gen->run();

Chargement…
Annuler
Enregistrer