Skip to content

Instantly share code, notes, and snippets.

@chadaustin
Created April 26, 2012 06:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chadaustin/2496896 to your computer and use it in GitHub Desktop.
Save chadaustin/2496896 to your computer and use it in GitHub Desktop.
class functions {
public static function make_callback($function) {
if (is_array($function) || strpos($function,'::') === false) {
if (! is_callable($function)) {
if (tep_in_sandbox()) {
tep_die_deprecated("Called nonexistent function '$function' in functions::make_callback");
} else {
dusty_record_value("bad_function_calls", $function);
}
}
return $function;
} else {
list($class, $method) = explode('::', $function);
if (! method_exists(new $class, $method)) {
if (tep_in_sandbox()) {
tep_die_deprecated("Called nonexistent method '$method' in functions::make_callback");
} else {
dusty_record_value("bad_function_calls", $method);
}
}
return array($class, $method);
}
}
public static function make_callback_without_import($function) {
if (is_array($function) || strpos($function,'::') === false) {
return $function;
} else {
list($class, $method) = explode('::',$function);
return array($class, $method);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment