function OpenDialogCommand::render

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Ajax/OpenDialogCommand.php \Drupal\Core\Ajax\OpenDialogCommand::render()
  2. 10 core/lib/Drupal/Core/Ajax/OpenDialogCommand.php \Drupal\Core\Ajax\OpenDialogCommand::render()
  3. 9 core/lib/Drupal/Core/Ajax/OpenDialogCommand.php \Drupal\Core\Ajax\OpenDialogCommand::render()
  4. 8.9.x core/lib/Drupal/Core/Ajax/OpenDialogCommand.php \Drupal\Core\Ajax\OpenDialogCommand::render()

Implements \Drupal\Core\Ajax\CommandInterface:render().

Overrides CommandInterface::render

1 call to OpenDialogCommand::render()
OpenOffCanvasDialogCommand::render in core/lib/Drupal/Core/Ajax/OpenOffCanvasDialogCommand.php
1 method overrides OpenDialogCommand::render()
OpenOffCanvasDialogCommand::render in core/lib/Drupal/Core/Ajax/OpenOffCanvasDialogCommand.php

File

core/lib/Drupal/Core/Ajax/OpenDialogCommand.php, line 142

Class

OpenDialogCommand
Defines an AJAX command to open certain content in a dialog.

Namespace

Drupal\Core\Ajax

Code

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'];
  if (!empty($this->dialogOptions['buttons'])) {
    foreach ($this->dialogOptions['buttons'] as &$button) {
      // Only allow specific attributes to be defined for a button.
      $button = \array_intersect_key($button, \array_flip([
        'disabled',
        'icons',
        'label',
        'text',
      ]));
      foreach ($button as &$value) {
        if (is_string($value)) {
          // Apply Xss::filter to button attribute values.
          $value = Xss::filter($value);
        }
      }
    }
  }
  return [
    'command' => 'openDialog',
    'selector' => $this->selector,
    'settings' => $this->settings,
    'data' => $this->getRenderedContent(),
    'dialogOptions' => $this->dialogOptions,
  ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.