TextValue.php in Search API 8
File
src/Plugin/search_api/data_type/value/TextValue.php
View source
<?php
namespace Drupal\search_api\Plugin\search_api\data_type\value;
class TextValue implements TextValueInterface {
protected $text;
protected $originalText;
protected $tokens;
protected $properties = [];
public function __construct($text) {
$this->text = $this->originalText = $text;
}
public function getText() {
return $this->text;
}
public function toText() {
$tokens = $this
->getTokens();
if ($tokens !== NULL) {
$to_string = function (TextTokenInterface $token) {
return $token
->getText();
};
return implode(' ', array_map($to_string, $tokens));
}
return $this
->getText();
}
public function setText($text) {
$this->text = $text;
return $this;
}
public function getOriginalText() {
return $this->originalText;
}
public function setOriginalText($originalText) {
$this->originalText = $originalText;
return $this;
}
public function getTokens() {
return $this->tokens;
}
public function setTokens(array $tokens = NULL) {
$this->tokens = $tokens;
return $this;
}
public function getProperties() {
return $this->properties;
}
public function getProperty($name, $default = NULL) {
if (array_key_exists($name, $this->properties)) {
return $this->properties[$name];
}
return $default;
}
public function setProperties(array $properties) {
$this->properties = $properties;
return $this;
}
public function setProperty($name, $value = TRUE) {
$this->properties[$name] = $value;
return $this;
}
public function __toString() {
return $this
->toText();
}
}
Classes
Name |
Description |
TextValue |
Represents a single value of a fulltext field. |