You are here

function entity_metadata_taxonomy_term_get_properties in Entity API 7

Callback for getting term properties.

See also

entity_metadata_taxonomy_entity_info_alter()

1 string reference to 'entity_metadata_taxonomy_term_get_properties'
entity_metadata_taxonomy_entity_property_info in modules/taxonomy.info.inc
Implements hook_entity_property_info() on top of taxonomy module.

File

modules/callbacks.inc, line 303
Provides various callbacks for the whole core module integration.

Code

function entity_metadata_taxonomy_term_get_properties($term, array $options, $name) {
  switch ($name) {
    case 'node_count':
      return count(taxonomy_select_nodes($term->tid));
    case 'description':
      return check_markup($term->description, isset($term->format) ? $term->format : NULL, '', TRUE);
    case 'parent':
      if (isset($term->parent[0]) && !is_array(isset($term->parent[0]))) {
        return $term->parent;
      }
      return array_keys(taxonomy_get_parents($term->tid));
    case 'parents_all':

      // We have to return an array of ids.
      $tids = array();
      foreach (taxonomy_get_parents_all($term->tid) as $parent) {
        $tids[] = $parent->tid;
      }
      return $tids;
  }
}