How to prevent XoopsErrorHandler

First of all, read GIJOE’s entry. Some libraries XOOPS2 uses and some modules raise notices and warnings. They interfere Legacy’s working. After much soul-searching, I decided to put XoopsErrorHandler again. But, wort around is here. Legacy_Controller came to use Delegate to create the debugger instance. Therefore, module developers and users can use custom-debug mode through preload or module preload. The following code is an example. Create ‘preload/DevelopPHPDebugger.class.php’ file, and copy the following code.

if (!defined(‘XOOPS_ROOT_PATH’)) exit();

require_once XOOPS_ROOT_PATH . “/modules/legacy/class/Legacy_Debugger.class.php”;

class DevelopPHPDebugger extends XCube_ActionFilter
{
function preFilter()
{
$this->mController->mSetupDebugger->add(“DevelopPHPDebugger::myFactory”);
}

function myFactory(&$instance, $debug_mode)
{
switch($debug_mode) {
case XOOPS_DEBUG_PHP:
$instance = new My_PHPDebugger();
break;

case XOOPS_DEBUG_MYSQL:
$instance = new My_MysqlDebugger();
break;

case XOOPS_DEBUG_SMARTY:
$instance = new My_SmartyDebugger();
break;

case XOOPS_DEBUG_OFF:
default:
$instance = new Legacy_NonDebugger();
break;
}
}
}

class My_PHPDebugger extends Legacy_PHPDebugger
{
function prepare()
{
error_reporting(E_ALL);
}
}

class My_MysqlDebugger extends Legacy_MysqlDebugger
{
function prepare()
{
}
}

class My_SmartyDebugger extends Legacy_SmartyDebugger
{
function prepare()
{
}
}

Advertisements
This entry was posted in XOOPS Cube. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s