From 5c0fe1b16e1635d7a3bdf60b43c90aae20665060 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Fri, 3 Sep 2010 12:33:59 -0400 Subject: [PATCH] Applying patch from 'majna'. Adding plugin to the list of template variables exposed in the controller task. Test added Fixes #1077 --- cake/console/libs/tasks/controller.php | 7 ++++--- cake/tests/cases/console/libs/tasks/controller.test.php | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cake/console/libs/tasks/controller.php b/cake/console/libs/tasks/controller.php index 36fd91600..b7f04bb18 100644 --- a/cake/console/libs/tasks/controller.php +++ b/cake/console/libs/tasks/controller.php @@ -275,8 +275,9 @@ class ControllerTask extends BakeTask { */ function bakeActions($controllerName, $admin = null, $wannaUseSession = true) { $currentModelName = $modelImport = $this->_modelName($controllerName); - if ($this->plugin) { - $modelImport = $this->plugin . '.' . $modelImport; + $plugin = $this->plugin; + if ($plugin) { + $modelImport = $plugin . '.' . $modelImport; } if (!App::import('Model', $modelImport)) { $this->err(__('You must have a model for this class to build basic methods. Please try again.', true)); @@ -290,7 +291,7 @@ class ControllerTask extends BakeTask { $singularHumanName = $this->_singularHumanName($controllerName); $pluralHumanName = $this->_pluralName($controllerName); - $this->Template->set(compact('admin', 'controllerPath', 'pluralName', 'singularName', 'singularHumanName', + $this->Template->set(compact('plugin', 'admin', 'controllerPath', 'pluralName', 'singularName', 'singularHumanName', 'pluralHumanName', 'modelObj', 'wannaUseSession', 'currentModelName')); $actions = $this->Template->generate('actions', 'controller_actions'); return $actions; diff --git a/cake/tests/cases/console/libs/tasks/controller.test.php b/cake/tests/cases/console/libs/tasks/controller.test.php index 0fbc888ff..618b0dfd3 100644 --- a/cake/tests/cases/console/libs/tasks/controller.test.php +++ b/cake/tests/cases/console/libs/tasks/controller.test.php @@ -299,6 +299,8 @@ class ControllerTaskTest extends CakeTestCase { $this->Task->expectAt(1, 'createFile', array( $path, new PatternExpectation('/ArticlesController extends ControllerTestAppController/'))); $this->Task->bake('Articles', '--actions--', array(), array(), array()); + + $this->assertEqual($this->Task->Template->templateVars['plugin'], 'ControllerTest'); } /**