You are here

function views_include_handler in Views (for Drupal 7) 6.2

Same name and namespace in other branches
  1. 6.3 includes/handlers.inc \views_include_handler()

Attempt to find the include file for a given handler from its definition.

This will also attempt to include all parents, though we're maxing the parent chain to 10 to prevent infinite loops.

1 call to views_include_handler()
_views_create_handler in includes/handlers.inc
Instantiate and construct a new handler

File

includes/handlers.inc, line 34
handlers.inc Defines the various handler objects to help build and display views.

Code

function views_include_handler($definition, $type, $count = 0) {

  // Do not proceed if the class already exists.
  if (isset($definition['handler']) && class_exists($definition['handler'])) {
    return TRUE;
  }

  // simple infinite loop prevention.
  if ($count > 10) {
    vpr(t('Handler @handler include tried to loop infinitely!', array(
      '@handler' => $definition['handler'],
    )));
    return FALSE;
  }
  if (!isset($definition['path'])) {
    if ($type == 'handler') {
      $definition += views_fetch_handler_data($definition['handler']);
    }
    else {
      $definition += views_fetch_plugin_data($type, $definition['handler']);
    }
  }
  if (!empty($definition['parent'])) {
    if ($type == 'handler') {
      $parent = views_fetch_handler_data($definition['parent']);
    }
    else {
      $parent = views_fetch_plugin_data($type, $definition['parent']);
    }
    if ($parent) {
      $rc = views_include_handler($parent, $type, $count + 1);

      // If the parent chain cannot be included, don't try; this will
      // help alleviate problems with modules with cross dependencies.
      if (!$rc) {
        return FALSE;
      }
    }
  }
  if (isset($definition['path']) && $definition['file']) {
    $filename = './' . $definition['path'] . '/' . $definition['file'];
    if (file_exists($filename)) {
      require_once $filename;
    }
  }
  return class_exists($definition['handler']);
}