various fixes

This commit is contained in:
Parziphal 2013-10-02 18:25:23 -05:00
parent c14289855a
commit e2cb9ec455
3 changed files with 37 additions and 24 deletions

View File

@ -28,6 +28,11 @@
</div>
</div>
</div>
<div class="form-group">
<div class="col-lg-8">
<?= $this->contentTag('button', 'Create', ['class' => 'btn btn-primary']) ?>
</div>
</div>
<?php }) ?>
</div>
<script>document.getElementById('file_name').focus();</script>
<script>document.getElementById('file_name').focus();</script>

View File

@ -33,17 +33,6 @@ class ControllerGenerator extends AbstractGenerator
$filePath = $baseDir . DIRECTORY_SEPARATOR . $fileName;
}
if (is_file($filePath)) {
$message = sprintf("File already exists (pass 'f' to overwrite): %s", $filePath);
if ($console) {
$console->terminate($message);
} else {
throw new Exception\FileExistsException(
$message
);
}
}
$defaultOptions = [
'parent' => ''
];
@ -72,14 +61,34 @@ class ControllerGenerator extends AbstractGenerator
$parent,
], $template);
if (!file_put_contents($filePath, $contents)) {
$msg = "Couldn't create file";
if (!is_file($filePath)) {
if (!file_put_contents($filePath, $contents)) {
$msg = "Couldn't create file";
if ($console) {
$console->terminate($msg);
} else {
throw new Exception\FileNotCreatedException(
$msg
);
}
}
} else {
if ($console) {
$console->terminate($msg);
} else {
throw new Exception\FileNotCreatedException(
$msg
);
$console->write("File already exists: " . $filePath);
}
}
# Create view folder
$viewsPath = Rails::config()->paths->views;
$viewFolder = $viewsPath . '/' . Rails::services()->get('inflector')->underscore($name);
if (!is_dir($viewFolder)) {
mkdir($viewFolder);
if ($console) {
$console->write("Created directory: " . $viewFolder);
}
} else {
if ($console) {
$console->write("Directory already exists: " . $viewFolder);
}
}
@ -96,6 +105,7 @@ class ControllerGenerator extends AbstractGenerator
class %className% extends %parent%
{
}';
}
';
}
}

View File

@ -34,13 +34,11 @@ class ModelGenerator extends AbstractGenerator
}
if (is_file($filePath)) {
$message = sprintf("File already exists (pass 'f' to overwrite): %s", $filePath);
$message = sprintf("File already exists: %s", $filePath);
if ($console) {
$console->terminate($message);
} else {
throw new Exception\FileExistsException(
$message
);
return false;
}
}