You are here

class CloseDialogCommand in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Ajax/CloseDialogCommand.php \Drupal\Core\Ajax\CloseDialogCommand

Defines an AJAX command that closes the current active dialog.

Hierarchy

Expanded class hierarchy of CloseDialogCommand

Related topics

2 files declare their use of CloseDialogCommand
AjaxCommandsTest.php in core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php
Contains \Drupal\Tests\Core\Ajax\AjaxCommandsTest.
AjaxTestController.php in core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php
Contains \Drupal\ajax_test\Controller\AjaxTestController.

File

core/lib/Drupal/Core/Ajax/CloseDialogCommand.php, line 15
Contains \Drupal\Core\Ajax\CloseDialogCommand.

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 array(
      'command' => 'closeDialog',
      'selector' => $this->selector,
      'persist' => $this->persist,
    );
  }

}

Members

Namesort descending Modifiers Type Description 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