Topic: migrating from registerFunction (V .2) to register (V .6)

Hi all,

I've been working on updating a large CodeIgniter application to use Xajax 0.6 as part of a larger updating process to PHP 5.3.3 and CodeIgniter 2.1.2

I'm confused about how to move from 'registerFunction' to 'register' in my application. There are several 'register' functions under different classes in xajax and I'm not sure what the correct syntax is. Any help would be greatly appreciated!

My existing code:

class Client extends CI_Controller
{

    function __construct()
    {    
        parent::__construct();
        $this->load->model('Mclient');
        $this->load->model('Mtask');
        $this->xajax->registerFunction(array('x_update_sections',&$this,'x_update_sections'));
        $this->xajax->registerFunction(array('x_update_client',&$this,'x_update_client'));
        $this->xajax->registerFunction(array('x_show_forms',&$this,'x_show_forms'));
        $this->xajax->registerFunction(array('x_show_mail_history',&$this,'x_show_mail_history'));
        $this->xajax->registerFunction(array('_x_generate_forms',&$this,'_x_generate_forms'));
        $this->xajax->registerFunction(array('_x_mail_forms',&$this, '_x_mail_forms'));
        $this->xajax->registerFunction(array('_x_fax_forms',&$this, '_x_fax_forms'));
        $this->xajax->registerFunction(array('_x_show_notes',&$this, '_x_show_notes'));
        $this->xajax->registerFunction(array('_x_show_changes',&$this, '_x_show_changes'));
        $this->xajax->registerFunction(array('_x_show_billing',&$this, '_x_show_billing'));
        $this->xajax->registerFunction(array('_x_delete_comment',&$this, '_x_delete_comment'));
        $this->xajax->registerFunction(array('_x_add_comment',&$this, '_x_add_comment'));
        $this->xajax->registerFunction(array('_x_mail_login',&$this, '_x_mail_login'));
        $this->xajax->registerFunction(array('_x_add_invoice',&$this, '_x_add_invoice'));
        $this->xajax->registerFunction(array('_x_add_payment',&$this, '_x_add_payment'));
        $this->xajax->registerFunction(array('_x_get_fee_amount',&$this, '_x_get_fee_amount'));
        $this->xajax->registerFunction(array('_x_action_items',&$this, '_x_action_items'));
        $this->xajax->registerFunction(array('_x_update_action_items',&$this, '_x_update_action_items'));
        $this->xajax->registerFunction(array('x_remove_billing',&$this, 'x_remove_billing'));
        $this->xajax->registerFunction(array('_x_show_request',&$this, '_x_show_request'));
        $this->xajax->registerFunction(array('_x_get_client_comment',&$this, '_x_get_client_comment'));
        $this->xajax->registerFunction(array('_x_update_client_comment',&$this, '_x_update_client_comment'));
        $this->xajax->registerFunction(array('_x_update_fields',&$this, '_x_update_fields'));
        $this->xajax->registerFunction(array('_x_show_task',&$this, '_x_show_task'));
        $this->xajax->registerFunction(array('_x_show_add_task',&$this, '_x_show_add_task'));
        $this->xajax->registerFunction(array('_x_show_edit_task',&$this, '_x_show_edit_task'));
        $this->xajax->registerFunction(array('_x_save_task',&$this, '_x_save_task'));
        $this->xajax->registerFunction(array('x_update_task',&$this, 'x_update_task'));
        $this->xajax->registerFunction(array('x_remove_task',&$this, 'x_remove_task'));
        
        $this->xajax->processRequest();
    }
}

I changed the first instance of registerFunction to:

$this->xajax->register(XAJAX_CALLABLE_OBJECT, x_update_sections);

But, I get the following errors:

A PHP Error was encountered

Severity: Notice

Message: Use of undefined constant x_update_sections - assumed 'x_update_sections'

Filename: controllers/client.php

Line Number: 15

A PHP Error was encountered

Severity: User Warning

Message: To register a callable object, please provide an instance of the desired class.

Filename: plugin_layer/xajaxCallableObjectPlugin.inc.php

Line Number: 118

A PHP Error was encountered

Severity: User Error

Message: Failed to locate registration method for the following: Array ( [0] => callable object [1] => x_update_sections )

Filename: xajax_core/xajaxPluginManager.inc.php

Line Number: 389

Obviously, I'm missing quite a bit. Again, any help would be a huge help as I'm really confused about which direction to move in.

Thanks!
Luke

Re: migrating from registerFunction (V .2) to register (V .6)

Luke,

The proper syntax for register a function in a class is:

$this->xajax->register(XAJAX_FUNCTION,array('dispatch',&$this,'dispatch'));//dispatch is the function name being registered

Hope this gets you going.:)

Ed

If you ever stop learning you may as well dig a hole, crawl in and pull the top over yourself.

Re: migrating from registerFunction (V .2) to register (V .6)

Thanks, Ed! That works perfectly. I appreciate your help a ton. Saved me a lot of time.