mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
fixing some errors in bake view task when no model schema is available
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6566 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
360b91eea7
commit
3a67bdc06d
1 changed files with 21 additions and 8 deletions
|
@ -253,14 +253,26 @@ class ViewTask extends Shell {
|
|||
$controllerObj->constructClasses();
|
||||
$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);
|
||||
|
||||
if ($modelObj) {
|
||||
$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);
|
||||
} else {
|
||||
$primaryKey = null;
|
||||
$displayField = null;
|
||||
$singularVar = Inflector::variable(Inflector::singularize($this->controllerName));
|
||||
$pluralVar = Inflector::variable($this->controllerName);
|
||||
$singularHumanName = Inflector::humanize(Inflector::singularize($this->controllerName));
|
||||
$pluralHumanName = Inflector::humanize($this->controllerName);
|
||||
$fields = array();
|
||||
$associations = array();
|
||||
}
|
||||
|
||||
return compact('modelClass', 'primaryKey', 'displayField', 'singularVar', 'pluralVar',
|
||||
'singularHumanName', 'pluralHumanName', 'fields','associations');
|
||||
|
@ -331,6 +343,7 @@ class ViewTask extends Shell {
|
|||
$content = ob_get_clean();
|
||||
return $content;
|
||||
}
|
||||
$this->hr();
|
||||
$this->err(sprintf(__('Template for %s could not be found', true), $template));
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue