class EditorController

Returns responses for Editor module routes.

Hierarchy

Expanded class hierarchy of EditorController

1 file declares its use of EditorController
EditIntegrationTest.php in drupal/core/modules/editor/lib/Drupal/editor/Tests/EditIntegrationTest.php
Contains \Drupal\editor\Tests\EditorIntegrationTest.

File

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

Namespace

Drupal\editor
View source
class EditorController extends ContainerAware {

  /**
   * Returns an Ajax response to render a text field without transformation filters.
   *
   * @param int $entity
   *   The entity of which a processed text field is being rerendered.
   * @param string $field_name
   *   The name of the (processed text) field that that is being rerendered
   * @param string $langcode
   *   The name of the language for which the processed text field is being
   *   rererendered.
   * @param string $view_mode
   *   The view mode the processed text field should be rerendered in.
   *
   * @return \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;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ContainerAware::$container protected property @api
ContainerAware::setContainer public function Sets the Container associated with this Controller. Overrides ContainerAwareInterface::setContainer
EditorController::getUntransformedText public function Returns an Ajax response to render a text field without transformation filters.