Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / lib / Drupal / Core / Ajax / ChangedCommand.php
1 <?php
2
3 namespace Drupal\Core\Ajax;
4
5 /**
6  * An AJAX command for marking HTML elements as changed.
7  *
8  * This command instructs the client to mark each of the elements matched by the
9  * given selector as 'ajax-changed'.
10  *
11  * This command is implemented by Drupal.AjaxCommands.prototype.changed()
12  * defined in misc/ajax.js.
13  *
14  * @ingroup ajax
15  */
16 class ChangedCommand implements CommandInterface {
17
18   /**
19    * A CSS selector string.
20    *
21    * If the command is a response to a request from an #ajax form element then
22    * this value can be NULL.
23    *
24    * @var string
25    */
26   protected $selector;
27
28   /**
29    * An optional CSS selector for elements to which asterisks will be appended.
30    *
31    * @var string
32    */
33   protected $asterisk;
34
35   /**
36    * Constructs a ChangedCommand object.
37    *
38    * @param string $selector
39    *   CSS selector for elements to be marked as changed.
40    * @param string $asterisk
41    *   CSS selector for elements to which an asterisk will be appended.
42    */
43   public function __construct($selector, $asterisk = '') {
44     $this->selector = $selector;
45     $this->asterisk = $asterisk;
46   }
47
48   /**
49    * Implements Drupal\Core\Ajax\CommandInterface:render().
50    */
51   public function render() {
52
53     return [
54       'command' => 'changed',
55       'selector' => $this->selector,
56       'asterisk' => $this->asterisk,
57     ];
58   }
59
60 }