You are here

public function GeysirModalController::delete in Geysir 8

Create a modal dialog to delete a single paragraph.

1 string reference to 'GeysirModalController::delete'
geysir.routing.yml in ./geysir.routing.yml
geysir.routing.yml

File

src/Controller/GeysirModalController.php, line 150

Class

GeysirModalController
Controller for all modal dialogs.

Namespace

Drupal\geysir\Controller

Code

public function delete($parent_entity_type, $parent_entity_bundle, $parent_entity_revision, $field, $field_wrapper_id, $delta, $paragraph, $paragraph_revision, $js = 'nojs') {
  if ($js == 'ajax') {
    $options = [
      'dialogClass' => 'geysir-dialog',
      'width' => '20%',
    ];
    $form = $this
      ->entityFormBuilder()
      ->getForm($paragraph, 'geysir_modal_delete', []);
    $response = new AjaxResponse();
    $paragraph_title = $this
      ->getParagraphTitle($parent_entity_type, $parent_entity_bundle, $field);
    $response
      ->addCommand(new OpenModalDialogCommand($this
      ->t('Delete @paragraph_title', [
      '@paragraph_title' => $paragraph_title,
    ]), render($form), $options));
    return $response;
  }
  return $this
    ->t('Javascript is required for this functionality to work properly.');
}