Skip to content

Commit 748ec4e

Browse files
committed
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
1 parent ec5d972 commit 748ec4e

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

cake/console/libs/tasks/view.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,10 @@ function __loadController() {
289289
}
290290
$controllerClassName = $this->controllerName . 'Controller';
291291
$controllerObj =& new $controllerClassName();
292+
$controllerObj->plugin = $this->plugin;
292293
$controllerObj->constructClasses();
293294
$modelClass = $controllerObj->modelClass;
294-
$modelObj =& ClassRegistry::getObject($controllerObj->modelKey);
295+
$modelObj =& $controllerObj->{$controllerObj->modelClass};
295296

296297
if ($modelObj) {
297298
$primaryKey = $modelObj->primaryKey;
@@ -302,13 +303,10 @@ function __loadController() {
302303
$fields = array_keys($schema);
303304
$associations = $this->__associations($modelObj);
304305
} else {
305-
$primaryKey = null;
306-
$displayField = null;
306+
$primaryKey = $displayField = null;
307307
$singularVar = Inflector::variable(Inflector::singularize($this->controllerName));
308308
$singularHumanName = $this->_singularHumanName($this->controllerName);
309-
$fields = array();
310-
$schema = array();
311-
$associations = array();
309+
$fields = $schema = $associations = array();
312310
}
313311
$pluralVar = Inflector::variable($this->controllerName);
314312
$pluralHumanName = $this->_pluralHumanName($this->controllerName);

0 commit comments

Comments
 (0)