-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathzf2.php
50 lines (36 loc) · 1.11 KB
/
zf2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
$command = $argv[1];
function copyTemplate($directory, $module){
$moduleLower = strtolower($module);
$currentDirectory = dir($directory);
while ($entry = $currentDirectory->read()) {
if ($entry != "." && $entry != "..") {
$newEntry = str_replace("template", $moduleLower, $directory . '/' . $entry);
$newEntry = str_replace("Template", $module, $newEntry);
if (is_dir($directory."/".$entry)) {
system("mkdir {$newEntry} -p");
copyTemplate($directory."/".$entry, $module);
}
else {
$template = file_get_contents($directory . "/" . $entry);
$template = str_replace('{$module}', $module, $template);
$template = str_replace('{$moduleLower}', $moduleLower, $template);
file_put_contents($newEntry, $template);
}
}
}
$currentDirectory->close();
}
switch ($command) {
case "create":
$type = $argv[2];
switch ($type) {
case "module":
$module = $argv[3];
copyTemplate(__DIR__ . '/module/Template', $module);
if ( isset($argv[4]) && $argv[4] == 'with_tests' ) {
copyTemplate(__DIR__ . '/tests/module/Template', $module);
}
}
break;
}