Pull merge.
[yaffs-website] / web / core / lib / Drupal / Core / Ajax / RemoveCommand.php
1 <?php
2
3 namespace Drupal\Core\Ajax;
4
5 /**
6  * AJAX command for calling the jQuery remove() method.
7  *
8  * The 'remove' command instructs the client to use jQuery's remove() method
9  * to remove each of elements matched by the given selector, and everything
10  * within them.
11  *
12  * This command is implemented by Drupal.AjaxCommands.prototype.remove()
13  * defined in misc/ajax.js.
14  *
15  * @see http://docs.jquery.com/Manipulation/remove#expr
16  *
17  * @ingroup ajax
18  */
19 class RemoveCommand implements CommandInterface {
20
21   /**
22    * The CSS selector for the element(s) to be removed.
23    *
24    * @var string
25    */
26   protected $selector;
27
28   /**
29    * Constructs a RemoveCommand object.
30    *
31    * @param string $selector
32    */
33   public function __construct($selector) {
34     $this->selector = $selector;
35   }
36
37   /**
38    * Implements Drupal\Core\Ajax\CommandInterface:render().
39    */
40   public function render() {
41     return [
42       'command' => 'remove',
43       'selector' => $this->selector,
44     ];
45   }
46
47 }