public function TextProcessed::getValue

Implements TypedDataInterface::getValue().

Overrides TypedData::getValue

File

drupal/core/modules/field/modules/text/lib/Drupal/text/TextProcessed.php, line 97
Definition of Drupal\text\TextProcessed.

Class

TextProcessed
A computed property for processing text with a format.

Namespace

Drupal\text

Code

public function getValue($langcode = NULL) {
  if (!isset($this->text)) {
    throw new InvalidArgumentException('Computed properties require context for computation.');
  }
  $field = $this->parent
    ->getParent();
  $entity = $field
    ->getParent();
  $instance = field_info_instance($entity
    ->entityType(), $field
    ->getName(), $entity
    ->bundle());
  if (!empty($instance['settings']['text_processing']) && $this->format->value) {
    return check_markup($this->text->value, $this->format->value, $entity
      ->language()->langcode);
  }
  else {

    // If no format is available, still make sure to sanitize the text.
    return check_plain($this->text->value);
  }
}