OpenModalCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 28
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
1
<?php
2
3
namespace Drupal\paragraphs_editor\Ajax;
4
5
use Drupal\Core\Ajax\OpenModalDialogCommand;
6
use Drupal\paragraphs_editor\EditorCommand\CommandContextInterface;
7
8
/**
9
 * Opens an ajax dialog for a specific editor context.
10
 */
11
class OpenModalCommand extends OpenModalDialogCommand {
12
13
  /**
14
   * Creates an OpenModelCommand.
15
   *
16
   * @param string $title
17
   *   The title of the dialog.
18
   * @param string|array $content
19
   *   The content that will be placed in the dialog, either a render array
20
   *   or an HTML string.
21
   * @param \Drupal\paragraphs_editor\EditorCommand\CommandContextInterface $context
22
   *   The context to open the dialog for.
23
   * @param array $dialog_options
24
   *   (optional) Settings to be passed to the dialog implementation. Any
25
   *   jQuery UI option can be used. See http://api.jqueryui.com/dialog.
26
   * @param array|null $settings
27
   *   (optional) Custom settings that will be passed to the Drupal behaviors
28
   *   on the content of the dialog. If left empty, the settings will be
29
   *   populated automatically from the current request.
30
   */
31
  public function __construct($title, $content, CommandContextInterface $context, array $dialog_options = [], $settings = NULL) {
32
    if (empty($dialog_options['width'])) {
33
      $dialog_options['width'] = '75%';
34
      $dialog_options['dialogClass'] = 'paragraphs-editor-dialog';
35
    }
36
37
    parent::__construct($title, $content, $dialog_options, $settings);
38
    $this->selector = '#paragraphs-ckeditor-modal-' . md5($context->getContextString());
39
  }
40
41
}
42