You are here

protected function IndentBlock::getLibraryURL in CKEditor IndentBlock 8

Get the CKEditor Indentblock library URL.

2 calls to IndentBlock::getLibraryURL()
IndentBlock::getFile in src/Plugin/CKEditorPlugin/IndentBlock.php
Returns the Drupal root-relative file path to the plugin JavaScript file.
IndentBlock::settingsForm in src/Plugin/CKEditorPlugin/IndentBlock.php
Returns a settings form to configure this CKEditor plugin.

File

src/Plugin/CKEditorPlugin/IndentBlock.php, line 138

Class

IndentBlock
Defines the "Indent Block" plugin.

Namespace

Drupal\ckeditor_indentblock\Plugin\CKEditorPlugin

Code

protected function getLibraryURL() {

  // Search for the path under the current site for multisites.
  $directories[] = \Drupal::service('site.path') . "/libraries/";

  // Search also the root 'libraries' directory.
  $directories[] = 'libraries/';

  // Search also at the path for ckeditor plugins.
  $directories[] = 'libraries/ckeditor/plugins/';

  // Installation profiles can place libraries into a 'libraries' directory,
  // so search that too.
  if ($installProfile = \Drupal::installProfile()) {
    $profile_path = drupal_get_path('profile', $installProfile);
    $directories[] = "{$profile_path}/libraries/";
  }
  foreach ($directories as $dir) {
    if (file_exists(DRUPAL_ROOT . '/' . $dir . 'indentblock/plugin.js')) {
      return $dir . 'indentblock/plugin.js';
    }
  }

  // CKEditor Indentblock library not found.
  return '';
}