Commit e9ea7d5c authored by Krzysztof Domański's avatar Krzysztof Domański Committed by Krzysztof Domański

Issue #3042721 by Krzysztof Domański, driverok: Replace all...

Issue #3042721 by Krzysztof Domański, driverok: Replace all libraries_get_path() calls with the new API
parent e75f4241
......@@ -11,11 +11,18 @@
function colorbutton_requirements($phase) {
$requirements = [];
$path = 'libraries/colorbutton/plugin.js';
if (\Drupal::moduleHandler()->moduleExists('libraries')) {
$path = libraries_get_path('colorbutton') . '/plugin.js';
// @todo Remove backward compatibility conditions when we bump Drupal
// requirement to 8.9.0. See https://www.drupal.org/node/3099614
if (\Drupal::hasService('library.libraries_directory_file_finder')) {
/** @var \Drupal\Core\Asset\LibrariesDirectoryFileFinder $library_file_finder */
$path = \Drupal::service('library.libraries_directory_file_finder')->find('colorbutton/plugin.js');
}
else {
$path = DRUPAL_ROOT . '/libraries/colorbutton/plugin.js';
if (\Drupal::moduleHandler()->moduleExists('libraries')) {
$path = libraries_get_path('colorbutton') . '/plugin.js';
}
}
$path = DRUPAL_ROOT . '/' . $path;
if (!file_exists($path)) {
$requirements['colorbutton'] = [
......
......@@ -21,11 +21,18 @@ class ColorButton extends CKEditorPluginBase implements CKEditorPluginConfigurab
* Get path to library folder.
*/
public function getLibraryPath() {
$path = 'libraries/colorbutton';
if (\Drupal::moduleHandler()->moduleExists('libraries')) {
// @todo Remove backward compatibility conditions when we bump Drupal
// requirement to 8.9.0. See https://www.drupal.org/node/3099614
if (\Drupal::hasService('library.libraries_directory_file_finder')) {
/** @var \Drupal\Core\Asset\LibrariesDirectoryFileFinder $library_file_finder */
$path = \Drupal::service('library.libraries_directory_file_finder')->find('colorbutton');
}
elseif (\Drupal::moduleHandler()->moduleExists('libraries')) {
$path = libraries_get_path('colorbutton');
}
else {
$path = 'libraries/colorbutton';
}
return $path;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment