You are here

function fieldable_panels_panes_build_content_type_info in Fieldable Panels Panes (FPP) 7

Returns a list of all reusable FPP entities of a given bundle.

Parameters

string $bundle: Fieldable panel pane bundle machine name.

array $ids: An array of fieldable panel pane entity ids.

Return value

array An array of content type information for each fpp entity.

1 call to fieldable_panels_panes_build_content_type_info()
fieldable_panels_panes_fieldable_panels_pane_content_type_content_types in plugins/content_types/fieldable_panels_pane.inc
Callback to return all custom content types available.

File

plugins/content_types/fieldable_panels_pane.inc, line 136
CTools content type to render a fielded panel pane.

Code

function fieldable_panels_panes_build_content_type_info($bundle, array $ids) {
  $types = array();
  $cid = "fieldable_panels_panes_{$bundle}_content_type";
  if (($cache = cache_get($cid, 'cache_panels')) && !empty($cache->data)) {
    $types = $cache->data;
  }
  else {
    $entities = fieldable_panels_panes_load_multiple($ids);
    if (!empty($entities)) {
      foreach ($entities as $entity_id => $entity) {
        $subtype = _fieldable_panels_panes_custom_content_type($entity);
        $types[$subtype['name']] = $subtype;

        // Re-key $entities such that $types and $entities are keyed
        // identically.
        $entities[$subtype['name']] = $entity;
        unset($entities[$entity_id]);
      }
    }

    // Trigger hook_fieldable_panels_panes_content_types_alter().
    drupal_alter('fieldable_panels_panes_content_types', $types, $bundle, $entities);
    cache_set($cid, $types, 'cache_panels');
  }
  return $types;
}