Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / lib / Drupal / Core / Ajax / SetDialogOptionCommand.php
1 <?php
2
3 namespace Drupal\Core\Ajax;
4
5 /**
6  * Defines an AJAX command that sets jQuery UI dialog properties.
7  *
8  * @ingroup ajax
9  */
10 class SetDialogOptionCommand implements CommandInterface {
11
12   /**
13    * A CSS selector string.
14    *
15    * @var string
16    */
17   protected $selector;
18
19   /**
20    * A jQuery UI dialog option name.
21    *
22    * @var string
23    */
24   protected $optionName;
25
26   /**
27    * A jQuery UI dialog option value.
28    *
29    * @var mixed
30    */
31   protected $optionValue;
32
33   /**
34    * Constructs a SetDialogOptionCommand object.
35    *
36    * @param string $selector
37    *   The selector of the dialog whose title will be set. If set to an empty
38    *   value, the default modal dialog will be selected.
39    * @param string $option_name
40    *   The name of the option to set. May be any jQuery UI dialog option.
41    *   See http://api.jqueryui.com/dialog.
42    * @param mixed $option_value
43    *   The value of the option to be passed to the dialog.
44    */
45   public function __construct($selector, $option_name, $option_value) {
46     $this->selector = $selector ? $selector : '#drupal-modal';
47     $this->optionName = $option_name;
48     $this->optionValue = $option_value;
49   }
50
51   /**
52    * {@inheritdoc}
53    */
54   public function render() {
55     return [
56       'command' => 'setDialogOption',
57       'selector' => $this->selector,
58       'optionName' => $this->optionName,
59       'optionValue' => $this->optionValue,
60     ];
61   }
62
63 }