mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
refactoring shell paths, also closes #5451, shell to return exit values
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7762 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
66cfeee8c7
commit
f861d685d5
2 changed files with 28 additions and 28 deletions
|
@ -129,8 +129,7 @@ class ShellDispatcher {
|
||||||
$this->__initConstants();
|
$this->__initConstants();
|
||||||
$this->parseParams($args);
|
$this->parseParams($args);
|
||||||
$this->__initEnvironment();
|
$this->__initEnvironment();
|
||||||
$this->dispatch();
|
exit($this->dispatch());
|
||||||
die("\n");
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Defines core configuration.
|
* Defines core configuration.
|
||||||
|
@ -191,11 +190,29 @@ class ShellDispatcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->shiftArgs();
|
$this->shiftArgs();
|
||||||
$vendorPaths = Configure::read('vendorPaths');
|
|
||||||
foreach ($vendorPaths as $path) {
|
$paths = array();
|
||||||
$this->shellPaths[] = $path . 'shells' . DS;
|
|
||||||
|
$pluginPaths = Configure::read('pluginPaths');
|
||||||
|
foreach ($pluginPaths as $pluginPath) {
|
||||||
|
$plugins = Configure::listObjects('plugin', $pluginPath);
|
||||||
|
foreach ((array)$plugins as $plugin) {
|
||||||
|
$path = $pluginPath . strtolower($plugin) . DS . 'vendors' . DS . 'shells' . DS;
|
||||||
|
if (file_exists($path)) {
|
||||||
|
$paths[] = $path;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$this->shellPaths[] = CONSOLE_LIBS;
|
|
||||||
|
$vendorPaths = array_values(Configure::read('vendorPaths'));
|
||||||
|
foreach ($vendorPaths as $vendorPath) {
|
||||||
|
$path = rtrim($vendorPath, DS) . DS . 'shells' . DS;
|
||||||
|
if (file_exists($path)) {
|
||||||
|
$paths[] = $path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->shellPaths = array_values(array_unique(array_merge($paths, Configure::read('shellPaths'))));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Initializes the environment and loads the Cake core.
|
* Initializes the environment and loads the Cake core.
|
||||||
|
@ -262,22 +279,6 @@ class ShellDispatcher {
|
||||||
$this->help();
|
$this->help();
|
||||||
} else {
|
} else {
|
||||||
$loaded = false;
|
$loaded = false;
|
||||||
$paths = array();
|
|
||||||
|
|
||||||
if ($plugin !== null) {
|
|
||||||
$pluginPaths = Configure::read('pluginPaths');
|
|
||||||
$count = count($pluginPaths);
|
|
||||||
for ($i = 0; $i < $count; $i++) {
|
|
||||||
$paths[] = $pluginPaths[$i] . $plugin . DS . 'vendors' . DS . 'shells' . DS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$vendorPaths = array_values(Configure::read('vendorPaths'));
|
|
||||||
$count = count($vendorPaths);
|
|
||||||
|
|
||||||
for ($i = 0; $i < $count; $i++) {
|
|
||||||
$paths[] = rtrim($vendorPaths[$i], DS) . DS . 'shells' . DS;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($this->shellPaths as $path) {
|
foreach ($this->shellPaths as $path) {
|
||||||
$this->shellPath = $path . $this->shell . ".php";
|
$this->shellPath = $path . $this->shell . ".php";
|
||||||
|
@ -323,8 +324,7 @@ class ShellDispatcher {
|
||||||
$this->help();
|
$this->help();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$shell->{$task}->execute();
|
return $shell->{$task}->execute();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,11 +353,11 @@ class ShellDispatcher {
|
||||||
|
|
||||||
if ($missingCommand && method_exists($shell, 'main')) {
|
if ($missingCommand && method_exists($shell, 'main')) {
|
||||||
$shell->startup();
|
$shell->startup();
|
||||||
$shell->main();
|
return $shell->main();
|
||||||
} elseif (!$privateMethod && method_exists($shell, $command)) {
|
} elseif (!$privateMethod && method_exists($shell, $command)) {
|
||||||
$this->shiftArgs();
|
$this->shiftArgs();
|
||||||
$shell->startup();
|
$shell->startup();
|
||||||
$shell->{$command}();
|
return $shell->{$command}();
|
||||||
} else {
|
} else {
|
||||||
$this->stderr("Unknown {$this->shellName} command '$command'.\nFor usage, try 'cake {$this->shell} help'.\n\n");
|
$this->stderr("Unknown {$this->shellName} command '$command'.\nFor usage, try 'cake {$this->shell} help'.\n\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -503,7 +503,7 @@ class Configure extends Object {
|
||||||
$paths['cake'][] = $cake;
|
$paths['cake'][] = $cake;
|
||||||
$paths['class'][] = $cake;
|
$paths['class'][] = $cake;
|
||||||
$paths['vendor'][] = $path . DS . 'vendors' . DS;
|
$paths['vendor'][] = $path . DS . 'vendors' . DS;
|
||||||
$paths['shell'][] = $path . DS . 'console' . DS . 'libs' . DS ;
|
$paths['shell'][] = $cake . 'console' . DS . 'libs' . DS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -586,7 +586,7 @@ class Configure extends Object {
|
||||||
'plugin' => array(APP . 'plugins' . DS),
|
'plugin' => array(APP . 'plugins' . DS),
|
||||||
'vendor' => array(APP . 'vendors' . DS, VENDORS),
|
'vendor' => array(APP . 'vendors' . DS, VENDORS),
|
||||||
'locale' => array(APP . 'locale' . DS),
|
'locale' => array(APP . 'locale' . DS),
|
||||||
'shell' => array(APP . 'vendors' . DS . 'shells' . DS)
|
'shell' => array()
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($basePaths as $type => $default) {
|
foreach ($basePaths as $type => $default) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue