mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
fixed missing dispatcher in ErrorHandler, updated AclScript, added initialize method to CakeScript which should be used by subclasses as the constructor.
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5002 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
383c8d36d3
commit
326c2a900d
3 changed files with 42 additions and 18 deletions
|
@ -55,6 +55,9 @@ class ErrorHandler extends Object{
|
|||
}
|
||||
$clean = new Sanitize();
|
||||
$messages = $clean->paranoid($messages, $allow);
|
||||
if(!class_exists('dispatcher')) {
|
||||
require CAKE . 'dispatcher.php';
|
||||
}
|
||||
$this->__dispatch =& new Dispatcher();
|
||||
|
||||
if ($__previousError != array($method, $messages)) {
|
||||
|
|
|
@ -51,10 +51,14 @@ class AclScript extends CakeScript {
|
|||
*/
|
||||
var $dataSource = 'default';
|
||||
/**
|
||||
* Enter description here...
|
||||
* override intialize of the CakeScript
|
||||
*
|
||||
*/
|
||||
function initialize () {
|
||||
}
|
||||
/**
|
||||
* Main method called from dispatch
|
||||
*
|
||||
* @param unknown_type $command
|
||||
* @param unknown_type $args
|
||||
*/
|
||||
function main () {
|
||||
$this->dataSource = 'default';
|
||||
|
@ -62,7 +66,6 @@ class AclScript extends CakeScript {
|
|||
if (isset($this->params['datasource'])) {
|
||||
$this->dataSource = $this->params['datasource'];
|
||||
}
|
||||
define('DATASOURCE', $this->dataSource);
|
||||
|
||||
if (ACL_CLASSNAME != 'DB_ACL') {
|
||||
$out = "--------------------------------------------------\n";
|
||||
|
@ -76,12 +79,12 @@ class AclScript extends CakeScript {
|
|||
$this->err($out);
|
||||
exit();
|
||||
}
|
||||
|
||||
//pr($this);
|
||||
//die();
|
||||
|
||||
$command = null;
|
||||
if(!in_array($command, array('help'))) {
|
||||
if(isset($this->args[0])) {
|
||||
$command = $this->args[0];
|
||||
}
|
||||
if($command && !in_array($command, array('help'))) {
|
||||
if(!file_exists(CONFIGS.'database.php')) {
|
||||
$this->out('');
|
||||
$this->out('Your database configuration was not found.');
|
||||
|
@ -91,12 +94,11 @@ class AclScript extends CakeScript {
|
|||
require_once (CONFIGS.'database.php');
|
||||
|
||||
if(!in_array($command, array('initdb'))) {
|
||||
$this->dataSource = DATASOURCE;
|
||||
$this->Acl = new AclComponent();
|
||||
$this->db =& ConnectionManager::getDataSource($this->dataSource);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch ($command) {
|
||||
case 'create':
|
||||
$this->create();
|
||||
|
@ -132,7 +134,7 @@ class AclScript extends CakeScript {
|
|||
$this->help();
|
||||
break;
|
||||
default:
|
||||
$this->err("Unknown ACL command '$command'.\nFor usage, try 'php acl.php help'.\n\n");
|
||||
$this->err("Unknown ACL command '$command'.\nFor usage, try 'cake acl help'.\n\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -355,7 +357,7 @@ class AclScript extends CakeScript {
|
|||
*
|
||||
*/
|
||||
function help() {
|
||||
$out = "Usage: php acl.php <command> <arg1> <arg2>...\n";
|
||||
$out = "Usage: cake acl <command> <arg1> <arg2>...\n";
|
||||
$out .= "-----------------------------------------------\n";
|
||||
$out .= "Commands:\n";
|
||||
$out .= "\n";
|
||||
|
|
|
@ -66,18 +66,32 @@ class CakeScript extends Object {
|
|||
*/
|
||||
var $args = array();
|
||||
/**
|
||||
* Initializes this ConsoleScript instance.
|
||||
* Constructs this CakeScript instance.
|
||||
*
|
||||
*/
|
||||
function __construct(&$dispatch) {
|
||||
$this->dispatch =& $dispatch;
|
||||
$this->params = $this->dispatch->params;
|
||||
$this->args = $this->dispatch->args;
|
||||
$this->initialize();
|
||||
}
|
||||
/**
|
||||
* Initializes the CakeScript
|
||||
* can be overriden in subclasses
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
function initialize() {
|
||||
if($this->_loadDbConfig()) {
|
||||
$this->_loadModel();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads database file and constructs DATABASE_CONFIG class
|
||||
* makes $this->dbConfig available to subclasses
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function _loadDbConfig() {
|
||||
if(config('database')) {
|
||||
if (class_exists('DATABASE_CONFIG')) {
|
||||
|
@ -85,10 +99,15 @@ class CakeScript extends Object {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
//$this->err('Database config could not be loaded');
|
||||
$this->err('Database config could not be loaded');
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads AppModel file and constructs AppModel class
|
||||
* makes $this->AppModel available to subclasses
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function _loadModel() {
|
||||
uses ('model'.DS.'connection_manager',
|
||||
'model'.DS.'datasources'.DS.'dbo_source', 'model'.DS.'model'
|
||||
|
@ -99,7 +118,7 @@ class CakeScript extends Object {
|
|||
return true;
|
||||
}
|
||||
|
||||
//$this->err('AppModel could not be loaded');
|
||||
$this->err('AppModel could not be loaded');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -108,7 +127,7 @@ class CakeScript extends Object {
|
|||
*
|
||||
*/
|
||||
function main() {
|
||||
|
||||
|
||||
$this->out('');
|
||||
$this->out('');
|
||||
$this->out('Baking...');
|
||||
|
|
Loading…
Reference in a new issue