class TextValue in Search API 8
Represents a single value of a fulltext field.
Hierarchy
- class \Drupal\search_api\Plugin\search_api\data_type\value\TextValue implements TextValueInterface
Expanded class hierarchy of TextValue
6 files declare their use of TextValue
- AddHierarchy.php in src/
Plugin/ search_api/ processor/ AddHierarchy.php - BackendTest.php in modules/
search_api_db/ tests/ src/ Kernel/ BackendTest.php - FieldsProcessorPluginBaseTest.php in tests/
src/ Unit/ Processor/ FieldsProcessorPluginBaseTest.php - StemmerTest.php in tests/
src/ Unit/ Processor/ StemmerTest.php - TestFieldsProcessorPlugin.php in tests/
src/ Unit/ Processor/ TestFieldsProcessorPlugin.php
File
- src/
Plugin/ search_api/ data_type/ value/ TextValue.php, line 8
Namespace
Drupal\search_api\Plugin\search_api\data_type\valueView source
class TextValue implements TextValueInterface {
/**
* The current text value.
*
* @var string
*/
protected $text;
/**
* The original text value.
*
* @var string
*/
protected $originalText;
/**
* The tokens created for this text value (if any).
*
* @var \Drupal\search_api\Plugin\search_api\data_type\value\TextTokenInterface[]|null
*/
protected $tokens;
/**
* An array of properties for this text value.
*
* @var array
*/
protected $properties = [];
/**
* Constructs a TextValue object.
*
* @param string $text
* The original text value.
*/
public function __construct($text) {
$this->text = $this->originalText = $text;
}
/**
* {@inheritdoc}
*/
public function getText() {
return $this->text;
}
/**
* {@inheritdoc}
*/
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();
}
/**
* {@inheritdoc}
*/
public function setText($text) {
$this->text = $text;
return $this;
}
/**
* {@inheritdoc}
*/
public function getOriginalText() {
return $this->originalText;
}
/**
* {@inheritdoc}
*/
public function setOriginalText($originalText) {
$this->originalText = $originalText;
return $this;
}
/**
* {@inheritdoc}
*/
public function getTokens() {
return $this->tokens;
}
/**
* {@inheritdoc}
*/
public function setTokens(array $tokens = NULL) {
$this->tokens = $tokens;
return $this;
}
/**
* {@inheritdoc}
*/
public function getProperties() {
return $this->properties;
}
/**
* {@inheritdoc}
*/
public function getProperty($name, $default = NULL) {
if (array_key_exists($name, $this->properties)) {
return $this->properties[$name];
}
return $default;
}
/**
* {@inheritdoc}
*/
public function setProperties(array $properties) {
$this->properties = $properties;
return $this;
}
/**
* {@inheritdoc}
*/
public function setProperty($name, $value = TRUE) {
$this->properties[$name] = $value;
return $this;
}
/**
* Implements the magic __toString() method.
*/
public function __toString() {
return $this
->toText();
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
TextValue:: |
protected | property | The original text value. | |
TextValue:: |
protected | property | An array of properties for this text value. | |
TextValue:: |
protected | property | The current text value. | |
TextValue:: |
protected | property | The tokens created for this text value (if any). | |
TextValue:: |
public | function |
Retrieves the original text value. Overrides TextValueInterface:: |
|
TextValue:: |
public | function |
Retrieves the properties set for this text value. Overrides TextValueInterface:: |
|
TextValue:: |
public | function |
Retrieves a specific property of this text value. Overrides TextValueInterface:: |
|
TextValue:: |
public | function |
Retrieves the currently stored text value. Overrides TextValueInterface:: |
|
TextValue:: |
public | function |
Retrieves the text tokens this text value was split into, if any. Overrides TextValueInterface:: |
|
TextValue:: |
public | function |
Sets the original text value. Overrides TextValueInterface:: |
|
TextValue:: |
public | function |
Sets the properties of this text value. Overrides TextValueInterface:: |
|
TextValue:: |
public | function |
Sets the properties of this text value. Overrides TextValueInterface:: |
|
TextValue:: |
public | function |
Sets the currently stored text value. Overrides TextValueInterface:: |
|
TextValue:: |
public | function |
Sets the text tokens for the text value. Overrides TextValueInterface:: |
|
TextValue:: |
public | function |
Retrieves the current effective text value. Overrides TextValueInterface:: |
|
TextValue:: |
public | function | Constructs a TextValue object. | |
TextValue:: |
public | function | Implements the magic __toString() method. |