function crumbs_CrumbsEntityPlugin_TokenEnabled::entityFindCandidate in Crumbs, the Breadcrumbs suite 7.2
Parameters
object $entity: The entity on this path.
string $entity_type: The entity type
string $distinction_key: Typically the bundle name. On user entities, this is one of the roles of the user. (this might be called more than once per user)
Return value
string A candidate for the parent path or title.
Overrides crumbs_CrumbsEntityPlugin_TokenDisabled::entityFindCandidate
File
- lib/
CrumbsEntityPlugin/ TokenEnabled.php, line 8
Class
Code
function entityFindCandidate($entity, $entity_type, $distinction_key) {
// This is cached..
$patterns = variable_get('crumbs_' . $entity_type . '_parent_patterns', array());
if (empty($patterns[$distinction_key])) {
return NULL;
}
// Use token to resolve the pattern.
$info = entity_get_info($entity_type);
$token_data = array(
$info['token type'] => $entity,
);
$token_options = array(
'language' => $GLOBALS['language'],
'callback' => 'crumbs_clean_token_values',
);
$parent = token_replace($patterns[$distinction_key], $token_data, $token_options);
if (empty($parent)) {
// Token collapsed..
}
// Only accept candidates where all tokens are fully resolved.
// This means we can't have literal '[' in the path - so be it.
if (FALSE !== strpos($parent, '[')) {
return NULL;
}
return $parent;
}