You are here

function _hashtags_get_tracked_text in Hashtags 7

Gather content of all 'text' fields that marked as 'Hashtag tracked'

Parameters

EntityMetadataWrapper &$wrapper :

string $entity_type :

string $bundle :

Return value

string

2 calls to _hashtags_get_tracked_text()
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 365

Code

function _hashtags_get_tracked_text(&$wrapper, $entity_type, $bundle) {
  $text = '';

  // get all fields by entity type & bundle
  $fields = field_info_instances($entity_type, $bundle);
  foreach ($fields as $field_name => $field) {

    // check field is marked as 'Hashtag tracked' and
    // go through all marked fields to gather a content
    // (only 'text' fields can be marked like this)
    if (isset($field['hashtag_settings']) && $field['hashtag_settings']['hashtag_field']) {
      $text .= ' ';

      // value of fields with Input formats have should be
      // taken in different way through MetadataWrapper
      if ($field['settings']['text_processing']) {
        $text .= $wrapper->{$field_name}->value
          ->value();
      }
      else {
        $text .= $wrapper->{$field_name}
          ->value();
      }
    }
  }
  return $text;
}