class OpenBootstrap4ModalDialogCommand in Bootstrap 4 Modal 8
Same name and namespace in other branches
- 2.x src/Ajax/OpenBootstrap4ModalDialogCommand.php \Drupal\bootstrap4_modal\Ajax\OpenBootstrap4ModalDialogCommand
Defines an AJAX command to open certain content in a dialog in a modal.
Hierarchy
- class \Drupal\Core\Ajax\OpenDialogCommand implements CommandInterface, CommandWithAttachedAssetsInterface uses CommandWithAttachedAssetsTrait
- class \Drupal\bootstrap4_modal\Ajax\OpenBootstrap4ModalDialogCommand
Expanded class hierarchy of OpenBootstrap4ModalDialogCommand
2 files declare their use of OpenBootstrap4ModalDialogCommand
- Bootstrap4Modal.php in src/
Plugin/ EntityBrowser/ Display/ Bootstrap4Modal.php - Bootstrap4ModalRenderer.php in src/
Render/ MainContent/ Bootstrap4ModalRenderer.php
File
- src/
Ajax/ OpenBootstrap4ModalDialogCommand.php, line 12
Namespace
Drupal\bootstrap4_modal\AjaxView source
class OpenBootstrap4ModalDialogCommand extends OpenDialogCommand {
/**
* Constructs an OpenModalDialog object.
*
* The modal dialog differs from the normal modal provided by
* OpenDialogCommand in that a modal prevents other interactions on the page
* until the modal has been completed. Drupal provides a built-in modal for
* this purpose, so no selector needs to be provided.
*
* @param string $title
* The title of the dialog.
* @param string|array $content
* The content that will be placed in the dialog, either a render array
* or an HTML string.
* @param array $dialog_options
* (optional) Settings to be passed to the dialog implementation. Any
* jQuery UI option can be used. See http://api.jqueryui.com/dialog.
* @param array|null $settings
* (optional) Custom settings that will be passed to the Drupal behaviors
* on the content of the dialog. If left empty, the settings will be
* populated automatically from the current request.
*/
public function __construct($title, $content, array $dialog_options = [], $settings = NULL) {
$dialog_options['modal'] = TRUE;
parent::__construct('#drupal-bootstrap4-modal', $title, $content, $dialog_options, $settings);
}
/**
* Implements \Drupal\Core\Ajax\CommandInterface:render().
*/
public function render() {
// For consistency ensure the modal option is set to TRUE or FALSE.
$this->dialogOptions['modal'] = isset($this->dialogOptions['modal']) && $this->dialogOptions['modal'];
return [
'command' => 'openBootstrap4Dialog',
'selector' => $this->selector,
'settings' => $this->settings,
'data' => $this
->getRenderedContent(),
'dialogOptions' => $this->dialogOptions,
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CommandWithAttachedAssetsTrait:: |
protected | property | The attached assets for this Ajax command. | |
CommandWithAttachedAssetsTrait:: |
public | function | Gets the attached assets. | |
CommandWithAttachedAssetsTrait:: |
protected | function | Processes the content for output. | |
OpenBootstrap4ModalDialogCommand:: |
public | function |
Implements \Drupal\Core\Ajax\CommandInterface:render(). Overrides OpenDialogCommand:: |
|
OpenBootstrap4ModalDialogCommand:: |
public | function |
Constructs an OpenModalDialog object. Overrides OpenDialogCommand:: |
|
OpenDialogCommand:: |
protected | property | The content for the dialog. | |
OpenDialogCommand:: |
protected | property | Stores dialog-specific options passed directly to jQuery UI dialogs. Any jQuery UI option can be used. See http://api.jqueryui.com/dialog. | |
OpenDialogCommand:: |
protected | property | The selector of the dialog. | |
OpenDialogCommand:: |
protected | property | Custom settings that will be passed to the Drupal behaviors on the content of the dialog. | |
OpenDialogCommand:: |
protected | property | The title of the dialog. | |
OpenDialogCommand:: |
public | function | Returns the dialog options. | |
OpenDialogCommand:: |
public | function | Sets a single dialog option value. | |
OpenDialogCommand:: |
public | function | Sets the dialog options array. | |
OpenDialogCommand:: |
public | function | Sets the dialog title (an alias of setDialogOptions). |