You are here

public function Field::__toString in Search API 8

Implements the magic __toString() method to simplify debugging.

File

src/Item/Field.php, line 675

Class

Field
Represents a field on a search item that can be indexed.

Namespace

Drupal\search_api\Item

Code

public function __toString() {
  $label = $this
    ->getLabel();
  $field_id = $this
    ->getFieldIdentifier();
  $type = $this
    ->getType();
  $out = "{$label} [{$field_id}]: indexed as type {$type}";
  $is_text_type = \Drupal::getContainer()
    ->get('search_api.data_type_helper')
    ->isTextType($type);
  if ($is_text_type) {
    $out .= ' (boost ' . $this
      ->getBoost() . ')';
  }
  if ($this
    ->getValues()) {
    $out .= "\nValues:";
    foreach ($this
      ->getValues() as $value) {
      $value = str_replace("\n", "\n  ", "{$value}");
      $out .= "\n- " . $value;
    }
  }
  return $out;
}