Applying patch from 'majna'. Adding plugin to the list of template variables exposed in the controller task. Test added Fixes #1077

This commit is contained in:
Mark Story 2010-09-03 12:33:59 -04:00
parent dbdd17f51a
commit 5c0fe1b16e
2 changed files with 6 additions and 3 deletions

View file

@ -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;

View file

@ -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');
}
/**