function _hashtags_is_last_term in Hashtags 7
Check if term is attached only to one entity (through Term referrence field type)
Parameters
integer $tid :
string $field_name :
Return value
boolean
2 calls to _hashtags_is_last_term()
- hashtags_comment_presave in ./
hashtags.module - Implements hook_comment_presave().
- hashtags_entity_presave in ./
hashtags.module - Implementation of hook_entity_presave().
File
- ./
hashtags.module, line 418
Code
function _hashtags_is_last_term($tid, $field_name = 'field_hashtags') {
$query = new EntityFieldQuery();
$query
->fieldCondition($field_name, 'tid', $tid, '=');
$entity_types = $query
->execute();
$count = 0;
foreach ($entity_types as $entity_type) {
$count += sizeof($entity_type);
}
return $count == 1;
}