Guest User

Untitled

a guest
Feb 20th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. /**
  2. * Returns true if the caller is to go ahead with default behavior, false if it is to skip.
  3. * The method is passed a reference to $caller, plus any additional arguments supplied.
  4. */
  5. function lqtDelegate( $caller, $delegate, $methodName ) {
  6. if( !$delegate ) return true;
  7.  
  8. // Build an array from the extra arguments.
  9. // In any case, include $caller in the arguments.
  10. $extra_args = array( &$caller );
  11. for ( $i = 3; $i < func_num_args(); $i++ ) {
  12. $extra_args[] = &func_get_arg($i);
  13. }
  14.  
  15. $refl = new ReflectionObject( $delegate );
  16. if ( $refl->hasMethod( $methodName ) ) {
  17. return call_user_func_array( array( $delegate, $methodName ), $extra_args );
  18. } else {
  19. return true;
  20. }
  21. }
Add Comment
Please, Sign In to add comment