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