protected function DuplicatesTermMergeWebTestCase::duplicateHashTerm in Term Merge 7
Supportive method.
Calculate hash a term based on which it will be paired with other terms as possible duplicates of each other.
Parameters
object $term: Term whose duplicate suggestion hash is to be calculated
array $duplicate_suggestions: Array of duplicate suggestion names that to apply, when determining hash of the provided term
Return value
string Hash of the provided term according to enabled duplicate suggestions
1 call to DuplicatesTermMergeWebTestCase::duplicateHashTerm()
- DuplicatesTermMergeWebTestCase::testDuplicates in ./term_merge.test 
- Test merging duplicates feature of Term Merge module.
File
- ./term_merge.test, line 1035 
- Test the Term Merge module.
Class
- DuplicatesTermMergeWebTestCase
- Test the Merge Duplicate Terms feature of the Term Merge module.
Code
protected function duplicateHashTerm($term, $duplicate_suggestions = array(
  'name',
)) {
  $hash = '';
  foreach ($duplicate_suggestions as $duplicate_suggestion) {
    $hash_chunk = '';
    switch ($duplicate_suggestion) {
      case 'name':
        $hash_chunk = drupal_strtoupper($term->name);
        // Trying transliteration, if available.
        if (module_exists('transliteration')) {
          $hash_chunk = transliteration_get($hash_chunk);
          // Keeping only ASCII chars.
          $hash_chunk = preg_replace('#\\W#', '', $hash_chunk);
        }
        break;
      case 'description':
        $hash_chunk = drupal_strtoupper($term->description);
        break;
      case 'parent':
        $hash_chunk = $term->parents[0];
        break;
    }
    $hash .= $hash_chunk;
  }
  return $hash;
}