mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6574 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
29fa485140
commit
6a1cdf2138
6 changed files with 42 additions and 10 deletions
|
@ -41,7 +41,7 @@ class BakeShell extends Shell {
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $tasks = array('Project', 'DbConfig', 'Model', 'Controller', 'View', 'Plugin');
|
var $tasks = array('Project', 'DbConfig', 'Model', 'Controller', 'View', 'Plugin', 'Test');
|
||||||
/**
|
/**
|
||||||
* Override loadTasks() to handle paths
|
* Override loadTasks() to handle paths
|
||||||
*
|
*
|
||||||
|
@ -105,7 +105,7 @@ class BakeShell extends Shell {
|
||||||
exit(0);
|
exit(0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->out('You have made an invalid selection. Please choose a type of class to Bake by entering D, M, V, or C.');
|
$this->out(__('You have made an invalid selection. Please choose a type of class to Bake by entering D, M, V, or C.', true));
|
||||||
}
|
}
|
||||||
$this->hr();
|
$this->hr();
|
||||||
$this->main();
|
$this->main();
|
||||||
|
@ -198,6 +198,7 @@ class BakeShell extends Shell {
|
||||||
$this->out("\n\tbake help\n\t\tshows this help message.");
|
$this->out("\n\tbake help\n\t\tshows this help message.");
|
||||||
$this->out("\n\tbake all <name>\n\t\tbakes complete MVC. optional <name> of a Model");
|
$this->out("\n\tbake all <name>\n\t\tbakes complete MVC. optional <name> of a Model");
|
||||||
$this->out("\n\tbake project <path>\n\t\tbakes a new app folder in the path supplied\n\t\tor in current directory if no path is specified");
|
$this->out("\n\tbake project <path>\n\t\tbakes a new app folder in the path supplied\n\t\tor in current directory if no path is specified");
|
||||||
|
$this->out("\n\tbake plugin <name>\n\t\tbakes a new plugin folder in the path supplied\n\t\tor in current directory if no path is specified.");
|
||||||
$this->out("\n\tbake db_config\n\t\tbakes a database.php file in config directory.");
|
$this->out("\n\tbake db_config\n\t\tbakes a database.php file in config directory.");
|
||||||
$this->out("\n\tbake model\n\t\tbakes a model. run 'bake model help' for more info");
|
$this->out("\n\tbake model\n\t\tbakes a model. run 'bake model help' for more info");
|
||||||
$this->out("\n\tbake view\n\t\tbakes views. run 'bake view help' for more info");
|
$this->out("\n\tbake view\n\t\tbakes views. run 'bake view help' for more info");
|
||||||
|
|
|
@ -508,8 +508,14 @@ class ControllerTask extends Shell {
|
||||||
} else {
|
} else {
|
||||||
$tables = $db->listSources();
|
$tables = $db->listSources();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($tables)) {
|
||||||
|
$this->err(__('Your database does not have any tables.', true));
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
$this->__tables = $tables;
|
$this->__tables = $tables;
|
||||||
$this->out('Possible Models based on your current database:');
|
$this->out('Possible Controllers based on your current database:');
|
||||||
$this->_controllerNames = array();
|
$this->_controllerNames = array();
|
||||||
$count = count($tables);
|
$count = count($tables);
|
||||||
for ($i = 0; $i < $count; $i++) {
|
for ($i = 0; $i < $count; $i++) {
|
||||||
|
|
|
@ -71,6 +71,14 @@ class DbConfigTask extends Shell {
|
||||||
|
|
||||||
while ($name == '') {
|
while ($name == '') {
|
||||||
$name = $this->in("Name:", null, 'default');
|
$name = $this->in("Name:", null, 'default');
|
||||||
|
if (preg_match('/[^a-z0-9_]/i', $name)) {
|
||||||
|
$name = '';
|
||||||
|
$this->out('The name may only contain unaccented latin characters, numbers or underscores');
|
||||||
|
}
|
||||||
|
else if (preg_match('/^[^a-z_]/i', $name)) {
|
||||||
|
$name = '';
|
||||||
|
$this->out('The name must start with an unaccented latin character or an underscore');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$driver = '';
|
$driver = '';
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,14 @@ class ModelTask extends Shell {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $path = MODELS;
|
var $path = MODELS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* tasks
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
var $tasks = array('DbConfig');
|
||||||
/**
|
/**
|
||||||
* Execution method always used for tasks
|
* Execution method always used for tasks
|
||||||
*
|
*
|
||||||
|
@ -83,7 +91,13 @@ class ModelTask extends Shell {
|
||||||
$associations = array('belongsTo'=> array(), 'hasOne'=> array(), 'hasMany' => array(), 'hasAndBelongsToMany'=> array());
|
$associations = array('belongsTo'=> array(), 'hasOne'=> array(), 'hasMany' => array(), 'hasAndBelongsToMany'=> array());
|
||||||
|
|
||||||
$useDbConfig = 'default';
|
$useDbConfig = 'default';
|
||||||
$connections = array_keys(get_class_vars('DATABASE_CONFIG'));
|
$configs = get_class_vars('DATABASE_CONFIG');
|
||||||
|
|
||||||
|
if (!is_array($configs)) {
|
||||||
|
return $this->DbConfig->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
$connections = array_keys($configs);
|
||||||
if (count($connections) > 1) {
|
if (count($connections) > 1) {
|
||||||
$useDbConfig = $this->in(__('Use Database Config', true) .':', $connections, 'default');
|
$useDbConfig = $this->in(__('Use Database Config', true) .':', $connections, 'default');
|
||||||
}
|
}
|
||||||
|
@ -196,7 +210,7 @@ class ModelTask extends Shell {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->out('Bake Aborted.');
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -733,6 +747,11 @@ class ModelTask extends Shell {
|
||||||
} else {
|
} else {
|
||||||
$tables = $db->listSources();
|
$tables = $db->listSources();
|
||||||
}
|
}
|
||||||
|
if (empty($tables)) {
|
||||||
|
$this->err(__('Your database does not have any tables.', true));
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
$this->__tables = $tables;
|
$this->__tables = $tables;
|
||||||
|
|
||||||
if ($interactive === true) {
|
if ($interactive === true) {
|
||||||
|
|
|
@ -92,13 +92,13 @@ class ProjectTask extends Shell {
|
||||||
while (!$response) {
|
while (!$response) {
|
||||||
$response = $this->in("What is the full path for this app including the app directory name?\nExample: ".$this->params['root'] . DS . "myapp\n[Q]uit", null, 'Q');
|
$response = $this->in("What is the full path for this app including the app directory name?\nExample: ".$this->params['root'] . DS . "myapp\n[Q]uit", null, 'Q');
|
||||||
if (strtoupper($response) === 'Q') {
|
if (strtoupper($response) === 'Q') {
|
||||||
$this->out('Bake Aborted');
|
$this->out(__('Bake Aborted.', true));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
$this->params['working'] = null;
|
$this->params['working'] = null;
|
||||||
$this->params['app'] = null;
|
$this->params['app'] = null;
|
||||||
$this->execute($response);
|
$this->execute($response);
|
||||||
exit();
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ class ProjectTask extends Shell {
|
||||||
while (!$project) {
|
while (!$project) {
|
||||||
$project = $this->in("What is the full path for this app including the app directory name?\nExample: ".$this->params['root'] . DS . "myapp", null, $this->params['root'] . DS . 'myapp');
|
$project = $this->in("What is the full path for this app including the app directory name?\nExample: ".$this->params['root'] . DS . "myapp", null, $this->params['root'] . DS . 'myapp');
|
||||||
$this->execute($project);
|
$this->execute($project);
|
||||||
exit();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->bake($project)) {
|
if($this->bake($project)) {
|
||||||
|
@ -137,7 +137,6 @@ class ProjectTask extends Shell {
|
||||||
$this->out(sprintf(__('chmod -R 0777 %s', true), $path . DS .'tmp'));
|
$this->out(sprintf(__('chmod -R 0777 %s', true), $path . DS .'tmp'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exit();
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Looks for a skeleton template of a Cake application,
|
* Looks for a skeleton template of a Cake application,
|
||||||
|
|
|
@ -219,7 +219,6 @@ class ViewTask extends Shell {
|
||||||
exit();
|
exit();
|
||||||
} else {
|
} else {
|
||||||
$this->out('Bake Aborted.');
|
$this->out('Bake Aborted.');
|
||||||
exit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue