function TextProcessed::getValue
Same name in other branches
- 9 core/modules/text/src/TextProcessed.php \Drupal\text\TextProcessed::getValue()
- 8.9.x core/modules/text/src/TextProcessed.php \Drupal\text\TextProcessed::getValue()
- 11.x core/modules/text/src/TextProcessed.php \Drupal\text\TextProcessed::getValue()
Overrides TypedData::getValue
3 calls to TextProcessed::getValue()
- TextProcessed::getCacheContexts in core/
modules/ text/ src/ TextProcessed.php - The cache contexts associated with this object.
- TextProcessed::getCacheMaxAge in core/
modules/ text/ src/ TextProcessed.php - The maximum age for which this object may be cached.
- TextProcessed::getCacheTags in core/
modules/ text/ src/ TextProcessed.php - The cache tags associated with this object.
File
-
core/
modules/ text/ src/ TextProcessed.php, line 41
Class
- TextProcessed
- A computed property for processing text with a format.
Namespace
Drupal\textCode
public function getValue() {
if ($this->processed !== NULL) {
return FilteredMarkup::create($this->processed
->getProcessedText());
}
$item = $this->getParent();
$text = $item->{$this->definition
->getSetting('text source')};
// Avoid doing unnecessary work on empty strings.
if (!isset($text) || $text === '') {
$this->processed = new FilterProcessResult('');
}
else {
$build = [
'#type' => 'processed_text',
'#text' => $text,
'#format' => $item->format,
'#filter_types_to_skip' => [],
'#langcode' => $item->getLangcode(),
];
// Capture the cacheability metadata associated with the processed text.
$processed_text = $this->getRenderer()
->renderInIsolation($build);
$this->processed = FilterProcessResult::createFromRenderArray($build)->setProcessedText((string) $processed_text);
}
return FilteredMarkup::create($this->processed
->getProcessedText());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.