Skip to content

Commit

Permalink
Applying patch from 'majna'. Adding plugin to the list of template va…
Browse files Browse the repository at this point in the history
…riables exposed in the controller task. Test added Fixes #1077
  • Loading branch information
markstory committed Sep 3, 2010
1 parent dbdd17f commit 5c0fe1b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cake/console/libs/tasks/controller.php
Expand Up @@ -275,8 +275,9 @@ function _askAboutMethods() {
*/
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));
Expand All @@ -290,7 +291,7 @@ function bakeActions($controllerName, $admin = null, $wannaUseSession = true) {
$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;
Expand Down
2 changes: 2 additions & 0 deletions cake/tests/cases/console/libs/tasks/controller.test.php
Expand Up @@ -299,6 +299,8 @@ function testBakeWithPlugin() {
$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');
}

/**
Expand Down

0 comments on commit 5c0fe1b

Please sign in to comment.