You are here

public function PanelButton::getFile in CKEditor Panel Button 8

Returns the Drupal root-relative file path to the plugin JavaScript file.

Note: this does not use a Drupal library because this uses CKEditor's API.

Return value

string|false The Drupal root-relative path to the file, FALSE if an internal plugin.

Overrides CKEditorPluginInterface::getFile

See also

https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_resourceManager....

File

src/Plugin/CKEditorPlugin/PanelButton.php, line 21

Class

PanelButton
Defines the "panelbutton" plugin.

Namespace

Drupal\panelbutton\Plugin\CKEditorPlugin

Code

public function getFile() {

  // @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('panelbutton/plugin.js');
  }
  elseif (\Drupal::moduleHandler()
    ->moduleExists('libraries')) {
    $path = libraries_get_path('panelbutton') . '/plugin.js';
  }
  else {
    $path = 'libraries/panelbutton/plugin.js';
  }
  return $path;
}