Mercurial > hg > isophonics-drupal-site
comparison core/lib/Drupal/Core/Ajax/AddCssCommand.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
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 } |