function fieldable_panels_panes_panelizer_clone_panelizer in Fieldable Panels Panes (FPP) 7
Implements hook_panelizer_clone_panelizer().
File
- ./
fieldable_panels_panes.module, line 1667 - Maintains an entity that appears as panel pane content.
Code
function fieldable_panels_panes_panelizer_clone_panelizer(&$panelizer) {
foreach ($panelizer->display->content as $pid => $pane) {
if ($pane->type == "fieldable_panels_pane") {
$entity_info = entity_get_info('fieldable_panels_pane');
$fpp = fieldable_panels_panes_load_from_subtype_force($pane->subtype);
// Reusable FPPs do not get cloned.
if ($fpp->reusable) {
continue;
}
// Clone the FPP and make sure it will get saved as a new entity.
$new_fpp = clone $fpp;
// Reset the primary keys.
$new_fpp->fpid = NULL;
$new_fpp->vid = NULL;
$new_fpp->vuuid = NULL;
$new_fpp->uuid = NULL;
$new_fpp->is_new = TRUE;
// Reset timestamps.
$new_fpp->created = NULL;
$new_fpp->timestamp = NULL;
// Make sure the status of a cloned exportable is custom.
if (!empty($entity_info['exportable'])) {
$status_key = isset($entity_info['entity keys']['status']) ? $entity_info['entity keys']['status'] : 'status';
// Replaces ENTITY_CUSTOM because we cannot assume that the Entity API
// module is installed.
$new_fpp->{$status_key} = 0x1;
}
// Save the new FPP object and add it to the display.
$new_fpp = fieldable_panels_panes_save($new_fpp);
list($subtype_prefix, ) = explode(':', $pane->subtype);
$key = $subtype_prefix == 'current' ? 'fpid' : $subtype_prefix;
$pane->subtype = $subtype_prefix . ':' . $new_fpp->{$key};
}
}
}