Browse Source

added ignore list

tags/0.1.0
Robin Thoni 8 years ago
parent
commit
4437df6315
2 changed files with 41 additions and 8 deletions
  1. 27
    5
      src/Generator/LuGenerator.php
  2. 14
    3
      test/generate.php

+ 27
- 5
src/Generator/LuGenerator.php View File

35
                 "namespace" => 'App\Http\Business',
35
                 "namespace" => 'App\Http\Business',
36
                 "folder" => '../app/Http/Business'
36
                 "folder" => '../app/Http/Business'
37
             ),
37
             ),
38
-        "mode" => 0775
38
+        "mode" => 0775,
39
+        "ignore" => array(
40
+            "tables" => array(),
41
+            "sp" => array()
42
+        )
39
     );
43
     );
40
     /**
44
     /**
41
      * @return array
45
      * @return array
52
         $this->_config = $config;
56
         $this->_config = $config;
53
     }
57
     }
54
 
58
 
55
-    public function __construct($db_connection, $db_database, $db_host, $db_port, $db_username, $db_password)
59
+    public function __construct()
56
     {
60
     {
57
-        $dsn = $db_connection . ":dbname=" . $db_database . ";host="
58
-            . $db_host . ";port=" . $db_port;
59
-        $this->_pdo = new PDO($dsn, $db_username, $db_password);
61
+        $dsn = getenv("DB_CONNECTION") . ":dbname=" . getenv("DB_DATABASE") . ";host="
62
+            . getenv("DB_HOST") . ";port=" . getenv("DB_PORT");
63
+        $this->_pdo = new PDO($dsn, getenv("DB_USERNAME"), getenv("DB_PASSWORD"));
60
     }
64
     }
61
 
65
 
62
     protected function printError($query, $message)
66
     protected function printError($query, $message)
269
             mkdir($dir, $dir_mode, true);
273
             mkdir($dir, $dir_mode, true);
270
     }
274
     }
271
 
275
 
276
+    public function matchIgnore($ignore, $name)
277
+    {
278
+        foreach ($this->_config["ignore"][$ignore] as $reg)
279
+        {
280
+            if (preg_match($reg, $name))
281
+                return true;
282
+        }
283
+        return false;
284
+    }
285
+
272
     public function run()
286
     public function run()
273
     {
287
     {
274
         $dbo_dir = $this->_config["dbo"]["folder"] . "/";
288
         $dbo_dir = $this->_config["dbo"]["folder"] . "/";
290
         if (!is_null($tables)) {
304
         if (!is_null($tables)) {
291
             foreach ($tables as $table) {
305
             foreach ($tables as $table) {
292
                 $table_name = $table["table_name"];
306
                 $table_name = $table["table_name"];
307
+                if ($this->matchIgnore("tables", $table_name)) {
308
+                    echo "Table $table_name ignored\n";
309
+                    continue;
310
+                }
293
                 $columns = $this->getColumns($table_name);
311
                 $columns = $this->getColumns($table_name);
294
                 if (is_null($columns))
312
                 if (is_null($columns))
295
                     continue;
313
                     continue;
315
             foreach ($sps as $sp)
333
             foreach ($sps as $sp)
316
             {
334
             {
317
                 $sp_name = $sp["sp_name"];
335
                 $sp_name = $sp["sp_name"];
336
+                if ($this->matchIgnore("sp", $sp_name)) {
337
+                    echo "Stored procedure $sp_name ignored\n";
338
+                    continue;
339
+                }
318
                 $args = $this->getStoredProceduresArguments($sp);
340
                 $args = $this->getStoredProceduresArguments($sp);
319
                 if (is_null($args))
341
                 if (is_null($args))
320
                     continue;
342
                     continue;

+ 14
- 3
test/generate.php View File

12
 
12
 
13
 Dotenv::load("..");
13
 Dotenv::load("..");
14
 
14
 
15
-$gen = new LuGenerator(getenv("DB_CONNECTION"), getenv("DB_DATABASE"), getenv("DB_HOST"),
16
-    getenv("DB_PORT"), getenv("DB_USERNAME"), getenv("DB_PASSWORD"));
15
+$gen = new LuGenerator();
16
+
17
+echo "\n\nDEFAULT\n\n";
17
 
18
 
18
 $gen->run();
19
 $gen->run();
19
 
20
 
42
             "namespace" => 'Luticate\Package\Business',
43
             "namespace" => 'Luticate\Package\Business',
43
             "folder" => 'generated/Package/Business'
44
             "folder" => 'generated/Package/Business'
44
         ),
45
         ),
45
-    "mode" => 0777
46
+    "mode" => 0777,
47
+    "ignore" => array(
48
+        "tables" => array(
49
+            "/luticate_users_groups/"
50
+        ),
51
+        "sp" => array(
52
+            "/^sp_lu_get/"
53
+        )
54
+    )
46
 ));
55
 ));
56
+
57
+echo "\n\nCONFIG\n\n";
47
 $gen->run();
58
 $gen->run();

Loading…
Cancel
Save