upgrade shell - refactoring

This commit is contained in:
evilbloodydemon 2010-12-11 18:13:59 +03:00
parent 65269bba19
commit d414755036

View file

@ -18,13 +18,9 @@ class UpgradeShell extends Shell {
* @return void
*/
function helpers() {
if (!empty($this->params['plugin'])) {
$this->_paths = array(App::pluginPath($this->params['plugin']));
} else {
$this->_paths = array(
VIEWS
);
}
$patterns = array();
foreach(App::objects('helper') as $helper) {
@ -36,11 +32,7 @@ class UpgradeShell extends Shell {
);
}
$this->_findFiles();
foreach ($this->_files as $file) {
$this->out('Updating ' . $file . '...', 1, Shell::VERBOSE);
$this->_updateFile($file, $patterns);
}
$this->_filesRegexpUpdate($patterns);
}
/**
@ -51,15 +43,11 @@ class UpgradeShell extends Shell {
* @return void
*/
function i18n() {
if (!empty($this->params['plugin'])) {
$this->_paths = array(App::pluginPath($this->params['plugin']));
} else {
$this->_paths = array(
CONTROLLERS,
MODELS,
VIEWS
);
}
$patterns = array(
array(
@ -75,6 +63,14 @@ class UpgradeShell extends Shell {
array('__*(*, true) to __*(*)', '/(__[a-z]*\(.*?)(,\s*true)(\))/', '\1\3')
);
$this->_filesRegexpUpdate($patterns);
}
protected function _filesRegexpUpdate($patterns) {
if (!empty($this->params['plugin'])) {
$this->_paths = array(App::pluginPath($this->params['plugin']));
}
$this->_findFiles();
foreach ($this->_files as $file) {
$this->out('Updating ' . $file . '...', 1, Shell::VERBOSE);