Hello all.

I have the following code which is used to execute a static method of a registered class. I am passing an array to the following method, which calls the method following it. The problem is that even though call_user_func_array is being called and has an array being passed to it, the method it calls is seeing the value passed as a string. Hope that makes sense.

static public function runPlugin($plugin, $point, $args = NULL){
      if(method_exists($plugin, $point))
        if(!is_array($args))
          call_user_func(array($plugin, $point), $args);
        else
          call_user_func_array(array($plugin, $point), $args);
    }

The above calls:

static public function documentsModifier($documentData){
      print_r($documentData);
    }

The problem, as stated above, is documentsModifier sees $documentData as a string, when runPlugin supplies an array.

Any ideas as to how I can resolve this?

TIA!

edit

The supplied array is:

Array
(
    [documentId] => aebc4f87-ab99-4f3a-ac9f-e9ba2d57bc31
    [userId] => 87654321-4321-4321-4321-210987654321
    [documentName] => Privacy Policy
    [documentContent] => <p>	You could put your privacy policy here</p>

)

    It's an operator error ... the usual kind of error. 😉

    call_user_func_array is for a variable length parameter list, not for passing the called function an array.

    I'm still a nub.

    static public function runPlugin($plugin, $point, $args = NULL, $variableArguementList = FALSE){
          if(method_exists($plugin, $point))
            if(!$variableArguementList)
              call_user_func(array($plugin, $point), $args);
            else
              call_user_func_array(array($plugin, $point), $args);
        }
      Write a Reply...