You are here

private function ParagraphsFrontendUIController::refreshWithAJaxResponse in Paragraphs frontend ui 8

Same name and namespace in other branches
  1. 8.2 src/Controller/ParagraphsFrontendUIController.php \Drupal\paragraphs_frontend_ui\Controller\ParagraphsFrontendUIController::refreshWithAJaxResponse()

Helper function to refresh the field with ajax.

3 calls to ParagraphsFrontendUIController::refreshWithAJaxResponse()
ParagraphsFrontendUIController::down in src/Controller/ParagraphsFrontendUIController.php
Shift down a single paragraph.
ParagraphsFrontendUIController::duplicate in src/Controller/ParagraphsFrontendUIController.php
Duplicate a paragraph.
ParagraphsFrontendUIController::up in src/Controller/ParagraphsFrontendUIController.php
Shift up a single paragraph.

File

src/Controller/ParagraphsFrontendUIController.php, line 155

Class

ParagraphsFrontendUIController
Controller for up and down actions.

Namespace

Drupal\paragraphs_frontend_ui\Controller

Code

private function refreshWithAJaxResponse($entity, $field_name) {
  $identifier = '[data-paragraphs-frontend-ui=' . $field_name . '-' . $entity
    ->id() . ']';
  $field = $entity
    ->get($field_name);
  $this
    ->forceValueLanguage($field, $this
    ->langcode());
  $response = new AjaxResponse();

  // Refresh the paragraphs field.
  $response
    ->addCommand(new ReplaceCommand($identifier, $field
    ->view('default')));
  return $response;
}