Adding fix for Controller::paginate() when default model is loaded from a plugin (Ticket #3660)

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6098 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2007-11-30 22:27:43 +00:00
parent ba59fad873
commit 00dc6dedb5
2 changed files with 20 additions and 1 deletions

View file

@ -876,7 +876,12 @@ class Controller extends Object {
if (isset($this->{$this->modelClass})) { if (isset($this->{$this->modelClass})) {
$object = $this->{$this->modelClass}; $object = $this->{$this->modelClass};
} else { } else {
$object = $this->{$this->uses[0]}; if (strpos($this->uses[0], '.') !== false) {
list($plugin, $className) = explode('.', $this->uses[0]);
$object = $this->{$className};
} else {
$object = $this->{$this->uses[0]};
}
} }
} }

View file

@ -77,5 +77,19 @@ class ControllerTest extends CakeTestCase {
unset($Controller); unset($Controller);
} }
function testPaginate() {
$Controller =& new Controller();
$Controller->uses = array('ControllerPost', 'ControllerComment');
$Controller->passedArgs[] = '1';
$Controller->params['url'] = array();
$Controller->constructClasses();
$Controller->modelClass = null;
$Controller->uses[0] = 'Plugin.ControllerPost';
$results = Set::extract($Controller->paginate(), '{n}.ControllerPost.id');
$this->assertEqual($results, array(1, 2, 3));
}
} }
?> ?>