class crumbs_EntityPlugin_Field_TermReference in Crumbs, the Breadcrumbs suite 7.2
Hierarchy
- class \crumbs_EntityPlugin_Field_Abstract implements crumbs_EntityPlugin
Expanded class hierarchy of crumbs_EntityPlugin_Field_TermReference
File
- lib/
EntityPlugin/ Field/ TermReference.php, line 3
View source
class crumbs_EntityPlugin_Field_TermReference extends crumbs_EntityPlugin_Field_Abstract {
/**
* {@inheritdoc}
*/
function fieldFindCandidate(array $items) {
$terms = array();
foreach ($items as $item) {
$terms[$item['tid']] = TRUE;
}
if (count($terms) > 1) {
$walk = $terms;
$visited = array();
while (!empty($walk)) {
$visited += $walk;
foreach ($walk as $tid => $true) {
$parents = taxonomy_get_parents($tid);
unset($walk[$tid]);
foreach ($parents as $parent_tid => $parent) {
unset($terms[$parent_tid]);
if (!isset($visited[$parent_tid])) {
$walk[$parent_tid] = $parent;
}
}
}
}
}
// Return the path of the first found term, if any.
foreach ($terms as $tid => $term_info) {
$term = taxonomy_term_load($tid);
if (!empty($term)) {
$uri = entity_uri('taxonomy_term', $term);
if (!empty($uri)) {
return $uri['path'];
}
}
}
return NULL;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
crumbs_EntityPlugin_Field_Abstract:: |
protected | property | ||
crumbs_EntityPlugin_Field_Abstract:: |
protected | property | ||
crumbs_EntityPlugin_Field_Abstract:: |
function |
Overrides crumbs_EntityPlugin:: |
||
crumbs_EntityPlugin_Field_Abstract:: |
function |
Overrides crumbs_EntityPlugin:: |
||
crumbs_EntityPlugin_Field_Abstract:: |
protected | function | ||
crumbs_EntityPlugin_Field_Abstract:: |
function | |||
crumbs_EntityPlugin_Field_TermReference:: |
function |
Overrides crumbs_EntityPlugin_Field_Abstract:: |