various fixes
This commit is contained in:
parent
c14289855a
commit
e2cb9ec455
@ -28,6 +28,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-lg-8">
|
||||||
|
<?= $this->contentTag('button', 'Create', ['class' => 'btn btn-primary']) ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<?php }) ?>
|
<?php }) ?>
|
||||||
</div>
|
</div>
|
||||||
<script>document.getElementById('file_name').focus();</script>
|
<script>document.getElementById('file_name').focus();</script>
|
@ -33,17 +33,6 @@ class ControllerGenerator extends AbstractGenerator
|
|||||||
$filePath = $baseDir . DIRECTORY_SEPARATOR . $fileName;
|
$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 = [
|
$defaultOptions = [
|
||||||
'parent' => ''
|
'parent' => ''
|
||||||
];
|
];
|
||||||
@ -72,6 +61,7 @@ class ControllerGenerator extends AbstractGenerator
|
|||||||
$parent,
|
$parent,
|
||||||
], $template);
|
], $template);
|
||||||
|
|
||||||
|
if (!is_file($filePath)) {
|
||||||
if (!file_put_contents($filePath, $contents)) {
|
if (!file_put_contents($filePath, $contents)) {
|
||||||
$msg = "Couldn't create file";
|
$msg = "Couldn't create file";
|
||||||
if ($console) {
|
if ($console) {
|
||||||
@ -82,6 +72,25 @@ class ControllerGenerator extends AbstractGenerator
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if ($console) {
|
||||||
|
$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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($console) {
|
if ($console) {
|
||||||
$console->terminate("Created file: " . $filePath);
|
$console->terminate("Created file: " . $filePath);
|
||||||
@ -96,6 +105,7 @@ class ControllerGenerator extends AbstractGenerator
|
|||||||
class %className% extends %parent%
|
class %className% extends %parent%
|
||||||
{
|
{
|
||||||
|
|
||||||
}';
|
}
|
||||||
|
';
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -34,13 +34,11 @@ class ModelGenerator extends AbstractGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (is_file($filePath)) {
|
if (is_file($filePath)) {
|
||||||
$message = sprintf("File already exists (pass 'f' to overwrite): %s", $filePath);
|
$message = sprintf("File already exists: %s", $filePath);
|
||||||
if ($console) {
|
if ($console) {
|
||||||
$console->terminate($message);
|
$console->terminate($message);
|
||||||
} else {
|
} else {
|
||||||
throw new Exception\FileExistsException(
|
return false;
|
||||||
$message
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user