Skip to content

Commit

Permalink
Add return early statements for redirecting in controllers.
Browse files Browse the repository at this point in the history
  • Loading branch information
euromark committed Jan 4, 2014
1 parent 3cee3b0 commit 3e48d2e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lib/Cake/Console/Command/UpgradeShell.php
Expand Up @@ -500,6 +500,29 @@ public function constants() {
$this->_filesRegexpUpdate($patterns);
}

/**
* Update controllers.
*
* - Make redirect statements return early.
*
* @return void
*/
public function controllers() {
$this->_paths = App::Path('Controller');
if (!empty($this->params['plugin'])) {
$this->_paths = App::Path('Controller', $this->params['plugin']);
}
$patterns = array(
array(
'$this->redirect() to return $this->redirect()',
'/\t\$this-\>redirect\(/',
"\t" . 'return $this->redirect('
),
);

$this->_filesRegexpUpdate($patterns);
}

/**
* Update components.
*
Expand Down Expand Up @@ -840,6 +863,9 @@ public function getOptionParser() {
))->addSubcommand('constants', array(
'help' => __d('cake_console', "Replace Obsolete constants"),
'parser' => $subcommandParser
))->addSubcommand('controllers', array(
'help' => __d('cake_console', 'Update controllers.'),
'parser' => $subcommandParser
))->addSubcommand('components', array(
'help' => __d('cake_console', 'Update components to extend Component class.'),
'parser' => $subcommandParser
Expand Down

0 comments on commit 3e48d2e

Please sign in to comment.