You are here

function fieldable_panels_panes_load_from_subtype_force in Fieldable Panels Panes (FPP) 7

Properly load the entity via $subtype_name.

Parameters

string $subtype_name: A string combining an indicator of the type of ID, e.g. 'fpid', 'vid', 'uuid', 'vuuid' or 'current, and an integer ID, separated by a colon; e.g. "fpid:123". If the type is 'current' the newest revision will be loaded, 'fpid' and 'uuid' will load the revision considered best, 'vid' and 'vuuid' will load a specific revision. Both 'uuid' and 'vuuid' require the UUID module to be present.

Return value

object The requested FPP object.

4 calls to fieldable_panels_panes_load_from_subtype_force()
fieldable_panels_panes_check_access_update in ./fieldable_panels_panes.module
Check if the user has 'update' access for an FPP object.
fieldable_panels_panes_fieldable_panels_pane_content_type in plugins/content_types/fieldable_panels_pane.inc
Return an individual FPP.
fieldable_panels_panes_load_from_subtype in ./fieldable_panels_panes.module
Properly load the FPP entity via its subtype.
fieldable_panels_panes_panelizer_clone_panelizer in ./fieldable_panels_panes.module
Implements hook_panelizer_clone_panelizer().

File

./fieldable_panels_panes.module, line 1029
Maintains an entity that appears as panel pane content.

Code

function fieldable_panels_panes_load_from_subtype_force($subtype_name) {
  $object = NULL;

  // Split the string up into the object type and the ID.
  list($type, $id) = explode(':', $subtype_name);

  // UUID integration.
  if ($type == 'uuid' && module_exists('uuid')) {
    $ids = entity_get_id_by_uuid('fieldable_panels_pane', array(
      $id,
    ));
    if ($object = entity_load('fieldable_panels_pane', $ids)) {
      $object = reset($object);
    }
  }
  elseif ($type == 'vuuid' && module_exists('uuid')) {
    $vids = entity_get_id_by_uuid('fieldable_panels_pane', array(
      $id,
    ), TRUE);
    if ($vids && ($content = entity_load('fieldable_panels_pane', FALSE, array(
      'vid' => reset($vids),
    )))) {
      $object = reset($content);
    }
  }
  elseif ($type == 'vid') {
    $fpid = db_query('SELECT fpid FROM {fieldable_panels_panes_revision} WHERE vid = :vid', array(
      ':vid' => $id,
    ))
      ->fetchField();
    $object = fieldable_panels_panes_load($fpid, $id);
  }
  elseif ($type == 'current') {
    $vid = db_query('SELECT MAX(vid) FROM {fieldable_panels_panes_revision} WHERE fpid = :fpid', array(
      ':fpid' => $id,
    ))
      ->fetchField();
    $object = fieldable_panels_panes_load($id, $vid);
  }
  else {
    $object = fieldable_panels_panes_load($id);
  }
  return $object;
}