You are here

function pay_load_handler in Pay 6

Same name and namespace in other branches
  1. 7 pay.module \pay_load_handler()

API Function: Include a handler file for a payment object.

1 call to pay_load_handler()
pay_load in ./pay.module
API Function: Load a payment class.

File

./pay.module, line 156
Pay module allows for accepting payments using pluggable payment backends.

Code

function pay_load_handler($type, $name) {
  static $cache = array();
  if (!isset($cache[$type])) {

    // Base classes for handlers.
    module_load_include('inc', 'pay', 'includes/handlers/pay');
    module_load_include('inc', 'pay', 'includes/handlers/' . $type);
    $cache[$type] = array();
  }

  // This is a pay primitive class, so we're done.
  if ($type == $name) {
    return TRUE;
  }

  // Already loaded.
  if (isset($cache[$type][$name])) {
    return $cache[$type][$name];
  }
  if ($name && ($handler = pay_handlers($type, $name))) {

    // Ensure the parent is loaded.
    if (isset($handler['parent'])) {
      pay_load_handler($type, $handler['parent']);
    }

    // Respect the 'path' element that may have been specified.
    $file = isset($handler['path']) ? $handler['path'] . '/' : '';
    $file .= $name . '.inc';

    // Require the file, if it exists.
    if ($cache[$type][$name] = is_file($file)) {
      require_once $file;
    }
    return $cache[$type][$name];
  }
}