function _forward_entity_from_path in Forward 7.3
4 calls to _forward_entity_from_path()
- forward_block_view in ./
forward.module - Implements hook_block_view().
- forward_page in ./
forward.module - Callback function for the forward Page
- forward_tracker in ./
forward.module - Callback for clickthrough tracker
- theme_forward_link in ./
forward.module - Theme function for Forward link
File
- ./
forward.module, line 1465 - Allows forwarding of entities by email, and provides a record of how often each has been forwarded.
Code
function _forward_entity_from_path($path, &$entity_type, &$entity, &$bundle) {
$id = 0;
$path = drupal_get_normal_path($path);
// Pass the path to the menu system and it will give us a loaded object and some meta data
if ($router_item = menu_get_item($path)) {
// Unfortunately, the router item doesn't tell us what entity type, so...
// Determine the entity type by matching the router load function to the list of all entity type load functions
if (!empty($router_item['load_functions'])) {
foreach ($router_item['load_functions'] as $load_fn) {
$entity_types = entity_get_info();
foreach ($entity_types as $type => $info) {
if ($info['load hook'] == $load_fn) {
// Have a match, set return value and passed in parameters
$entity_type = $type;
$entity = $router_item['map'][$router_item['number_parts'] - 1];
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
break;
}
}
}
}
// Load function matching didn't work, so try first URL parameter
if (!$id) {
if (!empty($router_item['map'][0])) {
$map0 = $router_item['map'][0];
$entity_types = entity_get_info();
foreach ($entity_types as $type => $info) {
if ($type == $map0) {
// Have a match, set return value and passed in parameters
$entity_type = $type;
$entity = NULL;
if (is_object($router_item['map'][$router_item['number_parts'] - 1])) {
$entity = $router_item['map'][$router_item['number_parts'] - 1];
}
elseif (is_numeric($router_item['map'][$router_item['number_parts'] - 1])) {
$entity = entity_load_single($entity_type, $router_item['map'][$router_item['number_parts'] - 1]);
}
if ($entity) {
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
break;
}
}
}
}
}
}
return $id;
}