OpenModalDialogCommand.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace Drupal\Core\Ajax;
  3. /**
  4. * Defines an AJAX command to open certain content in a dialog in a modal dialog.
  5. *
  6. * @ingroup ajax
  7. */
  8. class OpenModalDialogCommand extends OpenDialogCommand {
  9. /**
  10. * Constructs an OpenModalDialog object.
  11. *
  12. * The modal dialog differs from the normal modal provided by
  13. * OpenDialogCommand in that a modal prevents other interactions on the page
  14. * until the modal has been completed. Drupal provides a built-in modal for
  15. * this purpose, so no selector needs to be provided.
  16. *
  17. * @param string $title
  18. * The title of the dialog.
  19. * @param string|array $content
  20. * The content that will be placed in the dialog, either a render array
  21. * or an HTML string.
  22. * @param array $dialog_options
  23. * (optional) Settings to be passed to the dialog implementation. Any
  24. * jQuery UI option can be used. See http://api.jqueryui.com/dialog.
  25. * @param array|null $settings
  26. * (optional) Custom settings that will be passed to the Drupal behaviors
  27. * on the content of the dialog. If left empty, the settings will be
  28. * populated automatically from the current request.
  29. */
  30. public function __construct($title, $content, array $dialog_options = [], $settings = NULL) {
  31. $dialog_options['modal'] = TRUE;
  32. parent::__construct('#drupal-modal', $title, $content, $dialog_options, $settings);
  33. }
  34. }