Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. CloseDialogCommand.php

class CloseDialogCommand

Defines an AJAX command that closes the current active dialog.

Hierarchy

  • class \Drupal\Core\Ajax\CloseDialogCommand implements \Drupal\Core\Ajax\CommandInterface

Expanded class hierarchy of CloseDialogCommand

Related topics

Ajax API
Overview for Drupal's Ajax API.
4 files declare their use of CloseDialogCommand
AddFormBase.php in core/modules/media_library/src/Form/AddFormBase.php
ContentModerationConfigureEntityTypesForm.php in core/modules/content_moderation/src/Form/ContentModerationConfigureEntityTypesForm.php
LayoutRebuildTrait.php in core/modules/layout_builder/src/Controller/LayoutRebuildTrait.php
MediaLibrarySelectForm.php in core/modules/media_library/src/Plugin/views/field/MediaLibrarySelectForm.php

File

core/lib/Drupal/Core/Ajax/CloseDialogCommand.php, line 10

Namespace

Drupal\Core\Ajax
View source
class CloseDialogCommand implements CommandInterface {
    
    /**
     * A CSS selector string of the dialog to close.
     *
     * @var string
     */
    protected $selector;
    
    /**
     * Whether to persist the dialog in the DOM or not.
     *
     * @var bool
     */
    protected $persist;
    
    /**
     * Constructs a CloseDialogCommand object.
     *
     * @param string $selector
     *   A CSS selector string of the dialog to close.
     * @param bool $persist
     *   (optional) Whether to persist the dialog in the DOM or not.
     */
    public function __construct($selector = NULL, $persist = FALSE) {
        $this->selector = $selector ? $selector : '#drupal-modal';
        $this->persist = $persist;
    }
    
    /**
     * {@inheritdoc}
     */
    public function render() {
        return [
            'command' => 'closeDialog',
            'selector' => $this->selector,
            'persist' => $this->persist,
        ];
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
CloseDialogCommand::$persist protected property Whether to persist the dialog in the DOM or not.
CloseDialogCommand::$selector protected property A CSS selector string of the dialog to close.
CloseDialogCommand::render public function Return an array to be run through json_encode and sent to the client. Overrides CommandInterface::render
CloseDialogCommand::__construct public function Constructs a CloseDialogCommand object. 1
RSS feed
Powered by Drupal