Skip to content

Instantly share code, notes, and snippets.

@spotzero
Last active January 14, 2022 21:51
Show Gist options
  • Save spotzero/fe26851b00222fde8429f3b7a1a99a44 to your computer and use it in GitHub Desktop.
Save spotzero/fe26851b00222fde8429f3b7a1a99a44 to your computer and use it in GitHub Desktop.
fix for WxT Upgrade where rich_text is unavailable
diff --git a/modules/custom/wxt_core/src/UpdateWxT/UpdateWxT420.php b/modules/custom/wxt_core/src/UpdateWxT/UpdateWxT420.php
index 2d086ab..a1b66b8 100644
--- a/modules/custom/wxt_core/src/UpdateWxT/UpdateWxT420.php
+++ b/modules/custom/wxt_core/src/UpdateWxT/UpdateWxT420.php
@@ -64,25 +64,29 @@ public function enableCKEditorTOC() {
$this->moduleInstaller->install(['toc_filter']);
$format = FilterFormat::load('rich_text');
- $configuration = $format->filters('filter_caption')->getConfiguration();
- $format->setFilterConfig('entity_embed', ['weight' => $configuration['weight'] + 1]);
- $format->setFilterConfig('toc_filter', ['status' => TRUE, 'settings' => ['type' => 'wxt']]);
- $format->save();
+ if ($format) {
+ $configuration = $format->filters('filter_caption')->getConfiguration();
+ $format->setFilterConfig('entity_embed', ['weight' => $configuration['weight'] + 1]);
+ $format->setFilterConfig('toc_filter', ['status' => TRUE, 'settings' => ['type' => 'wxt']]);
+ $format->save();
+ }
$this->moduleInstaller->install(['ckeditor_abbreviation']);
$editor = Editor::load('rich_text');
- $settings = $editor->getSettings();
- $rows = $settings['toolbar']['rows'];
- foreach ($rows as $row_key => $row) {
- foreach ($row as $group_key => $group) {
- if ($group['name'] === 'WET Components') {
- array_unshift($settings['toolbar']['rows'][$row_key][$group_key]['items'], "abbr");
+ if ($editor) {
+ $settings = $editor->getSettings();
+ $rows = $settings['toolbar']['rows'];
+ foreach ($rows as $row_key => $row) {
+ foreach ($row as $group_key => $group) {
+ if ($group['name'] === 'WET Components') {
+ array_unshift($settings['toolbar']['rows'][$row_key][$group_key]['items'], "abbr");
+ }
}
}
+ $editor->setSettings($settings);
+ $editor->save();
}
- $editor->setSettings($settings);
- $editor->save();
}
/**
@@ -96,6 +100,9 @@ public function enableCKEditorAbbreviation() {
$this->moduleInstaller->install(['ckeditor_abbreviation']);
$editor = Editor::load('rich_text');
+ if (!$editor) {
+ return;
+ }
$settings = $editor->getSettings();
$rows = $settings['toolbar']['rows'];
foreach ($rows as $row_key => $row) {
@@ -118,6 +125,9 @@ public function enableCKEditorAbbreviation() {
*/
public function enableCKEditorAlert() {
$editor = Editor::load('rich_text');
+ if (!$editor) {
+ return;
+ }
$settings = $editor->getSettings();
$rows = $settings['toolbar']['rows'];
foreach ($rows as $row_key => $row) {
@@ -140,6 +150,9 @@ public function enableCKEditorAlert() {
*/
public function enableCKEditorFootnotes() {
$editor = Editor::load('rich_text');
+ if (!$editor) {
+ return;
+ }
$settings = $editor->getSettings();
$rows = $settings['toolbar']['rows'];
foreach ($rows as $row_key => $row) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment