Welcome Guest, Not a member yet? Register   Sign In
Passing a library class to call_user_func_array()
#1

[eluser]Gorelog[/eluser]
Hello,

I'm trying to do something like this from a library X and get a function from another library Z.

Code:
$class_name = foo;
$function_name = bar;

call_user_func_array(array($class_name, $function_name), $the_args);

I'm not sure how to pass the library ($class_name) over. Any suggestions.

Much appreciated.
#2

[eluser]Aken[/eluser]
This seems unnecessary with a CodeIgniter application. What's the result you're trying to achieve?
#3

[eluser]Gorelog[/eluser]
Aken,

I found an old library that I'm trying to use, http://code.google.com/p/ci-usertracking/.

In the config I can pass the library and function for it to get the user identity.
Code:
$config['usertracking']['user_identifier'] = array($classType, //required -- enter "model", "helper", or "library"
    $className, //required -- the model, class, or helper name (e.g. site_helper.php would be 'site')
    $functionName, //required -- the function that actually returns the value
    $arguments); //optional -- an array containing any arguments to send to the function

Here is where it errors out in the library
Code:
if ( ! $this->CI->load->$class_type($class_name))
        {
          if ((($class_type !== 'helper') && !method_exists($this->CI->$class_name, $function_name)) OR ($class_type == 'helper' && !function_exists($function_name)))
            show_error("Could not load the $function_name in $class_name.  The filter will not be applied.");
          else //Do it!
          {
            if ($class_type == 'helper')
              $curr_filter_result = call_user_func_array($function_name, $the_args);
            else
              $curr_filter_result = call_user_func_array(array($this->CI->$class_name, $function_name), $the_args);
          }
        }

CodeIgniter gets $this->CI->$class_name as View producing the following error: Message: Undefined property: Views::$Ion_auth

I think it would work if I could just pass the library. I have a workaround for this, but I thought it would be nice to get this working as intended.

Thanks
#4

[eluser]InsiteFX[/eluser]
This is used for like calling a callback in the current running class.
Code:
return call_user_func_array(array($this, $callback_function_name), $the_args);

CodeIgniter uses this for its _remap method.




Theme © iAndrew 2016 - Forum software by © MyBB