Fixing baking views for models in plugins. Making sure that the temporary controller object gets its plugin property set so the correct models are loaded and used. Fixes #381

This commit is contained in:
Mark Story 2010-02-27 20:28:04 -05:00
parent ec5d9729b0
commit 748ec4ee78

View file

@ -289,9 +289,10 @@ class ViewTask extends Shell {
} }
$controllerClassName = $this->controllerName . 'Controller'; $controllerClassName = $this->controllerName . 'Controller';
$controllerObj =& new $controllerClassName(); $controllerObj =& new $controllerClassName();
$controllerObj->plugin = $this->plugin;
$controllerObj->constructClasses(); $controllerObj->constructClasses();
$modelClass = $controllerObj->modelClass; $modelClass = $controllerObj->modelClass;
$modelObj =& ClassRegistry::getObject($controllerObj->modelKey); $modelObj =& $controllerObj->{$controllerObj->modelClass};
if ($modelObj) { if ($modelObj) {
$primaryKey = $modelObj->primaryKey; $primaryKey = $modelObj->primaryKey;
@ -302,13 +303,10 @@ class ViewTask extends Shell {
$fields = array_keys($schema); $fields = array_keys($schema);
$associations = $this->__associations($modelObj); $associations = $this->__associations($modelObj);
} else { } else {
$primaryKey = null; $primaryKey = $displayField = null;
$displayField = null;
$singularVar = Inflector::variable(Inflector::singularize($this->controllerName)); $singularVar = Inflector::variable(Inflector::singularize($this->controllerName));
$singularHumanName = $this->_singularHumanName($this->controllerName); $singularHumanName = $this->_singularHumanName($this->controllerName);
$fields = array(); $fields = $schema = $associations = array();
$schema = array();
$associations = array();
} }
$pluralVar = Inflector::variable($this->controllerName); $pluralVar = Inflector::variable($this->controllerName);
$pluralHumanName = $this->_pluralHumanName($this->controllerName); $pluralHumanName = $this->_pluralHumanName($this->controllerName);