Permalink
Browse files

Removed adding of Html and Form helper by default to baked controller…

…s as its not DRY and they are alrady inherited from Controller class. If var helpers is declared in AppController, Html and Form should be included there.
  • Loading branch information...
1 parent 779479f commit e2c4c0d4de3f990b505b074cc15b94489f5013a1 @ADmad ADmad committed Dec 7, 2009
View
14 cake/console/templates/default/classes/controller.ctp
@@ -29,13 +29,17 @@ class <?php echo $controllerName; ?>Controller extends <?php echo $plugin; ?>App
var $scaffold;
<?php else: ?>
<?php
-echo "\tvar \$helpers = array('Html', 'Form'";
if (count($helpers)):
- foreach ($helpers as $help):
- echo ", '" . Inflector::camelize($help) . "'";
- endforeach;
+ echo "\tvar \$helpers = array(";
+ for ($i = 0, $len = count($helpers); $i < $len; $i++):
+ if ($i != $len - 1):
+ echo "'" . Inflector::camelize($helpers[$i]) . "', ";
+ else:
+ echo "'" . Inflector::camelize($helpers[$i]) . "'";
+ endif;
+ endfor;
+ echo ");\n";
endif;
-echo ");\n";
if (count($components)):
echo "\tvar \$components = array(";
View
8 cake/tests/cases/console/libs/tasks/controller.test.php
@@ -260,14 +260,20 @@ function testBake() {
$result = $this->Task->bake('Articles', '--actions--', $helpers, $components);
$this->assertPattern('/class ArticlesController extends AppController/', $result);
$this->assertPattern('/\$components \= array\(\'Acl\', \'Auth\'\)/', $result);
- $this->assertPattern('/\$helpers \= array\(\'Html\', \'Form\', \'Ajax\', \'Time\'\)/', $result);
+ $this->assertPattern('/\$helpers \= array\(\'Ajax\', \'Time\'\)/', $result);
$this->assertPattern('/\-\-actions\-\-/', $result);
$result = $this->Task->bake('Articles', 'scaffold', $helpers, $components);
$this->assertPattern('/class ArticlesController extends AppController/', $result);
$this->assertPattern('/var \$scaffold/', $result);
$this->assertNoPattern('/helpers/', $result);
$this->assertNoPattern('/components/', $result);
+
+ $result = $this->Task->bake('Articles', '--actions--', array(), array());
+ $this->assertPattern('/class ArticlesController extends AppController/', $result);
+ $this->assertNoPattern('/components/', $result);
+ $this->assertNoPattern('/helpers/', $result);
+ $this->assertPattern('/\-\-actions\-\-/', $result);
}
/**

0 comments on commit e2c4c0d

Please sign in to comment.