From 3a67bdc06d0979cb39f869b853700cd48b86c72f Mon Sep 17 00:00:00 2001 From: gwoo Date: Thu, 13 Mar 2008 15:32:24 +0000 Subject: [PATCH] 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 --- cake/console/libs/tasks/view.php | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/cake/console/libs/tasks/view.php b/cake/console/libs/tasks/view.php index 51a9e9a26..ce7746347 100644 --- a/cake/console/libs/tasks/view.php +++ b/cake/console/libs/tasks/view.php @@ -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; }