From 3c3692c8022887c0b92e344c689c110781606f3d Mon Sep 17 00:00:00 2001
From: Nathaniel Catchpole <catch@35733.no-reply.drupal.org>
Date: Tue, 21 Jul 2015 11:56:56 +0100
Subject: [PATCH] Issue #2536880 by alexpott: CKEditor admin form broken

---
 core/modules/ckeditor/src/Plugin/Editor/CKEditor.php |  2 +-
 .../modules/ckeditor/src/Tests/CKEditorAdminTest.php | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php b/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php
index 0e237b17e4a7..d5bd0b9a721a 100644
--- a/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php
+++ b/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php
@@ -157,7 +157,7 @@ public function settingsForm(array $form, FormStateInterface $form_state, Editor
         'library' => array('ckeditor/drupal.ckeditor.admin'),
         'drupalSettings' => [
           'ckeditor' => [
-            'toolbarAdmin' => $this->renderer->renderPlain($ckeditor_settings_toolbar),
+            'toolbarAdmin' => (string) $this->renderer->renderPlain($ckeditor_settings_toolbar),
           ],
         ],
       ),
diff --git a/core/modules/ckeditor/src/Tests/CKEditorAdminTest.php b/core/modules/ckeditor/src/Tests/CKEditorAdminTest.php
index d113a7609719..3ce82714a36a 100644
--- a/core/modules/ckeditor/src/Tests/CKEditorAdminTest.php
+++ b/core/modules/ckeditor/src/Tests/CKEditorAdminTest.php
@@ -117,6 +117,18 @@ function testExistingFormat() {
     $editor = entity_load('editor', 'filtered_html');
     $this->assertFalse($editor, 'No Editor config entity exists yet.');
 
+    // Ensure that drupalSettings is correct.
+    $ckeditor_settings_toolbar = array(
+      '#theme' => 'ckeditor_settings_toolbar',
+      '#editor' => Editor::create(['editor' => 'ckeditor']),
+      '#plugins' => $this->container->get('plugin.manager.ckeditor.plugin')->getButtons(),
+    );
+    $this->assertEqual(
+      $this->drupalSettings['ckeditor']['toolbarAdmin'],
+      $this->container->get('renderer')->renderPlain($ckeditor_settings_toolbar),
+      'CKEditor toolbar settings are rendered as part of drupalSettings.'
+    );
+
     // Ensure the toolbar buttons configuration value is initialized to the
     // expected default value.
     $expected_buttons_value = json_encode($expected_default_settings['toolbar']['rows']);
-- 
GitLab