From 4c3869fad23e5e42fc62b33490ca1beafc6b9dc3 Mon Sep 17 00:00:00 2001 From: Dave Reid <reid.dave@principal.com> Date: Thu, 26 May 2022 12:31:06 -0500 Subject: [PATCH 1/2] Do not override EmbedCKEditorPluginBase::getLibraries(). Fix for deprecated drupal_get_path(). --- src/Plugin/CKEditorPlugin/DrupalEntity.php | 31 ++++++++++++---------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/Plugin/CKEditorPlugin/DrupalEntity.php b/src/Plugin/CKEditorPlugin/DrupalEntity.php index 7e0e4599..6c06a7f2 100644 --- a/src/Plugin/CKEditorPlugin/DrupalEntity.php +++ b/src/Plugin/CKEditorPlugin/DrupalEntity.php @@ -31,18 +31,7 @@ class DrupalEntity extends EmbedCKEditorPluginBase implements CKEditorPluginCssI * {@inheritdoc} */ public function getFile() { - return drupal_get_path('module', 'entity_embed') . '/js/plugins/drupalentity/plugin.js'; - } - - /** - * {@inheritdoc} - */ - public function getLibraries(Editor $editor) { - return [ - 'core/jquery', - 'core/drupal', - 'core/drupal.ajax', - ]; + return $this->getModulePath('entity_embed') . '/js/plugins/drupalentity/plugin.js'; } /** @@ -62,9 +51,23 @@ class DrupalEntity extends EmbedCKEditorPluginBase implements CKEditorPluginCssI */ public function getCssFiles(Editor $editor) { return [ - drupal_get_path('module', 'system') . '/css/components/hidden.module.css', - drupal_get_path('module', 'entity_embed') . '/css/entity_embed.editor.css', + $this->getModulePath('system') . '/css/components/hidden.module.css', + $this->getModulePath('entity_embed') . '/css/entity_embed.editor.css', ]; } + /** + * {@inheritdoc} + * + * Backwards compatible version for Drupal 9.2. + */ + protected function getModulePath(string $module_name): string { + // CKEditorPluginBase::getModulePath() was added in Drupal 9.3+ + if (is_callable('parent::getModulePath')) { + return parent::getModulePath($module_name); + } + + return \Drupal::service('extension.list.module')->getPath($module_name); + } + } -- GitLab From 447a777235f56718ade671612bb3a586acfb4615 Mon Sep 17 00:00:00 2001 From: Dave Reid <reid.dave@principal.com> Date: Thu, 26 May 2022 16:18:21 -0500 Subject: [PATCH 2/2] Fixed comment missing period. --- src/Plugin/CKEditorPlugin/DrupalEntity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Plugin/CKEditorPlugin/DrupalEntity.php b/src/Plugin/CKEditorPlugin/DrupalEntity.php index 6c06a7f2..39b8028e 100644 --- a/src/Plugin/CKEditorPlugin/DrupalEntity.php +++ b/src/Plugin/CKEditorPlugin/DrupalEntity.php @@ -62,7 +62,7 @@ class DrupalEntity extends EmbedCKEditorPluginBase implements CKEditorPluginCssI * Backwards compatible version for Drupal 9.2. */ protected function getModulePath(string $module_name): string { - // CKEditorPluginBase::getModulePath() was added in Drupal 9.3+ + // CKEditorPluginBase::getModulePath() was added in Drupal 9.3+. if (is_callable('parent::getModulePath')) { return parent::getModulePath($module_name); } -- GitLab