Created
September 7, 2020 14:19
-
-
Save szeidler/1cf8f60973e9970f2622739e52f94d44 to your computer and use it in GitHub Desktop.
D9 non-libraries support for colordialog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/colordialog.info.yml b/colordialog.info.yml | |
index 090bf73..ccac3a3 100644 | |
--- a/colordialog.info.yml | |
+++ b/colordialog.info.yml | |
@@ -2,7 +2,7 @@ name: CKEditor Color Dialog | |
type: module | |
description: "Adds in the Color Dialog plugin for CKEditor." | |
package: CKEditor | |
-core: 8.x | |
+core_version_requirement: ^8 || ^9 | |
dependencies: | |
- drupal:ckeditor | |
diff --git a/colordialog.install b/colordialog.install | |
index e228f7c..c4270b9 100644 | |
--- a/colordialog.install | |
+++ b/colordialog.install | |
@@ -11,11 +11,12 @@ | |
function colordialog_requirements($phase) { | |
$requirements = []; | |
- $path = '/libraries/colordialog/plugin.js'; | |
- if (\Drupal::moduleHandler()->moduleExists('libraries')) { | |
- $path = libraries_get_path('colordialog') . '/plugin.js'; | |
+ if (\Drupal::hasService('library.libraries_directory_file_finder')) { | |
+ $path = \Drupal::service('library.libraries_directory_file_finder')->find('colordialog/plugin.js'); | |
+ } | |
+ else { | |
+ $path = DRUPAL_ROOT . '/libraries/colordialog/plugin.js'; | |
} | |
- $path = DRUPAL_ROOT . '/' . $path; | |
if (!file_exists($path)) { | |
$requirements['colordialog'] = [ | |
diff --git a/src/Plugin/CKEditorPlugin/ColorDialog.php b/src/Plugin/CKEditorPlugin/ColorDialog.php | |
index 04e14c0..8f867b7 100644 | |
--- a/src/Plugin/CKEditorPlugin/ColorDialog.php | |
+++ b/src/Plugin/CKEditorPlugin/ColorDialog.php | |
@@ -20,9 +20,11 @@ class ColorDialog extends CKEditorPluginBase implements CKEditorPluginContextual | |
* {@inheritdoc} | |
*/ | |
public function getFile() { | |
- $path = 'libraries/colordialog/plugin.js'; | |
- if (\Drupal::moduleHandler()->moduleExists('libraries')) { | |
- $path = libraries_get_path('colordialog', FALSE) . '/plugin.js'; | |
+ if (\Drupal::hasService('library.libraries_directory_file_finder')) { | |
+ $path = \Drupal::service('library.libraries_directory_file_finder')->find('colordialog/plugin.js'); | |
+ } | |
+ else { | |
+ $path = DRUPAL_ROOT . '/libraries/colordialog/plugin.js'; | |
} | |
return $path; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment