You are here

private function ParagraphsFrontendUIController::refreshWithAJaxResponse in Paragraphs frontend ui 8.2

Same name and namespace in other branches
  1. 8 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 273

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();
  if ($this->configFactory
    ->get(SettingsForm::SETTINGS_NAME)
    ->get('enable_nested_paragraphs')) {
    $response
      ->addCommand(new ClearContextualLinks());
  }

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