annotate core/modules/ckeditor/src/Ajax/AddStyleSheetCommand.php @ 19:fa3358dc1485 tip

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