Skip to content

Commit

Permalink
console cake cleanup and unification
Browse files Browse the repository at this point in the history
remove duplicate define
  • Loading branch information
euromark committed Jun 17, 2014
1 parent 96df2c4 commit a9de83d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
12 changes: 8 additions & 4 deletions app/Console/cake.php
Expand Up @@ -17,20 +17,24 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/

$ds = DIRECTORY_SEPARATOR;
$dispatcher = 'Cake' . $ds . 'Console' . $ds . 'ShellDispatcher.php';
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}

$dispatcher = 'Cake' . DS . 'Console' . DS . 'ShellDispatcher.php';

if (function_exists('ini_set')) {
$root = dirname(dirname(dirname(__FILE__)));

// the following line differs from its sibling
// /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) {
trigger_error('Could not locate CakePHP core files.', E_USER_ERROR);
}
unset($paths, $path, $dispatcher, $root, $ds);
unset($dispatcher);

return ShellDispatcher::run($argv);
1 change: 0 additions & 1 deletion lib/Cake/Console/ShellDispatcher.php
Expand Up @@ -79,7 +79,6 @@ protected function _initConstants() {
}

if (!defined('CAKE_CORE_INCLUDE_PATH')) {
define('DS', DIRECTORY_SEPARATOR);
define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(dirname(__FILE__))));
define('CAKEPHP_SHELL', true);
if (!defined('CORE_PATH')) {
Expand Down
19 changes: 12 additions & 7 deletions lib/Cake/Console/cake.php
Expand Up @@ -17,21 +17,24 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/

$ds = DIRECTORY_SEPARATOR;
$dispatcher = 'Cake' . $ds . 'Console' . $ds . 'ShellDispatcher.php';
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}

$dispatcher = 'Cake' . DS . 'Console' . DS . 'ShellDispatcher.php';
$found = false;
$paths = explode(PATH_SEPARATOR, ini_get('include_path'));

foreach ($paths as $path) {
if (file_exists($path . $ds . $dispatcher)) {
if (file_exists($path . DS . $dispatcher)) {
$found = $path;
break;
}
}

if (!$found) {
$rootInstall = dirname(dirname(dirname(__FILE__))) . $ds . $dispatcher;
$composerInstall = dirname(dirname(__FILE__)) . $ds . $dispatcher;
$rootInstall = dirname(dirname(dirname(__FILE__))) . DS . $dispatcher;
$composerInstall = dirname(dirname(__FILE__)) . DS . $dispatcher;

if (file_exists($composerInstall)) {
include $composerInstall;
Expand All @@ -40,10 +43,12 @@
} else {
trigger_error('Could not locate CakePHP core files.', E_USER_ERROR);
}
unset($rootInstall, $composerInstall);

} 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);

0 comments on commit a9de83d

Please sign in to comment.