protected function EntityPagerOut::entityRefUrlFromToken in Entity Pager 7
Process Entity Reference URL from tokens.
If it is established the Tokens are Entity References, this method converts them into useful information.
Parameters
string $entity_type: The type of entity.
object $entity: The entity object.
string $link_with_token: The link with the token in.
Return value
bool|mixed|null|string return a url from an Entity Reference.
1 call to EntityPagerOut::entityRefUrlFromToken()
- EntityPagerOut::tokenLink in includes/
EntityPagerOut.inc - Process Token link.
File
- includes/
EntityPagerOut.inc, line 110 - Provides the Business Logic for the EntityPager module.
Class
- EntityPagerOut
- Class EntityPagerOut.
Code
protected function entityRefUrlFromToken($entity_type, $entity, $link_with_token) {
$link_all_url = '';
// Get URL of token.
// Example token: [node:field_company]
$trimmed = trim($link_with_token, '[]');
$token_in_url = explode(':', $trimmed);
// E.g. field_company.
$field = $token_in_url[1];
// Set the id field.
$this
->setField('id_field', $field);
// E.g. $node->field_company['und'][0]['entity']->nid;
$field_long = $entity->{$field};
// E.g. $field_value = $field_value[LANGUAGE_NONE][0]['entity']->nid;
$field_value = $field_long[LANGUAGE_NONE][0]['target_id'];
if (isset($field_value) && is_numeric($field_value)) {
$link_all_url = drupal_get_path_alias($entity_type . '/' . $field_value);
}
return $link_all_url;
}