function PanelizerEntityDefault::entity_base_url in Panelizer 7.3
Provides the base panelizer URL for an entity.
3 calls to PanelizerEntityDefault::entity_base_url()
- PanelizerEntityDefault::page_layout in plugins/
entity/ PanelizerEntityDefault.class.php - PanelizerEntityDefault::page_overview in plugins/
entity/ PanelizerEntityDefault.class.php - Switched page callback to give the overview page
- PanelizerEntityDefault::wrap_entity_panelizer_pages in plugins/
entity/ PanelizerEntityDefault.class.php - Provides a wrapper for the panelizer page output.
File
- plugins/
entity/ PanelizerEntityDefault.class.php, line 2266 - Base class for the Panelizer Entity plugin.
Class
- PanelizerEntityDefault
- Base class for the Panelizer Entity plugin.
Code
function entity_base_url($entity, $view_mode = NULL) {
list($entity_id, $revision_id, $bundle) = entity_extract_ids($this->entity_type, $entity);
$path_elements[] = $entity_id;
$path = $this->plugin['entity path'];
if ($this->supports_revisions) {
$current_entities = entity_load($this->entity_type, array(
$entity_id,
));
$current_entity = array_pop($current_entities);
// Ensure the correct revision key is used, as not all entities use 'vid'.
$entity_info = entity_get_info($this->entity_type);
$revision_key = isset($entity_info['entity keys']['revision']) ? $entity_info['entity keys']['revision'] : 'vid';
if ($revision_id !== $current_entity->{$revision_key}) {
$path_elements[] = $revision_id;
$path .= '/revisions/%';
}
}
$bits = explode('/', $path);
foreach ($bits as $count => $bit) {
if (strpos($bit, '%') === 0) {
$bits[$count] = array_shift($path_elements);
}
}
$bits[] = 'panelizer';
if ($view_mode) {
$bits[] = $view_mode;
}
$base_url = implode('/', $bits);
return $base_url;
}