Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. TextProcessed.php

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

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal