comparison core/modules/ckeditor/src/Ajax/AddStyleSheetCommand.php @ 0:c75dbcec494b

Initial commit from drush-created site
author Chris Cannam
date Thu, 05 Jul 2018 14:24:15 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:c75dbcec494b
1 <?php
2
3 namespace Drupal\ckeditor\Ajax;
4
5 use Drupal\Core\Ajax\CommandInterface;
6
7 /**
8 * AJAX command to add style sheets to a CKEditor instance.
9 */
10 class AddStyleSheetCommand implements CommandInterface {
11
12 /**
13 * The CKEditor instance ID.
14 *
15 * @var string
16 */
17 protected $editorId;
18
19 /**
20 * The style sheet URLs to add to the CKEditor instance.
21 *
22 * @var string[]
23 */
24 protected $styleSheets = [];
25
26 /**
27 * AddStyleSheetCommand constructor.
28 *
29 * @param string $editor_id
30 * The CKEditor instance ID.
31 * @param string[] $stylesheets
32 * The style sheet URLs to add to the CKEditor instance.
33 */
34 public function __construct($editor_id, array $stylesheets = []) {
35 $this->editorId = $editor_id;
36 $this->styleSheets = $stylesheets;
37 }
38
39 /**
40 * Adds a style sheet to the CKEditor instance.
41 *
42 * @param string $stylesheet
43 * The style sheet URL.
44 *
45 * @return $this
46 * The called object, for chaining.
47 */
48 public function addStyleSheet($stylesheet) {
49 $this->styleSheets[] = $stylesheet;
50 return $this;
51 }
52
53 /**
54 * {@inheritdoc}
55 */
56 public function render() {
57 return [
58 'command' => 'ckeditor_add_stylesheet',
59 'editor_id' => $this->editorId,
60 'stylesheets' => $this->styleSheets,
61 ];
62 }
63
64 }