ctools_content_get_subtypes

  1. drupal
    1. 6 content.inc function
    2. 7 content.inc function
Drupal 7 ctools_content_get_subtypes($type)

Get all of the individual subtypes provided by a given content type. This would be all of the blocks for the block type, or all of the views for the view type.

Parameters

$type: The content type to load.

Return value

An array of all subtypes available.

3 calls to ctools_content_get_subtypes()

File

sites/all/modules/ctools/includes/content.inc, line 124
Contains the tools to handle pluggable content that can be used by other applications such as Panels or Dashboard.

Code

function ctools_content_get_subtypes($type) {
  static $cache = array();

  $subtypes = array();

  if (is_array($type)) {
    $plugin = $type;
  }
  else {
    $plugin = ctools_get_content_type($type);
  }

  if (empty($plugin) || empty($plugin['name'])) {
    return;
  }

  if (isset($cache[$plugin['name']])) {
    return $cache[$plugin['name']];
  }

  if (isset($plugin['content types'])) {
    $function = $plugin['content types'];
    if (is_array($function)) {
      $subtypes = $function;
    }
    else if (function_exists($function)) {
      // Cast to array to prevent errors from non-array returns.
      $subtypes = (array) $function($plugin);
    }
  }

  // Walk through the subtypes and ensure minimal settings are
  // retained.
  foreach ($subtypes as $id => $subtype) {
    // Use exact name since this is a modify by reference.
    ctools_content_prepare_subtype($subtypes[$id], $plugin);
  }

  $cache[$plugin['name']] = $subtypes;

  return $subtypes;
}