public function EditorController::getUntransformedText

Returns an Ajax response to render a text field without transformation filters.

Parameters

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.

Return value

\Drupal\Core\Ajax\AjaxResponse The Ajax response.

1 string reference to 'EditorController::getUntransformedText'
editor.routing.yml in drupal/core/modules/editor/editor.routing.yml
drupal/core/modules/editor/editor.routing.yml

File

drupal/core/modules/editor/lib/Drupal/editor/EditorController.php, line 36
Contains \Drupal\editor\EditorController.

Class

EditorController
Returns responses for Editor module routes.

Namespace

Drupal\editor

Code

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