Removed adding of Html and Form helper by default to baked controllers 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.

This commit is contained in:
ADmad 2009-12-08 01:41:52 +05:30
parent 779479fb8c
commit e2c4c0d4de
2 changed files with 16 additions and 6 deletions

View file

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

@ -260,7 +260,7 @@ class ControllerTaskTest extends CakeTestCase {
$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);
@ -268,6 +268,12 @@ class ControllerTaskTest extends CakeTestCase {
$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);
}
/**