1. 8.5.x core/lib/Drupal/Core/Ajax/OpenOffCanvasDialogCommand.php OpenOffCanvasDialogCommand
  2. 8.2.x core/modules/outside_in/src/Ajax/OpenOffCanvasDialogCommand.php OpenOffCanvasDialogCommand
  3. 8.3.x core/modules/outside_in/src/Ajax/OpenOffCanvasDialogCommand.php OpenOffCanvasDialogCommand
  4. 8.4.x core/modules/settings_tray/src/Ajax/OpenOffCanvasDialogCommand.php OpenOffCanvasDialogCommand
  5. 8.6.x core/lib/Drupal/Core/Ajax/OpenOffCanvasDialogCommand.php OpenOffCanvasDialogCommand

Defines an AJAX command to open content in a dialog in a off-canvas dialog.



Expanded class hierarchy of OpenOffCanvasDialogCommand

Related topics

2 files declare their use of OpenOffCanvasDialogCommand
OffCanvasRenderer.php in core/modules/settings_tray/src/Render/MainContent/OffCanvasRenderer.php
OpenOffCanvasDialogCommandTest.php in core/modules/settings_tray/tests/src/Unit/Ajax/OpenOffCanvasDialogCommandTest.php


core/modules/settings_tray/src/Ajax/OpenOffCanvasDialogCommand.php, line 14


View source
class OpenOffCanvasDialogCommand extends OpenDialogCommand {

   * The dialog width to use if none is provided.

   * Constructs an OpenOffCanvasDialogCommand object.
   * The off-canvas dialog differs from the normal modal provided by
   * OpenDialogCommand in that a off-canvas has built in positioning and
   * behaviours. Drupal provides a built-in off-canvas dialog for this purpose,
   * so the selector is hard-coded in the call to the parent constructor.
   * @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) {
    parent::__construct('#drupal-off-canvas', $title, $content, $dialog_options, $settings);
    $this->dialogOptions['modal'] = FALSE;
    $this->dialogOptions['autoResize'] = FALSE;
    $this->dialogOptions['resizable'] = 'w';
    $this->dialogOptions['draggable'] = FALSE;
    $this->dialogOptions['drupalAutoButtons'] = FALSE;

    // @todo drupal.ajax.js does not respect drupalAutoButtons properly, pass an
    //   empty set of buttons until https://www.drupal.org/node/2793343 is in.
    $this->dialogOptions['buttons'] = [];
    if (empty($dialog_options['dialogClass'])) {
      $this->dialogOptions['dialogClass'] = 'ui-dialog-off-canvas';

    // If no width option is provided then use the default width to avoid the
    // dialog staying at the width of the previous instance when opened
    // more than once, with different widths, on a single page.
    if (!isset($this->dialogOptions['width'])) {
      $this->dialogOptions['width'] = static::DEFAULT_DIALOG_WIDTH;

   * {@inheritdoc}
  public function render() {
    $build = parent::render();
    $build['effect'] = 'fade';
    $build['speed'] = 1000;
    return $build;



Contains filters are case sensitive
Namesort descending Modifiers Type Description Overrides
CommandWithAttachedAssetsTrait::$attachedAssets protected property The attached assets for this Ajax command.
CommandWithAttachedAssetsTrait::getAttachedAssets public function Gets the attached assets. Overrides CommandWithAttachedAssetsInterface::getAttachedAssets
CommandWithAttachedAssetsTrait::getRenderedContent protected function Processes the content for output.
OpenDialogCommand::$content protected property The content for the dialog.
OpenDialogCommand::$dialogOptions 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::$selector protected property The selector of the dialog.
OpenDialogCommand::$settings protected property Custom settings that will be passed to the Drupal behaviors on the content of the dialog.
OpenDialogCommand::$title protected property The title of the dialog.
OpenDialogCommand::getDialogOptions public function Returns the dialog options.
OpenDialogCommand::setDialogOption public function Sets a single dialog option value.
OpenDialogCommand::setDialogOptions public function Sets the dialog options array.
OpenDialogCommand::setDialogTitle public function Sets the dialog title (an alias of setDialogOptions).
OpenOffCanvasDialogCommand::DEFAULT_DIALOG_WIDTH constant The dialog width to use if none is provided.
OpenOffCanvasDialogCommand::render public function Implements \Drupal\Core\Ajax\CommandInterface:render(). Overrides OpenDialogCommand::render
OpenOffCanvasDialogCommand::__construct public function Constructs an OpenOffCanvasDialogCommand object. Overrides OpenDialogCommand::__construct