You are here

public function QuickEditController::getUntransformedText in Drupal 10

Returns Ajax response to render 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 'QuickEditController::getUntransformedText'
quickedit.routing.yml in core/modules/quickedit/quickedit.routing.yml
core/modules/quickedit/quickedit.routing.yml

File

core/modules/quickedit/src/QuickEditController.php, line 377

Class

QuickEditController
Returns responses for Quick Edit module routes.

Namespace

Drupal\quickedit

Code

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