mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 00:48:25 +00:00
updating shell task handling, removing bake2
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5076 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
e8292ec7fd
commit
1875d74e4a
4 changed files with 16 additions and 115 deletions
|
@ -272,16 +272,15 @@ class ShellDispatcher {
|
|||
if(isset($this->args[0])) {
|
||||
$command = $this->args[0];
|
||||
}
|
||||
|
||||
|
||||
$task = Inflector::camelize($command);
|
||||
if(in_array($task, $shell->taskNames)) {
|
||||
$shell->initialize();
|
||||
$task = Inflector::camelize($command);
|
||||
$shell->{$task}->initialize();
|
||||
$shell->{$task}->execute();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$classMethods = get_class_methods($shell);
|
||||
|
||||
$privateMethod = $missingCommand = false;
|
||||
|
@ -296,7 +295,7 @@ class ShellDispatcher {
|
|||
if (in_array(strtolower($command), $protectedCommands)) {
|
||||
$missingCommand = true;
|
||||
}
|
||||
|
||||
|
||||
if($command == 'help') {
|
||||
if(method_exists($shell, 'help')) {
|
||||
$shell->command = $command;
|
||||
|
@ -408,12 +407,12 @@ class ShellDispatcher {
|
|||
$app = $this->params['app'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(empty($this->params['app']) && in_array($app, array('cake', 'console', 'app'))){
|
||||
$app = 'app';
|
||||
$this->params['working'] = dirname(dirname(__FILE__));
|
||||
}
|
||||
|
||||
|
||||
if($app !== basename($this->params['working']) && $this->params['working'] !== dirname(dirname(__FILE__))) {
|
||||
$this->params['root'] = $this->params['working'];
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs
|
||||
* @since CakePHP(tm) v 0.10.5.1732
|
||||
* @subpackage cake.cake.console
|
||||
* @since CakePHP(tm) v 1.2.0.5074
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
|
|
|
@ -1,104 +0,0 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* Short description for file.
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
|
||||
* Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
|
||||
* @package cake
|
||||
* @subpackage cake.cake.scripts.bake
|
||||
* @since CakePHP(tm) v 1.2
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
class Bake2Shell extends Shell {
|
||||
|
||||
var $task = null;
|
||||
|
||||
function initialize() {
|
||||
pr($this->args);
|
||||
if(isset($this->args[0])) {
|
||||
$this->task = $this->args[0];
|
||||
}
|
||||
}
|
||||
|
||||
function main() {
|
||||
if($this->task == null) {
|
||||
$this->err('No Task specified');
|
||||
exit();
|
||||
}
|
||||
|
||||
$task = $this->_loadTask($this->task);
|
||||
if ($task !== null) {
|
||||
$task->execute($this->args);
|
||||
} else {
|
||||
$this->err("Task not found: " . $this->task . "\n");
|
||||
}
|
||||
}
|
||||
|
||||
function _loadTask($taskName = null) {
|
||||
|
||||
if(!$taskName) {
|
||||
$taskName = $this->task;
|
||||
}
|
||||
|
||||
if(!$taskName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$loaded = false;
|
||||
foreach($this->Dispatch->shellPaths as $path) {
|
||||
$this->taskPath = $path . 'tasks' . DS . $taskName.'.php';
|
||||
if (file_exists($this->taskPath)) {
|
||||
$loaded = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($loaded) {
|
||||
require CONSOLE_LIBS . 'tasks' . DS . 'bake.php';
|
||||
require $this->taskPath;
|
||||
|
||||
$this->taskClass = $taskName.'Task';
|
||||
if(class_exists($this->taskClass)) {
|
||||
return new $this->taskClass($this);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function _readConfigFile($fileName) {
|
||||
$fileLineArray = file($fileName);
|
||||
foreach($fileLineArray as $fileLine) {
|
||||
$dataLine = trim($fileLine);
|
||||
$delimiter = strpos($dataLine, '=');
|
||||
if ($delimiter > 0) {
|
||||
$key = strtolower(trim(substr($dataLine, 0, $delimiter)));
|
||||
$value = trim(substr($dataLine, $delimiter + 1));
|
||||
$iniSetting[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $iniSetting;
|
||||
}
|
||||
|
||||
function help() {
|
||||
echo "Usage: php bake2.php task [param1, ...]\n";
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -123,12 +123,18 @@ class Shell extends Object {
|
|||
* Initializes the Shell
|
||||
* can be overriden in subclasses
|
||||
*
|
||||
* @return null
|
||||
* @return void
|
||||
*/
|
||||
function initialize() {
|
||||
|
||||
$this->_loadModels();
|
||||
|
||||
$this->_welcome();
|
||||
}
|
||||
/**
|
||||
* Displays a header for the shell
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function _welcome() {
|
||||
$this->hr();
|
||||
$this->out('App : '. APP_DIR);
|
||||
$this->out('Path: '. ROOT . DS . APP_DIR);
|
||||
|
|
Loading…
Add table
Reference in a new issue