Skip to content

Commit

Permalink
Merge pull request #8759 from xhs345/patch-2
Browse files Browse the repository at this point in the history
2.x cake bake Controller: Only add Flash component when required
  • Loading branch information
markstory committed May 4, 2016
2 parents de87ac1 + 4d65091 commit 5b83f70
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions lib/Cake/Console/Command/Task/ControllerTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ protected function _interactive() {
$components = $this->doComponents();

$wannaUseSession = $this->in(
__d('cake_console', "Would you like to use Session flash messages?"), array('y', 'n'), 'y'
__d('cake_console', "Would you like to use the FlashComponent to display flash messages?"), array('y', 'n'), 'y'
);

if (strtolower($wannaUseSession) === 'y') {
array_push($components, 'Session');
array_push($components, 'Session', 'Flash');
}
array_unique($components);
}
Expand Down Expand Up @@ -384,9 +384,9 @@ public function doHelpers() {
* @return array Components the user wants to use.
*/
public function doComponents() {
$components = array('Paginator', 'Flash');
$components = array('Paginator');
return array_merge($components, $this->_doPropertyChoices(
__d('cake_console', "Would you like this controller to use other components\nbesides PaginatorComponent and FlashComponent?"),
__d('cake_console', "Would you like this controller to use other components\nbesides PaginatorComponent?"),
__d('cake_console', "Please provide a comma separated list of the component names you'd like to use.\nExample: 'Acl, Security, RequestHandler'")
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public function testDoHelpersTrailingCommas() {
public function testDoComponentsNo() {
$this->Task->expects($this->any())->method('in')->will($this->returnValue('n'));
$result = $this->Task->doComponents();
$this->assertSame(array('Paginator', 'Flash'), $result);
$this->assertSame(array('Paginator'), $result);
}

/**
Expand All @@ -235,7 +235,7 @@ public function testDoComponentsTrailingSpaces() {
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue(' RequestHandler, Security '));

$result = $this->Task->doComponents();
$expected = array('Paginator', 'Flash', 'RequestHandler', 'Security');
$expected = array('Paginator', 'RequestHandler', 'Security');
$this->assertEquals($expected, $result);
}

Expand All @@ -249,7 +249,7 @@ public function testDoComponentsTrailingCommas() {
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue(' RequestHandler, Security, , '));

$result = $this->Task->doComponents();
$expected = array('Paginator', 'Flash', 'RequestHandler', 'Security');
$expected = array('Paginator', 'RequestHandler', 'Security');
$this->assertEquals($expected, $result);
}

Expand Down

0 comments on commit 5b83f70

Please sign in to comment.