Skip to content

Commit

Permalink
Add upgrade task for renaming collection class uses.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jul 27, 2013
1 parent 4f8d1c4 commit 84c627f
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions lib/Cake/Console/Command/UpgradeShell.php
Expand Up @@ -409,6 +409,40 @@ protected function _processFixture($content) {
return $content;
}

/**
* Rename collection classes
*
* @return void
*/
public function rename_collections() {
$path = $this->_getPath();

$Folder = new Folder($path);
$this->_paths = $Folder->tree(null, false, 'dir');
$this->_findFiles('php');
foreach ($this->_files as $filePath) {
$patterns = [
[
' Rename ComponentCollection',
'#ComponentCollection#',
"ComponentRegistry",
],
[
' Rename HelperCollection',
'#HelperCollection#',
"HelperRegistry",
],
[
' Rename TaskCollection',
'#TaskCollection#',
"TaskRegistry",
],
];
$this->_updateFile($filePath, $patterns);
}
$this->out(__d('cake_console', '<success>Collection class uses rename successfully</success>'));
}

/**
* Filter paths to remove webroot, Plugin, tmp directories
*
Expand Down Expand Up @@ -595,6 +629,10 @@ public function getOptionParser() {
'help' => __d('cake_console', 'Update fixtures to use new index/constraint features. This is necessary before running tests.'),
'parser' => ['options' => compact('plugin', 'dryRun'), 'arguments' => compact('path')],
])
->addSubcommand('rename_collections', [
'help' => __d('cake_console', "Rename HelperCollection, ComponentCollection, and TaskCollection."),
'parser' => ['options' => compact('plugin', 'dryRun'), 'arguments' => compact('path')]
])
->addSubcommand('cache_config', [
'help' => __d('cake_console', "Replace Cache::config() with Configure."),
'parser' => ['options' => compact('plugin', 'dryRun'), 'arguments' => compact('path')]
Expand Down

0 comments on commit 84c627f

Please sign in to comment.