This is using the Oracle RightNow platform for the Customer Portal so I do not have full access to all the code.
On the hooks.php, it was previously calling this:
$rnHooks['post_incident_create'][] = array(
'class' => 'incident_create_model',
'function' => 'send_email',
'filepath' => ''
);
Which calls the function send_email() in incident_create_model.php
function send_email($data)
{
//uses the variable $data to send an e-mail
}
Now I want to split up that function so i create another function in incident_create_model.php so first I modify the hooks.php to call the new function.
$rnHooks['post_incident_create'][] = array(
'class' => 'incident_create_model',
'function' => 'example',
'filepath' => ''
);
I define the newly defined function example() and call send_email() from it
function example($data)
{
send_email($data);
}
This fails and results in an error. Is there any reason why I would not be able to pass the variable $data? I can access the variable fine when I try to in the function example(). I'm thinking that it has something to do with the hidden code that I do not have access that is calling example($data) but I can not think of anything that would prevent a variable from being passed.
When programming in an object-oriented paradigm, you have to keep the method scope in mind. Calling send_email()
without $this
implies that the send_email method is in the global scope. But, that method is actually defined in your incident_create_model object. So, by changing the call to $this->send_email($data);
, PHP knows that the send_email()
method that you are trying to call is defined in that class rather than as a procedural method somewhere.
You're RightNow hook will always instantiate the incident_create_model. Keep in mind though that calling send_email()
statically, self::send_email()
implies that the model is not instantiated or does not need access to class methods and properties that are not static, so you would need to take that into account when programming what the send_email()
method will do.