console cake cleanup and unification

remove duplicate define
This commit is contained in:
euromark 2014-06-17 02:28:52 +02:00
parent 96df2c4b68
commit a9de83daeb
3 changed files with 20 additions and 12 deletions

View file

@ -17,20 +17,24 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT License * @license http://www.opensource.org/licenses/mit-license.php MIT License
*/ */
$ds = DIRECTORY_SEPARATOR; if (!defined('DS')) {
$dispatcher = 'Cake' . $ds . 'Console' . $ds . 'ShellDispatcher.php'; define('DS', DIRECTORY_SEPARATOR);
}
$dispatcher = 'Cake' . DS . 'Console' . DS . 'ShellDispatcher.php';
if (function_exists('ini_set')) { if (function_exists('ini_set')) {
$root = dirname(dirname(dirname(__FILE__))); $root = dirname(dirname(dirname(__FILE__)));
// the following line differs from its sibling // the following line differs from its sibling
// /lib/Cake/Console/Templates/skel/Console/cake.php // /lib/Cake/Console/Templates/skel/Console/cake.php
ini_set('include_path', $root . $ds . 'lib' . PATH_SEPARATOR . ini_get('include_path')); ini_set('include_path', $root . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path'));
unset($root);
} }
if (!include $dispatcher) { if (!include $dispatcher) {
trigger_error('Could not locate CakePHP core files.', E_USER_ERROR); trigger_error('Could not locate CakePHP core files.', E_USER_ERROR);
} }
unset($paths, $path, $dispatcher, $root, $ds); unset($dispatcher);
return ShellDispatcher::run($argv); return ShellDispatcher::run($argv);

View file

@ -79,7 +79,6 @@ class ShellDispatcher {
} }
if (!defined('CAKE_CORE_INCLUDE_PATH')) { if (!defined('CAKE_CORE_INCLUDE_PATH')) {
define('DS', DIRECTORY_SEPARATOR);
define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(dirname(__FILE__)))); define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(dirname(__FILE__))));
define('CAKEPHP_SHELL', true); define('CAKEPHP_SHELL', true);
if (!defined('CORE_PATH')) { if (!defined('CORE_PATH')) {

View file

@ -17,21 +17,24 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT License * @license http://www.opensource.org/licenses/mit-license.php MIT License
*/ */
$ds = DIRECTORY_SEPARATOR; if (!defined('DS')) {
$dispatcher = 'Cake' . $ds . 'Console' . $ds . 'ShellDispatcher.php'; define('DS', DIRECTORY_SEPARATOR);
}
$dispatcher = 'Cake' . DS . 'Console' . DS . 'ShellDispatcher.php';
$found = false; $found = false;
$paths = explode(PATH_SEPARATOR, ini_get('include_path')); $paths = explode(PATH_SEPARATOR, ini_get('include_path'));
foreach ($paths as $path) { foreach ($paths as $path) {
if (file_exists($path . $ds . $dispatcher)) { if (file_exists($path . DS . $dispatcher)) {
$found = $path; $found = $path;
break; break;
} }
} }
if (!$found) { if (!$found) {
$rootInstall = dirname(dirname(dirname(__FILE__))) . $ds . $dispatcher; $rootInstall = dirname(dirname(dirname(__FILE__))) . DS . $dispatcher;
$composerInstall = dirname(dirname(__FILE__)) . $ds . $dispatcher; $composerInstall = dirname(dirname(__FILE__)) . DS . $dispatcher;
if (file_exists($composerInstall)) { if (file_exists($composerInstall)) {
include $composerInstall; include $composerInstall;
@ -40,10 +43,12 @@ if (!$found) {
} else { } else {
trigger_error('Could not locate CakePHP core files.', E_USER_ERROR); trigger_error('Could not locate CakePHP core files.', E_USER_ERROR);
} }
unset($rootInstall, $composerInstall);
} else { } else {
include $found . $ds . $dispatcher; include $found . DS . $dispatcher;
} }
unset($paths, $path, $found, $dispatcher, $root, $ds); unset($paths, $path, $found, $dispatcher);
return ShellDispatcher::run($argv); return ShellDispatcher::run($argv);