Skip to content

Commit

Permalink
templater will guess a directory name if one is not provided
Browse files Browse the repository at this point in the history
  • Loading branch information
carlreedw committed Nov 8, 2018
1 parent 82acc64 commit b557219
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Templater.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function generateTemplateFromPost($twig) {
'everyPageHooks' => $_POST['everyPageHooks'],
'namespace' => $_POST['namespace'],
'description' => $_POST['moduleDescription'],
'dirName' => $_POST['dirName'],
'authors' => [],
'controlCenterLinks' => [],
'crons' => [],
Expand All @@ -24,10 +25,11 @@ function generateTemplateFromPost($twig) {
$data['initialVersion'] = empty($_POST['moduleInitVersion']) ? '0.1' : $_POST['moduleInitVersion'];

// determine directory name via given class name
// preg_match_all('/[A-Z][a-z]+/', $data['className'], $matches);
// $dirName = ($_POST['dirName']=="") ? join('_', array_map('strtolower', $matches[0])) . '_v' . $data['initialVersion'] : $_POST['dirName'];

$dirName = ($_POST['dirName']=="") ? 'module_template_v' . $data['initialVersion'] : $_POST['dirName'];
if (empty($_POST['dirName'])) {
preg_match_all('/([A-Z]*[a-z]*)/', $data['className'], $matches);
array_pop($matches[0]);
$data['dirName'] = join('_', array_map('strtolower', $matches[0])) . '_v' . $data['initialVersion'];
}

# authors
$done = false;
Expand Down Expand Up @@ -123,7 +125,7 @@ function generateTemplateFromPost($twig) {
}

$zip->close();
$zipFileName = $dirName . '.zip';
$zipFileName = $data['dirName'] . '.zip';
header("Content-disposition: attachment; filename=$zipFileName");
header('Content-type: application/zip');
readfile($file);
Expand Down

0 comments on commit b557219

Please sign in to comment.