You are here

public static function ContentSyncDialogHelper::getModalDialogAttributes in Content Synchronization 8

Same name and namespace in other branches
  1. 8.2 src/Utility/ContentSyncDialogHelper.php \Drupal\content_sync\Utility\ContentSyncDialogHelper::getModalDialogAttributes()
  2. 3.0.x src/Utility/ContentSyncDialogHelper.php \Drupal\content_sync\Utility\ContentSyncDialogHelper::getModalDialogAttributes()

Get modal dialog attributes.

Parameters

int $width: Width of the modal dialog.

array $class: Additional class names to be included in the dialog's attributes.

Return value

array Modal dialog attributes.

File

src/Utility/ContentSyncDialogHelper.php, line 81

Class

ContentSyncDialogHelper
Helper class for dialog methods.

Namespace

Drupal\content_sync\Utility

Code

public static function getModalDialogAttributes($width = 800, array $class = []) {
  if (\Drupal::config('content_sync.settings')
    ->get('ui.dialog_disabled')) {
    return $class ? [
      'class' => $class,
    ] : [];
  }
  else {
    $class[] = 'use-ajax';
    if (content_syncDialogHelper::useOffCanvas()) {
      return [
        'class' => $class,
        'data-dialog-type' => 'dialog',
        'data-dialog-renderer' => self::getOffCanvasTriggerName(),
        'data-dialog-options' => Json::encode([
          'width' => $width > 480 ? 480 : $width,
        ]),
      ];
    }
    else {
      return [
        'class' => $class,
        'data-dialog-type' => 'modal',
        'data-dialog-options' => Json::encode([
          'width' => $width,
        ]),
      ];
    }
  }
}