Refactoring of scaffold and bake.

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5918 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2007-10-29 03:14:07 +00:00
parent 6ab2b013bc
commit 3ce7ff6d8e
2 changed files with 20 additions and 5 deletions

View file

@ -233,13 +233,19 @@ class ViewTask extends Shell {
}
$controllerObj = & new $controllerClassName();
$controllerObj->constructClasses();
$modelKey = $controllerObj->modelKey;
$modelObj =& ClassRegistry::getObject($modelKey);
$modelClass = $controllerObj->modelClass;
$modelObj =& ClassRegistry::getObject($controllerObj->modelKey);
$primaryKey = $modelObj->primaryKey;
$displayField = $modelObj->displayField;
$singularVar = Inflector::variable($modelClass);
$pluralVar = Inflector::variable($this->controllerName);
$singularHumanName = Inflector::humanize($modelClass);
$pluralHumanName = Inflector::humanize($this->controllerName);
$fields = array_keys($modelObj->schema());
$associations = $this->__associations($modelObj);
return compact('fields', 'associations');
return compact('modelClass', 'primaryKey', 'displayField', 'singularVar', 'pluralVar',
'singularHumanName', 'pluralHumanName', 'fields','associations');
}
/**
* Assembles and writes bakes the view file.

View file

@ -169,10 +169,19 @@ class Scaffold extends Object {
$this->scaffoldActions = $controller->scaffold;
$this->controller->pageTitle = __('Scaffold :: ', true) . Inflector::humanize($this->action) . ' :: ' . $this->scaffoldTitle;
$modelClass = $this->controller->modelClass;
$primaryKey = $this->ScaffoldModel->primaryKey;
$displayField = $this->ScaffoldModel->displayField;
$singularVar = Inflector::variable($modelClass);
$pluralVar = Inflector::variable($this->controller->name);
$singularHumanName = Inflector::humanize($modelClass);
$pluralHumanName = Inflector::humanize($this->controller->name);
$fields = array_keys($this->ScaffoldModel->schema());
$associations = $this->__associations();
$this->controller->set(compact('fields', 'associations'));
$this->controller->set(compact('modelClass', 'primaryKey', 'displayField', 'singularVar', 'pluralVar',
'singularHumanName', 'pluralHumanName', 'fields', 'associations'));
$this->__scaffold($params);
}
/**