You are here

function fb_exit in Drupal for Facebook 7.3

Same name and namespace in other branches
  1. 5.2 fb.module \fb_exit()
  2. 5 fb.module \fb_exit()
  3. 6.3 fb.module \fb_exit()
  4. 6.2 fb.module \fb_exit()

Implements hook_exit().

When completing a canvas page we need special processing for the session. See fb_session.inc.

Also invoke hook_fb(FB_OP_EXIT), so that other modules can handle special cases (in particular form support in fb_canvas.module.

TODO: remove this hook, for compatibility with Drupal's aggressive caching. Modules that currently look for FB_OP_EXIT will need to implement hook_exit on their own.

File

./fb.module, line 1510
This is the core required module of Drupal for Facebook.

Code

function fb_exit($destination = NULL) {
  global $_fb_app, $_fb;
  $on_exit =& drupal_static('fb_invoke_async');
  if (!empty($on_exit)) {
    while ($args = array_shift($on_exit)) {
      $func = array_shift($args);
      if (fb_verbose()) {
        watchdog('fb', t("Processing delayed call to %function."), array(
          '%function' => $func,
        ));
      }
      try {
        $result = call_user_func_array($func, $args);
      } catch (Exception $e) {
        fb_log_exception($e, t('Failed calling %function.', array(
          '%function' => $func,
        )));
      }
    }
  }
  if ($_fb_app && $_fb) {

    // Invoke other modules.
    fb_invoke(FB_OP_EXIT, array(
      'fb_app' => $_fb_app,
      'fb' => $GLOBALS['_fb'],
    ), $destination);
  }
}