public function EditorController::getUntransformedText in Drupal 9
Same name and namespace in other branches
- 8 core/modules/editor/src/EditorController.php \Drupal\editor\EditorController::getUntransformedText()
Returns an Ajax response to render a text field without transformation filters.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity of which a formatted text field is being rerendered.
string $field_name: The name of the (formatted text) field that is being rerendered
string $langcode: The name of the language for which the formatted text field is being rerendered.
string $view_mode_id: The view mode the formatted text field should be rerendered in.
Return value
\Drupal\Core\Ajax\AjaxResponse The Ajax response.
1 string reference to 'EditorController::getUntransformedText'
- editor.routing.yml in core/
modules/ editor/ editor.routing.yml - core/modules/editor/editor.routing.yml
File
- core/
modules/ editor/ src/ EditorController.php, line 36
Class
- EditorController
- Returns responses for Editor module routes.
Namespace
Drupal\editorCode
public function getUntransformedText(EntityInterface $entity, $field_name, $langcode, $view_mode_id) {
$response = new AjaxResponse();
// Direct text editing is only supported for single-valued fields.
$field = $entity
->getTranslation($langcode)->{$field_name};
$editable_text = check_markup($field->value, $field->format, $langcode, [
FilterInterface::TYPE_TRANSFORM_REVERSIBLE,
FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE,
]);
$response
->addCommand(new GetUntransformedTextCommand($editable_text));
return $response;
}