mirror of
https://github.com/brmlab/brmsklad.git
synced 2025-08-06 16:13:38 +02:00
Upgrade CakePHP from 2.2.5 to 2.9.5
This commit is contained in:
parent
5a580df460
commit
235a541597
793 changed files with 60746 additions and 23753 deletions
|
@ -2,23 +2,23 @@
|
|||
/**
|
||||
* Upgrade Shell
|
||||
*
|
||||
* PHP 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package Cake.Console.Command
|
||||
* @since CakePHP(tm) v 2.0
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
App::uses('AppShell', 'Console/Command');
|
||||
App::uses('Folder', 'Utility');
|
||||
App::uses('CakePlugin', 'Core');
|
||||
|
||||
/**
|
||||
* A shell class to help developers upgrade applications to CakePHP 2.0
|
||||
|
@ -103,7 +103,7 @@ class UpgradeShell extends AppShell {
|
|||
public function tests() {
|
||||
$this->_paths = array(APP . 'tests' . DS);
|
||||
if (!empty($this->params['plugin'])) {
|
||||
$this->_paths = array(App::pluginPath($this->params['plugin']) . 'tests' . DS);
|
||||
$this->_paths = array(CakePlugin::path($this->params['plugin']) . 'tests' . DS);
|
||||
}
|
||||
$patterns = array(
|
||||
array(
|
||||
|
@ -129,7 +129,7 @@ class UpgradeShell extends AppShell {
|
|||
$cwd = getcwd();
|
||||
|
||||
if (!empty($this->params['plugin'])) {
|
||||
chdir(App::pluginPath($this->params['plugin']));
|
||||
chdir(CakePlugin::path($this->params['plugin']));
|
||||
}
|
||||
|
||||
if (is_dir('plugins')) {
|
||||
|
@ -200,7 +200,7 @@ class UpgradeShell extends AppShell {
|
|||
$dir = $options;
|
||||
$options = array();
|
||||
}
|
||||
$options = array_merge($defaultOptions, $options);
|
||||
$options += $defaultOptions;
|
||||
$this->_movePhpFiles($dir, $options);
|
||||
}
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ class UpgradeShell extends AppShell {
|
|||
$this->_paths = array_diff(App::path('views'), App::core('views'));
|
||||
|
||||
if (!empty($this->params['plugin'])) {
|
||||
$this->_paths = array(App::pluginPath($this->params['plugin']) . 'views' . DS);
|
||||
$this->_paths = array(CakePlugin::path($this->params['plugin']) . 'views' . DS);
|
||||
}
|
||||
|
||||
$patterns = array();
|
||||
|
@ -230,7 +230,7 @@ class UpgradeShell extends AppShell {
|
|||
CakePlugin::load($plugin);
|
||||
$pluginHelpers = array_merge(
|
||||
$pluginHelpers,
|
||||
App::objects('helper', App::pluginPath($plugin) . DS . 'views' . DS . 'helpers' . DS, false)
|
||||
App::objects('helper', CakePlugin::path($plugin) . DS . 'views' . DS . 'helpers' . DS, false)
|
||||
);
|
||||
}
|
||||
$helpers = array_merge($pluginHelpers, $helpers);
|
||||
|
@ -261,7 +261,7 @@ class UpgradeShell extends AppShell {
|
|||
APP
|
||||
);
|
||||
if (!empty($this->params['plugin'])) {
|
||||
$this->_paths = array(App::pluginPath($this->params['plugin']));
|
||||
$this->_paths = array(CakePlugin::path($this->params['plugin']));
|
||||
}
|
||||
|
||||
$patterns = array(
|
||||
|
@ -300,7 +300,7 @@ class UpgradeShell extends AppShell {
|
|||
APP
|
||||
);
|
||||
if (!empty($this->params['plugin'])) {
|
||||
$this->_paths = array(App::pluginPath($this->params['plugin']));
|
||||
$this->_paths = array(CakePlugin::path($this->params['plugin']));
|
||||
}
|
||||
$patterns = array(
|
||||
array(
|
||||
|
@ -355,7 +355,7 @@ class UpgradeShell extends AppShell {
|
|||
$this->_paths = array_merge($views, $controllers, $components);
|
||||
|
||||
if (!empty($this->params['plugin'])) {
|
||||
$pluginPath = App::pluginPath($this->params['plugin']);
|
||||
$pluginPath = CakePlugin::path($this->params['plugin']);
|
||||
$this->_paths = array(
|
||||
$pluginPath . 'controllers' . DS,
|
||||
$pluginPath . 'controllers' . DS . 'components' . DS,
|
||||
|
@ -393,6 +393,11 @@ class UpgradeShell extends AppShell {
|
|||
'/(\$this->action\b(?!\())/',
|
||||
'$this->request->action'
|
||||
),
|
||||
array(
|
||||
'$this->request->onlyAllow() -> $this->request->allowMethod()',
|
||||
'/\$this->request->onlyAllow\(/',
|
||||
'$this->request->allowMethod('
|
||||
)
|
||||
);
|
||||
$this->_filesRegexpUpdate($patterns);
|
||||
}
|
||||
|
@ -407,7 +412,7 @@ class UpgradeShell extends AppShell {
|
|||
APP
|
||||
);
|
||||
if (!empty($this->params['plugin'])) {
|
||||
$this->_paths = array(App::pluginPath($this->params['plugin']));
|
||||
$this->_paths = array(CakePlugin::path($this->params['plugin']));
|
||||
}
|
||||
$patterns = array(
|
||||
array(
|
||||
|
@ -429,7 +434,7 @@ class UpgradeShell extends AppShell {
|
|||
APP
|
||||
);
|
||||
if (!empty($this->params['plugin'])) {
|
||||
$this->_paths = array(App::pluginPath($this->params['plugin']));
|
||||
$this->_paths = array(CakePlugin::path($this->params['plugin']));
|
||||
}
|
||||
$patterns = array(
|
||||
array(
|
||||
|
@ -501,10 +506,33 @@ class UpgradeShell extends AppShell {
|
|||
$this->_filesRegexpUpdate($patterns);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update controller redirects.
|
||||
*
|
||||
* - Make redirect statements return early.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function controller_redirects() {
|
||||
$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.
|
||||
*
|
||||
* - Make components that extend Object to extend Component.
|
||||
* - Make components that extend CakeObject to extend Component.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
@ -519,6 +547,11 @@ class UpgradeShell extends AppShell {
|
|||
'/([a-zA-Z]*Component extends) Object/',
|
||||
'\1 Component'
|
||||
),
|
||||
array(
|
||||
'*Component extends CakeObject to *Component extends Component',
|
||||
'/([a-zA-Z]*Component extends) CakeObject/',
|
||||
'\1 Component'
|
||||
),
|
||||
);
|
||||
|
||||
$this->_filesRegexpUpdate($patterns);
|
||||
|
@ -527,6 +560,7 @@ class UpgradeShell extends AppShell {
|
|||
/**
|
||||
* Replace cakeError with built-in exceptions.
|
||||
* NOTE: this ignores calls where you've passed your own secondary parameters to cakeError().
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function exceptions() {
|
||||
|
@ -536,7 +570,7 @@ class UpgradeShell extends AppShell {
|
|||
$this->_paths = array_merge($controllers, $components);
|
||||
|
||||
if (!empty($this->params['plugin'])) {
|
||||
$pluginPath = App::pluginPath($this->params['plugin']);
|
||||
$pluginPath = CakePlugin::path($this->params['plugin']);
|
||||
$this->_paths = array(
|
||||
$pluginPath . 'controllers' . DS,
|
||||
$pluginPath . 'controllers' . DS . 'components' . DS,
|
||||
|
@ -582,7 +616,7 @@ class UpgradeShell extends AppShell {
|
|||
|
||||
$new = 'View' . DS . Inflector::camelize($old);
|
||||
$old = 'View' . DS . $old;
|
||||
if ($new == $old) {
|
||||
if ($new === $old) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -631,10 +665,10 @@ class UpgradeShell extends AppShell {
|
|||
/**
|
||||
* Move application php files to where they now should be
|
||||
*
|
||||
* Find all php files in the folder (honoring recursive) and determine where cake expects the file to be
|
||||
* If the file is not exactly where cake expects it - move it.
|
||||
* Find all php files in the folder (honoring recursive) and determine where CakePHP expects the file to be
|
||||
* If the file is not exactly where CakePHP expects it - move it.
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $path The path to move files in.
|
||||
* @param array $options array(recursive, checkFolder)
|
||||
* @return void
|
||||
*/
|
||||
|
@ -736,7 +770,7 @@ class UpgradeShell extends AppShell {
|
|||
/**
|
||||
* Searches the paths and finds files based on extension.
|
||||
*
|
||||
* @param string $extensions
|
||||
* @param string $extensions The extensions to include. Defaults to none.
|
||||
* @return void
|
||||
*/
|
||||
protected function _findFiles($extensions = '') {
|
||||
|
@ -780,11 +814,13 @@ class UpgradeShell extends AppShell {
|
|||
}
|
||||
|
||||
/**
|
||||
* get the option parser
|
||||
* Gets the option parser instance and configures it.
|
||||
*
|
||||
* @return ConsoleOptionParser
|
||||
*/
|
||||
public function getOptionParser() {
|
||||
$parser = parent::getOptionParser();
|
||||
|
||||
$subcommandParser = array(
|
||||
'options' => array(
|
||||
'plugin' => array(
|
||||
|
@ -809,53 +845,49 @@ class UpgradeShell extends AppShell {
|
|||
)
|
||||
);
|
||||
|
||||
return parent::getOptionParser()
|
||||
->description(__d('cake_console', "A shell to help automate upgrading from CakePHP 1.3 to 2.0. \n" .
|
||||
"Be sure to have a backup of your application before running these commands."))
|
||||
->addSubcommand('all', array(
|
||||
'help' => __d('cake_console', 'Run all upgrade commands.'),
|
||||
'parser' => $subcommandParser
|
||||
))
|
||||
->addSubcommand('tests', array(
|
||||
'help' => __d('cake_console', 'Update tests class names to FooTest rather than FooTestCase.'),
|
||||
'parser' => $subcommandParser
|
||||
))
|
||||
->addSubcommand('locations', array(
|
||||
'help' => __d('cake_console', 'Move files and folders to their new homes.'),
|
||||
'parser' => $subcommandParser
|
||||
))
|
||||
->addSubcommand('i18n', array(
|
||||
'help' => __d('cake_console', 'Update the i18n translation method calls.'),
|
||||
'parser' => $subcommandParser
|
||||
))
|
||||
->addSubcommand('helpers', array(
|
||||
'help' => __d('cake_console', 'Update calls to helpers.'),
|
||||
'parser' => $subcommandParser
|
||||
))
|
||||
->addSubcommand('basics', array(
|
||||
'help' => __d('cake_console', 'Update removed basics functions to PHP native functions.'),
|
||||
'parser' => $subcommandParser
|
||||
))
|
||||
->addSubcommand('request', array(
|
||||
'help' => __d('cake_console', 'Update removed request access, and replace with $this->request.'),
|
||||
'parser' => $subcommandParser
|
||||
))
|
||||
->addSubcommand('configure', array(
|
||||
'help' => __d('cake_console', "Update Configure::read() to Configure::read('debug')"),
|
||||
'parser' => $subcommandParser
|
||||
))
|
||||
->addSubcommand('constants', array(
|
||||
'help' => __d('cake_console', "Replace Obsolete constants"),
|
||||
'parser' => $subcommandParser
|
||||
))
|
||||
->addSubcommand('components', array(
|
||||
'help' => __d('cake_console', 'Update components to extend Component class.'),
|
||||
'parser' => $subcommandParser
|
||||
))
|
||||
->addSubcommand('exceptions', array(
|
||||
'help' => __d('cake_console', 'Replace use of cakeError with exceptions.'),
|
||||
'parser' => $subcommandParser
|
||||
));
|
||||
$parser->description(
|
||||
__d('cake_console', "A tool to help automate upgrading an application or plugin " .
|
||||
"from CakePHP 1.3 to 2.0. Be sure to have a backup of your application before " .
|
||||
"running these commands."
|
||||
))->addSubcommand('all', array(
|
||||
'help' => __d('cake_console', 'Run all upgrade commands.'),
|
||||
'parser' => $subcommandParser
|
||||
))->addSubcommand('tests', array(
|
||||
'help' => __d('cake_console', 'Update tests class names to FooTest rather than FooTestCase.'),
|
||||
'parser' => $subcommandParser
|
||||
))->addSubcommand('locations', array(
|
||||
'help' => __d('cake_console', 'Move files and folders to their new homes.'),
|
||||
'parser' => $subcommandParser
|
||||
))->addSubcommand('i18n', array(
|
||||
'help' => __d('cake_console', 'Update the i18n translation method calls.'),
|
||||
'parser' => $subcommandParser
|
||||
))->addSubcommand('helpers', array(
|
||||
'help' => __d('cake_console', 'Update calls to helpers.'),
|
||||
'parser' => $subcommandParser
|
||||
))->addSubcommand('basics', array(
|
||||
'help' => __d('cake_console', 'Update removed basics functions to PHP native functions.'),
|
||||
'parser' => $subcommandParser
|
||||
))->addSubcommand('request', array(
|
||||
'help' => __d('cake_console', 'Update removed request access, and replace with $this->request.'),
|
||||
'parser' => $subcommandParser
|
||||
))->addSubcommand('configure', array(
|
||||
'help' => __d('cake_console', "Update Configure::read() to Configure::read('debug')"),
|
||||
'parser' => $subcommandParser
|
||||
))->addSubcommand('constants', array(
|
||||
'help' => __d('cake_console', "Replace Obsolete constants"),
|
||||
'parser' => $subcommandParser
|
||||
))->addSubcommand('controller_redirects', array(
|
||||
'help' => __d('cake_console', 'Return early on controller redirect calls.'),
|
||||
'parser' => $subcommandParser
|
||||
))->addSubcommand('components', array(
|
||||
'help' => __d('cake_console', 'Update components to extend Component class.'),
|
||||
'parser' => $subcommandParser
|
||||
))->addSubcommand('exceptions', array(
|
||||
'help' => __d('cake_console', 'Replace use of cakeError with exceptions.'),
|
||||
'parser' => $subcommandParser
|
||||
));
|
||||
|
||||
return $parser;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue