Fix file always being set to 'schema.php'

When the name parameter is set and no custom file value is provided,
the name should be used to generate the file name. empty() cannot be
used because the file parameter has a default value of 'schema.php'.

Fixes #2202
This commit is contained in:
mark_story 2013-10-25 23:36:16 -04:00
parent 3dc60af166
commit 411f510406

View file

@ -67,12 +67,12 @@ class SchemaShell extends AppShell {
$name = $this->params['name'] = $splitName;
}
if ($name && empty($this->params['file'])) {
$this->params['file'] = Inflector::underscore($name);
}
$defaultFile = 'schema.php';
if (empty($this->params['file'])) {
$this->params['file'] = 'schema.php';
$this->params['file'] = $defaultFile;
}
if ($name && $this->params['file'] === $defaultFile) {
$this->params['file'] = Inflector::underscore($name);
}
if (strpos($this->params['file'], '.php') === false) {
$this->params['file'] .= '.php';