You are here

function calendar_systems_call in Calendar Systems 6.2

API function to call a calendar's internal routine.

@retrun The returned value of called calendar function or NULL on fail.

Parameters

$function: Function "alias" to call.

$pick: Whether to cherrypick the calendar or just return the default one in case that the $calendar is not passed.

$args: An array of arguments to be passed to $function.

$calendar: Calendar identifier to call its $function callback.

See also

calendar_systems_pick()

calendar_systems_default()

File

./calendar_systems.module, line 331
Contains Calendar Systems module hooks, helpers and API functions.

Code

function calendar_systems_call($function, $pick = TRUE, $args = array(), $calendar = '') {

  // Cherrypick the best-fit calendar if requsted so.
  $calendar = empty($calendar) ? $pick ? calendar_systems_pick() : calendar_systems_default() : calendar_systems_calendars('calendar', $calendar);

  // Call the calendar callback, if available.
  if (isset($calendar[$function]) && function_exists($calendar[$function])) {
    return call_user_func_array($calendar[$function], $args);
  }

  // Cry otherwise!
  return NULL;
}