Same name and namespace in other branches
  1. 8.9.x core/modules/text/src/TextProcessed.php \Drupal\text\TextProcessed::getValue()
  2. 9 core/modules/text/src/TextProcessed.php \Drupal\text\TextProcessed::getValue()

Gets the data value.

Return value

mixed The data value.

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\text

Code

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());
}