Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / lib / Drupal / Core / Ajax / AddCssCommand.php
1 <?php
2
3 namespace Drupal\Core\Ajax;
4
5 /**
6  * An AJAX command for adding css to the page via ajax.
7  *
8  * This command is implemented by Drupal.AjaxCommands.prototype.add_css()
9  * defined in misc/ajax.js.
10  *
11  * @see misc/ajax.js
12  *
13  * @ingroup ajax
14  */
15 class AddCssCommand implements CommandInterface {
16
17   /**
18    * A string that contains the styles to be added to the page.
19    *
20    * It should include the wrapping style tag.
21    *
22    * @var string
23    */
24   protected $styles;
25
26   /**
27    * Constructs an AddCssCommand.
28    *
29    * @param string $styles
30    *   A string that contains the styles to be added to the page, including the
31    *   wrapping <style> tag.
32    */
33   public function __construct($styles) {
34     $this->styles = $styles;
35   }
36
37   /**
38    * Implements Drupal\Core\Ajax\CommandInterface:render().
39    */
40   public function render() {
41
42     return [
43       'command' => 'add_css',
44       'data' => $this->styles,
45     ];
46   }
47
48 }