Returns an Ajax response to render a text field without transformation filters.
int $entity: The entity of which a processed text field is being rerendered.
string $field_name: The name of the (processed text) field that that is being rerendered
string $langcode: The name of the language for which the processed text field is being rererendered.
string $view_mode: The view mode the processed text field should be rerendered in.
\Drupal\Core\Ajax\AjaxResponse The Ajax response.
public function getUntransformedText(EntityInterface $entity, $field_name, $langcode, $view_mode) {
$response = new AjaxResponse();
// Direct text editing is only supported for single-valued fields.
$field = $entity
->getTranslation($langcode, FALSE)->{$field_name};
$editable_text = check_markup($field->value, $field->format, $langcode, FALSE, array(
FILTER_TYPE_TRANSFORM_REVERSIBLE,
FILTER_TYPE_TRANSFORM_IRREVERSIBLE,
));
$response
->addCommand(new GetUntransformedTextCommand($editable_text));
return $response;
}