mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-07 12:36:25 +00:00
Removing $uses as part of bake.
This commit is contained in:
parent
9d405faf8f
commit
0d7b86fc8b
3 changed files with 32 additions and 31 deletions
|
@ -143,7 +143,7 @@ class ControllerTask extends Shell {
|
||||||
$this->out("Baking {$controllerName}Controller");
|
$this->out("Baking {$controllerName}Controller");
|
||||||
$this->hr();
|
$this->hr();
|
||||||
|
|
||||||
$helpers = $components = $uses = array();
|
$helpers = $components = array();
|
||||||
$actions = '';
|
$actions = '';
|
||||||
$wannaUseSession = 'y';
|
$wannaUseSession = 'y';
|
||||||
$wannaBakeAdminCrud = 'n';
|
$wannaBakeAdminCrud = 'n';
|
||||||
|
@ -172,7 +172,6 @@ class ControllerTask extends Shell {
|
||||||
|
|
||||||
$helpers = $this->doHelpers();
|
$helpers = $this->doHelpers();
|
||||||
$components = $this->doComponents();
|
$components = $this->doComponents();
|
||||||
$uses = $this->doUses();
|
|
||||||
|
|
||||||
$wannaUseSession = $this->in(
|
$wannaUseSession = $this->in(
|
||||||
__("Would you like to use Session flash messages?", true), array('y','n'), 'y'
|
__("Would you like to use Session flash messages?", true), array('y','n'), 'y'
|
||||||
|
@ -195,13 +194,13 @@ class ControllerTask extends Shell {
|
||||||
$looksGood = $this->in(__('Look okay?', true), array('y','n'), 'y');
|
$looksGood = $this->in(__('Look okay?', true), array('y','n'), 'y');
|
||||||
|
|
||||||
if (strtolower($looksGood) == 'y') {
|
if (strtolower($looksGood) == 'y') {
|
||||||
$baked = $this->bake($controllerName, $actions, $helpers, $components, $uses);
|
$baked = $this->bake($controllerName, $actions, $helpers, $components);
|
||||||
if ($baked && $this->_checkUnitTest()) {
|
if ($baked && $this->_checkUnitTest()) {
|
||||||
$this->bakeTest($controllerName);
|
$this->bakeTest($controllerName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$baked = $this->bake($controllerName, $actions, $helpers, $components, $uses);
|
$baked = $this->bake($controllerName, $actions, $helpers, $components);
|
||||||
if ($baked && $this->_checkUnitTest()) {
|
if ($baked && $this->_checkUnitTest()) {
|
||||||
$this->bakeTest($controllerName);
|
$this->bakeTest($controllerName);
|
||||||
}
|
}
|
||||||
|
@ -213,7 +212,7 @@ class ControllerTask extends Shell {
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
**/
|
**/
|
||||||
function confirmController($controllerName, $useDynamicScaffold, $uses, $helpers, $components) {
|
function confirmController($controllerName, $useDynamicScaffold, $helpers, $components) {
|
||||||
$this->out('');
|
$this->out('');
|
||||||
$this->hr();
|
$this->hr();
|
||||||
$this->out('The following controller will be created:');
|
$this->out('The following controller will be created:');
|
||||||
|
@ -227,7 +226,6 @@ class ControllerTask extends Shell {
|
||||||
$properties = array(
|
$properties = array(
|
||||||
'helpers' => __("Helpers:", true),
|
'helpers' => __("Helpers:", true),
|
||||||
'components' => __('Components:', true),
|
'components' => __('Components:', true),
|
||||||
'uses' => __('Uses:', true)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($properties as $var => $title) {
|
foreach ($properties as $var => $title) {
|
||||||
|
@ -432,11 +430,11 @@ class ControllerTask extends Shell {
|
||||||
* @return string Baked controller
|
* @return string Baked controller
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function bake($controllerName, $actions = '', $helpers = null, $components = null, $uses = null) {
|
function bake($controllerName, $actions = '', $helpers = null, $components = null) {
|
||||||
$isScaffold = ($actions === 'scaffold') ? true : false;
|
$isScaffold = ($actions === 'scaffold') ? true : false;
|
||||||
|
|
||||||
$this->Template->set('plugin', $this->plugin);
|
$this->Template->set('plugin', $this->plugin);
|
||||||
$this->Template->set(compact('controllerName', 'actions', 'helpers', 'components', 'uses', 'isScaffold'));
|
$this->Template->set(compact('controllerName', 'actions', 'helpers', 'components', 'isScaffold'));
|
||||||
$contents = $this->Template->generate('objects', 'controller');
|
$contents = $this->Template->generate('objects', 'controller');
|
||||||
|
|
||||||
$filename = $this->path . $this->_controllerPath($controllerName) . '_controller.php';
|
$filename = $this->path . $this->_controllerPath($controllerName) . '_controller.php';
|
||||||
|
@ -507,18 +505,6 @@ class ControllerTask extends Shell {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Interact with the user and get a list of additional models to use
|
|
||||||
*
|
|
||||||
* @return array Models the user wants to use.
|
|
||||||
**/
|
|
||||||
function doUses() {
|
|
||||||
return $this->_doPropertyChoices(
|
|
||||||
__("Would you like this controller to use any additional models?", true),
|
|
||||||
__("Please provide a comma separated list of the model names you'd like to use.\nExample: 'Post, Comment, User'", true)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common code for property choice handling.
|
* Common code for property choice handling.
|
||||||
*
|
*
|
||||||
|
|
|
@ -29,13 +29,6 @@ class <?php echo $controllerName; ?>Controller extends <?php echo $plugin; ?>App
|
||||||
var $scaffold;
|
var $scaffold;
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?php
|
<?php
|
||||||
if (count($uses)):
|
|
||||||
echo "\tvar \$uses = array('" . $this->_modelName($controllerName) . "'";
|
|
||||||
foreach ($uses as $use):
|
|
||||||
echo ", '" . $this->_modelName($use) . "'";
|
|
||||||
endforeach;
|
|
||||||
echo ");\n";
|
|
||||||
endif;
|
|
||||||
|
|
||||||
echo "\tvar \$helpers = array('Html', 'Form'";
|
echo "\tvar \$helpers = array('Html', 'Form'";
|
||||||
if (count($helpers)):
|
if (count($helpers)):
|
||||||
|
|
|
@ -196,8 +196,7 @@ class ControllerTaskTest extends CakeTestCase {
|
||||||
$this->Task->expectAt(2, 'out', array("Controller Name:\n\t$controller"));
|
$this->Task->expectAt(2, 'out', array("Controller Name:\n\t$controller"));
|
||||||
$this->Task->expectAt(3, 'out', array("Helpers:\n\tAjax, Time"));
|
$this->Task->expectAt(3, 'out', array("Helpers:\n\tAjax, Time"));
|
||||||
$this->Task->expectAt(4, 'out', array("Components:\n\tAcl, Auth"));
|
$this->Task->expectAt(4, 'out', array("Components:\n\tAcl, Auth"));
|
||||||
$this->Task->expectAt(5, 'out', array("Uses:\n\tComment, User"));
|
$this->Task->confirmController($controller, $scaffold, $helpers, $components);
|
||||||
$this->Task->confirmController($controller, $scaffold, $uses, $helpers, $components);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -214,7 +213,6 @@ class ControllerTaskTest extends CakeTestCase {
|
||||||
$result = $this->Task->bake('Articles', '--actions--', $helpers, $components, $uses);
|
$result = $this->Task->bake('Articles', '--actions--', $helpers, $components, $uses);
|
||||||
$this->assertPattern('/class ArticlesController extends AppController/', $result);
|
$this->assertPattern('/class ArticlesController extends AppController/', $result);
|
||||||
$this->assertPattern('/\$components \= array\(\'Acl\', \'Auth\'\)/', $result);
|
$this->assertPattern('/\$components \= array\(\'Acl\', \'Auth\'\)/', $result);
|
||||||
$this->assertPattern('/\$uses \= array\(\'Article\', \'Comment\', \'User\'\)/', $result);
|
|
||||||
$this->assertPattern('/\$helpers \= array\(\'Html\', \'Form\', \'Ajax\', \'Time\'\)/', $result);
|
$this->assertPattern('/\$helpers \= array\(\'Html\', \'Form\', \'Ajax\', \'Time\'\)/', $result);
|
||||||
$this->assertPattern('/\-\-actions\-\-/', $result);
|
$this->assertPattern('/\-\-actions\-\-/', $result);
|
||||||
|
|
||||||
|
@ -223,7 +221,31 @@ class ControllerTaskTest extends CakeTestCase {
|
||||||
$this->assertPattern('/var \$scaffold/', $result);
|
$this->assertPattern('/var \$scaffold/', $result);
|
||||||
$this->assertNoPattern('/helpers/', $result);
|
$this->assertNoPattern('/helpers/', $result);
|
||||||
$this->assertNoPattern('/components/', $result);
|
$this->assertNoPattern('/components/', $result);
|
||||||
$this->assertNoPattern('/uses/', $result);
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test that execute runs all when the first arg == all
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
function testExecuteIntoAll() {
|
||||||
|
$this->Task->connection = 'test_suite';
|
||||||
|
$this->Task->path = '/my/path/';
|
||||||
|
$this->Task->args = array('all');
|
||||||
|
|
||||||
|
$filename = '/my/path/articles_controller.php';
|
||||||
|
$this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class ArticlesController/')));
|
||||||
|
|
||||||
|
$filename = '/my/path/articles_tags_contoller.php';
|
||||||
|
$this->Task->expectAt(1, 'createFile', array($filename, new PatternExpectation('/class ArticlesTagsController/')));
|
||||||
|
|
||||||
|
$filename = '/my/path/comments_controller.php';
|
||||||
|
$this->Task->expectAt(2, 'createFile', array($filename, new PatternExpectation('/class CommentsController/')));
|
||||||
|
|
||||||
|
$filename = '/my/path/tags_controller.php';
|
||||||
|
$this->Task->expectAt(4, 'createFile', array($filename, new PatternExpectation('/class TagsController/')));
|
||||||
|
|
||||||
|
$this->Task->execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
Loading…
Add table
Reference in a new issue